Attaching source jar with eclipse plugin

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Attaching source jar with eclipse plugin

Glyn Walters
This post was updated on .
Hi

Having some problems attaching a source jar. I have a project that creates a source jar like this:

task sourcesJar(type: Jar, dependsOn:classes) {    
        classifier = 'sources'    
        from sourceSets.main.allSource
    manifest {
        attributes 'Implementation-Title': 'Messaging Common Sources', 'Implementation-Version': version
    }
}

jar {
        dependsOn sourcesJar
    manifest {
        attributes 'Implementation-Title': 'Messaging Common', 'Implementation-Version': version
    }
}

The artifacts get created correctly on TeamCity (Team City as well as building, also acts as an ivy repo):

MessagingCommon-91933-sources.jar
MessagingCommon-91933.jar

In the project that has the dependency I have:

dependencies {
        compile group: "org", name: "bt544", version: '91933'
}

Then if I run "gradle eclipse" I can see in my new build path I have the following jars on the build path:

{gradleCacheDir}\MessagingCommon-91933-91933.jar and {gradleCacheDir}\MessagingCommon-91933-sources-91933.jar

But the jar is not acting as a souce jar if I refresh in eclipse. Is this anything to do with the extra "-91933" that was appended to the "-sources"? I'm not sure if "-91933-sources" becoming "-91933-sources-91933" is something gradle is doing or if its something the TeamCity Ivy is appending. Because if I go and get the artifacts directly it ends with "-sources".

Any advice would be appreciated.

Thanks
Glyn

Edit: using Gradle 1.0-milestone-7
Reply | Threaded
Open this post in threaded view
|

Re: Attaching source jar with eclipse plugin

Ruediger Schobbert
I wrote something concerning that subject some time ago:
http://gradle.1045684.n5.nabble.com/uploading-sources-and-javadocs-eclipse-plugin-is-very-strict-td4677989.html

Maybe it will help you.

Cheers,
Ruediger.

Am 16.02.2012 18:03, schrieb Glyn Walters:

> Hi
>
> Having some problems attaching a source jar. I have a project that creates a
> source jar like this:
>
> task sourcesJar(type: Jar, dependsOn:classes) {
> classifier = 'sources'
> from sourceSets.main.allSource
>      manifest {
>          attributes 'Implementation-Title': 'Messaging Common Sources',
> 'Implementation-Version': version
>      }
> }
>
> jar {
> dependsOn sourcesJar
>      manifest {
>          attributes 'Implementation-Title': 'Messaging Common',
> 'Implementation-Version': version
>      }
> }
>
> The artifacts get created correctly on TeamCity (Team City as well as
> building, also acts as an ivy repo):
>
> MessagingCommon-91933-sources.jar
> MessagingCommon-91933.jar
>
> In the project that has the dependency I have:
>
> dependencies {
> compile group: "org", name: "bt544", version: '91933'
> }
>
> Then if I run "gradle eclipse" I can see in my new build path I have the
> following jars on the build path:
>
> {gradleCacheDir}\MessagingCommon-91933-91933.jar and
> {gradleCacheDir}\MessagingCommon-91933-sources-91933.jar
>
> But the jar is not acting as a souce jar if I refresh in eclipse. Is this
> anything to do with the extra "-91933" that was appended to the "-sources"?
> I'm not sure if "-91933-sources" becoming "-91933-sources-91933" is
> something gradle is doing or if its something the TeamCity Ivy is appending.
> Because if I go and get the artifacts directly it ends with "-sources".
>
> Any advice would be appreciated.
>
> Thanks
> Glyn
>
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Attaching-source-jar-with-eclipse-plugin-tp5490090p5490090.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Attaching source jar with eclipse plugin

Glyn Walters
Hi Reudiger

Interesting, thanks for the link. So it looks like the key might be to make sure the sources jar is uploaded to the ivy repository as an artifact type='source'. Sadly I don't have control of this as in TeamCity the gradle build finishes at the point where all the artifacts have been created. The mapping then to it's internal ivy representation is done with artifact path mapping. E.g. on a project you set "build/libs/MessagingCommon-*.jar=>./" So there isn't actually a gradle task for uploading archives where I'd set the artifact type as far as I can tell.

So in the end the teamcity-ivy.xml that it generates looks like this, which is where the problem presumably lies:

<ivy-module version="1.4">
    <info organisation="org" module="bt544" revision="91951"/>
    <publications>
        <artifact name="MessagingCommon-91951-sources" type="jar" ext="jar"/>
        <artifact name="MessagingCommon-91951" type="jar" ext="jar"/>
    </publications>
</ivy-module>
Reply | Threaded
Open this post in threaded view
|

Re: Attaching source jar with eclipse plugin

Aaronlong31
In reply to this post by Glyn Walters
I had the same problem, and then I had resolved it.

Steps:
1. Right click your project, then select "Build Path" --> "Configure Build Path";
2. Select "Order and export"
3. Select "Web App Libraries", and click "Bottom" button, then the "Web App Libraries" will be on the bottom;
4. That's work, Good Luck!