Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail if Jar task replaces output of another #1624

Closed
carlolf opened this issue Mar 21, 2017 · 6 comments
Closed

Fail if Jar task replaces output of another #1624

carlolf opened this issue Mar 21, 2017 · 6 comments

Comments

@carlolf
Copy link

carlolf commented Mar 21, 2017

Expected Behavior

The manual states for MavenPublishing two methods a closure might use:

  • artifact: with a task argument serving as the output of the given task
  • setArtifacts: argument list for the artifacts
    So, my expectation is, either should work.

Current Behavior

Using artifact method with the task argument, this error occurs:

Execution failed for task ':de.uvdms.jadice.common:publishMavenJavaPublicationToMavenRepository'.
Failed to publish publication 'mavenJava' to repository 'maven'
Invalid publication 'mavenJava': multiple artifacts with the identical extension and classifier ('jar', 'null').

Using the method artifacts with task argument in the form [ serverJarWithoutAnnoProfile ], the regular jar is published - which I do not want.

Context

What I'm trying to do: NOT to publish the regular built jar, but a special jar built by calling a user task (serverJarWithoutAnnoProfile).

Steps to Reproduce (for bugs)

This is my user task:
task serverJarWithoutAnnoProfile(type: Jar) { archiveName jadiceCommonWebappJar from(sourceSets.main.output) }
The publish closure is this:
publishing.publications { mavenJava(MavenPublication) { artifacts = [ serverJarWithoutAnnoProfile ] //artifact serverJarWithoutAnnoProfile } }

Your Environment

I use Gradle 3.4.1 with JDK 1.7 under Windows 10.

@bmuschko bmuschko added a:question in:publishing-plugins ivy-publish maven-publish labels Mar 22, 2017
@oehme
Copy link
Contributor

oehme commented Sep 15, 2017

Your Jar task needs to define a classifier, otherwise you are overwriting the main Jar accidentally. We should fail on this earlier to make that clear to the user.

@oehme oehme changed the title MavenPublishing not working as expected Fail if Jar task replaces output of another Sep 15, 2017
@oehme
Copy link
Contributor

oehme commented Sep 15, 2017

Duplicate of #2299

@oehme oehme marked this as a duplicate of #2299 Sep 15, 2017
@oehme oehme closed this as completed Sep 15, 2017
@carlolf
Copy link
Author

carlolf commented Sep 20, 2017

Hi Stefan,
I tried with a classifier. But this does no solve my problem. I want to upload this special jar now qualified with a classifier. But it does not get uploaded by the puplish task. Instead, publish uploads the 'normal' jar - this is not wanted. See the closure above.
I have no idea how I can solve this case if the publish closure does not work.

@carlolf
Copy link
Author

carlolf commented Sep 20, 2017

Ah, now I got it! I had to set the classifier qualifiying the artifact level.

One problem I need to solve: how to exclude the normal jar from uploading? Is there a skip statement?

@oehme
Copy link
Contributor

oehme commented Sep 20, 2017

Calling artifacts = [...] (as you showed above) should overwrite which artifacts are published. If that doesn't work, could you create a small example project showing the problem?

@carlolf
Copy link
Author

carlolf commented Oct 20, 2017

yes, thank you. Declaring artifacts = [serverJarWithoutAnnoProfile , sourcesJar] did the correct job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants