[GRADLE-2916] How do I place the POM generated from the maven-publish plugin inside the jar? Created: 04/Oct/13  Updated: 01/Feb/17  Resolved: 24/Jan/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Task
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 0


 Description   

I am trying out FUSE bundles ([1]http://fuse.fusesource.org/bundle/faq...). To use them, I have to place the POM for a jar inside the jar in the directory: "META-INF/maven/groupId/artifactId/pom.xml"

How would I go about placing the pom generated by that plugin inside the jar at the location described by the groupID/artifactID that was put in the pom?

Thanks
----------------------------------------------------------------------------------------
[1] http://fuse.fusesource.org/bundle/faq.html



 Comments   
Comment by Gradle Forums [ 04/Oct/13 ]

Assuming your publication is named `main`, the following should work. You may have to adapt `groupId` and `artifactId` as needed.

jar {
into("META-INF/maven/$project.group/$project.name") {
from generatePomFileForMainPublication
rename ".*", "pom.xml"
}
}

Comment by Gradle Forums [ 04/Oct/13 ]

I thought it was something like that, but I get this (the publication is mavenJava):

  • What went wrong:
    A problem occurred evaluating project ':example'.
    > No such property: generatePomFileForMavenJavaPublication for class: org.gradle.api.internal.file.copy.CopySpecImpl_Decorated
Comment by Gradle Forums [ 04/Oct/13 ]

This might be related to the new configuration approach used for the `maven-publish` plugin. I recommend to try with the latest nightly build.

Comment by Gradle Forums [ 04/Oct/13 ]

Ok, I will give that a shot when I come in tomorrow. Thanks for the replies!

Comment by Gradle Forums [ 04/Oct/13 ]

Still doesn't work with the nightly.

$ gr :example:clean :example:jar
Parallel execution with configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

  • Where:
    Build file 'C:\path\to\example\build.gradle' line: 3
  • What went wrong:
    A problem occurred evaluating project ':example'.
    > No such property: generatePomFileForMavenJavaPublication for class: org.gradle.api.internal.file.copy.DefaultCopySpec_Decorated
  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.898 secs

$ gr --version

------------------------------------------------------------
Gradle 1.9-20131003220019+0000
------------------------------------------------------------

Build time: 2013-10-03 22:00:19 UTC
Build number: none
Revision: 7970ec3503b4f5767ee1c1c69f8b4186c4763e3d

Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy: 2.2.0
JVM: 1.7.0_21 (Oracle Corporation 23.21-b01)
OS: Windows 7 6.1 amd64

Comment by Gradle Forums [ 04/Oct/13 ]

Here is the jist of my build script (The line number will not match with above because this is actually a multiproject build with some of this in 'subprojects sections of the main build.gradle)

apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username snapshot_user
password snapshot_password
}
url nexus_snapshot_url
}
}
}

jar {
into("META-INF/maven/$project.group/$project.name") {
from generatePomFileForMavenJavaPublication
rename ".*", "pom.xml"
}
}

dependencies {
testCompile "junit:junit:4.0"
}

Comment by Gradle Forums [ 04/Oct/13 ]

Have you verified that you can run `gradle generatePomFileForMavenJavaPublication`?

Comment by Gradle Forums [ 04/Oct/13 ]

Yes, and it generates the pom I would expect. I did notice this in the documentation:

>The “maven-publish” plugin leverages some experimental support for late plugin configuration, and any GenerateMavenPom tasks will not be constructed until the publishing extension is configured. The simplest way to ensure that the publishing plugin is configured when you attempt to access the GenerateMavenPom task is to place the access inside a publishing block, as the above example demonstrates.

Do I have to wrap this jar part in a publishing block? Would that even work?

Comment by Gradle Forums [ 04/Oct/13 ]

I guess it would.

Comment by Gradle Forums [ 04/Oct/13 ]

I tried wrapping the jar part in a publishing block, did not help, same error.

Comment by Thad Humphries [ 22/May/14 ]

Is there a work-around that can add "build/publications/mavenJav/pom-default.xml" to "META-INF/maven/$project.group/$project.name" as pom.xml? What about the pom.properties file?

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 24/Jan/17 ]

Judging from the comments the user found a "workaround" for the issue.

Comment by Alexei Osipov [ 31/Jan/17 ]

It doesn't look like there any workaround in comments for this issue.
This issue is still actual. Well, at least for my project.

Comment by Benjamin Muschko [ 01/Feb/17 ]

Further discussion here: https://github.com/gradle/gradle/issues/1278

Generated at Wed Jun 30 12:34:55 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.