This message was deleted.
# community-support
s
This message was deleted.
a
the
artifact {}
block doesn’t have a
files()
function
Copy code
dependencies {
  implementation("com.twitter:twitter-api-java-sdk:2.0.3") {
    artifact {
      this.files() // ERROR: Unresolved reference: files
    }
  }
}
d
IntelliJ suggested me towards that solution and it didn't explode. 🤔 (I know IntelliJ has never been reliable on gradle syntax)
@Adam But do you have any suggestions?
a
it won’t explode, but it also won’t do anything :).
files()
calls Project.files(), which will create a new file collection, which is allowed, but then nothing happens
d
Haha voiding the result. Perfect. 😛
a
if what you have here https://gradle-community.slack.com/archives/CAHSN3LDN/p1689522787197249 works, then that sounds good. I think there might be a way to do it properly with some sort of custom dependency resolution rule https://docs.gradle.org/current/userguide/resolution_rules.html, but those are phenomenally complicated and difficult. Or with an exclusion / local file-based repository https://stackoverflow.com/questions/19701053/how-do-i-replace-a-gradle-module-dependency-with-a-jar, but that seems hacky.
btw it’s a good idea to keep all your replies in a single thread, rather than sending multiple messages in the main channel, else the conversation gets difficult to follow
d
The solution I found works. But it lost its
javadoc
and
sources
reference. If there is a way to provide them into the
implementation
thing, that would be great!
I didn't know you did threads here, so sure. 🙂
1
a
how are you building this custom artifact?
d
Opened up that project locally and ran maven package, got four jars;
main
,
javadoc
,
sources
and
test
. Copied them over to this project. Didn't want to publish.
a
if you want to keep the sources (Javadoc shouldn’t be necessary if you have the sources, right?), then maybe you could add it as an included build? https://github.com/melix/includegit-gradle-plugin
ah it’s Maven, that makes it more difficult
d
Yeah, I was thinking of a subproject thing. But mixing wont work
a
you could publish it to MavenLocal?
d
Sure, I guess I could. Would work fine on my dev environment, but will be problem later with building docker images in ci or whatever
a
d
yeah
kinda dead project
2022 lol
a
hmmmm well, there are a few options. One would be to fork it and convert it to a Gradle project. It doesn’t look that complicated - just check it out, cd into project dir, and run
gradle init
to run the auto conversion
d
And then I could include that fork as a dependency via that plugin you linked?
a
yes that’s right
or you could set up some Gradle magic 1. download the project https://stackoverflow.com/a/34327202/4161471 2. create a Gradle Exec task that will run Maven, and publish the project to Maven Local
d
It generated with
api
instead of
implementation
, what's the difference? Does it matter?
a
or probably the easiest, but most manual, is to just manually build & publish to Maven Local, and then copy the files - while keeping the directory structure - into your project So if Maven Local looks like this:
Copy code
.
└── m2/
    └── repository/
        └── com/
            └── blah/
                ├── whatever/
                │   ├── whatever.jar
                │   └── whatever-sources.jar
                └── maven.xml
Then you’d add in your project:
Copy code
.
└── myProject/
    └── maven-dir/
        └── com/
            └── blah/
                ├── whatever/
                │   ├── whatever.jar
                │   └── whatever-sources.jar
                └── maven.xml
Then add a local Maven directory for that file:
Copy code
repositories {
  maven(file("./maven-dir/"))
}
It generated with
api
instead of
implementation
, what’s the difference? Does it matter?
implementation
means “I need this dependency to build and run this project”,
api
is the same but additionally tells consumers “you need this dependency as well, so I’ll automatically add it to your dependency list”,
Maven doesn’t have that distinction, so when Gradle converts Maven projects then it picks the most compatible option - even if it’s not correct
d
ah it provides it upwards
1
That maven repo thing worked perfectly!
got all the stuff
a
nice!
d
It's a bit hacky, and I know it shouldn't be done. But whatever 😂
a
if it’s stupid and it works it’s not stupid 👍
d
haha true
installed git lfs for jars lol
But thanks for the help @Adam!
a
you’re welcome :)
t
Regarding your original question, did you try
Copy code
implementation("com.twitter:twitter-api-java-sdk:2.0.3") {
    artifact {
        url = uri("libs/twitter-api-java-sdk/twitter-api-java-sdk-2.0.3-jakarta10.jar").toString()
    }
}
(or something like that)
You could also try with something along the lines of:
Copy code
dependencies {
    components {
        withModule("…") {
            allVariants {
                withFiles {
                    removeAllFiles()
                    addFile("twitter-api-java-sdk-2.0.3.jar", uri("libs/…").toString())
☝️ 1