Hello, I am having an issue getting my sources jar file to be recognized as such for my main binary jar file by gradle when it downloads the dependencies from our internal repository via ivy. It’s treating them as separate dependencies.
Let’s call my binary jar file ‘myco.jar’. It was built from another internal project within our company, and my project is dependent on it. It gets published to an artifactory repository along with a ‘myco-sources.jar’ file that contains the source code. This publishing is done in an ant task that uses ivy.
In my gradle.build, I specify the dependency like this:
implementation (group:“com.myco”, name:“mycoproj”, version:"${version}")
Then when I run gradle, I can see that it successfully downloads both ‘myco.jar’ and ‘myco-sources.jar’ and the build is successful. But when I go to the project build path (I am using eclipse), I see that it lists myco.jar and myco-sources.jar as separate dependencies instead of setting myco-sources.jar as the source code for myco.jar. This means that I still can’t access the source code when debugging, and eclipse won’t let me add it manually because it says the source attachment is non modifiable.
I don’t know how to get this binding to take place. It seems to automatically know to bind this information for the external dependencies like swagger and jersey.
I also see this in our gradle.build file, but I don’t know how relevant it is:
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
}
And this is how it accesses the repositories for the dependencies:
repositories {
ivy {
url = ivyUrl
credentials {
username = ivyUsername
password = ivyPassword
}
patternLayout {
ivy ivyPattern
artifact artifactPattern
}
}
mavenCentral()
}
This is how the ivy.xml file looks like that is used to publish the myco.jar and myco-sources.jar files:
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="com.myco" module="mycoproj"/>
<publications>
<artifact name="myco" type="jar" ext="jar"/>
<artifact name="myco" e:classifier="sources" type="source" ext="jar"/>
</publications>
<dependencies>
<dependency ... />
...
</dependencies>
</ivy-module>
and this is the ant task CI runs to publish to our repository:
<target name="publish-task" depends="xxx" description="xxx">
<ivy:resolve file="ivy.xml"/>
<ivy:publish pubrevision="${version}" status="integration" resolver="xxx" overwrite="true">
<artifacts pattern="${path}/[artifact]-[revision](-[classifier]).[ext]"/>
</ivy:publish>
<delete file="ivy-${version}.xml"/>
</target>