[GRADLE-1287] Problems post-processing Maven POM with XmlProvider Created: 04/Jan/11  Updated: 10/Feb/17  Resolved: 10/Feb/17

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

Type: Bug
Reporter: Peter Niederwieser Assignee: Unassigned
Resolution: Won't Fix Votes: 0


 Description   

I'm trying to post-process the Maven POM with XmlProvider like so (in an attempt to get around GRADLE-1285):

install.repositories.mavenInstaller.pom.withXml { xmlProvider ->
  // do something here
}

However, I'm running into the following problems:

1. As soon as I call xmlProvider.asNode() (without even doing anything with it), gradle install gives the following exception:

Execution failed for task ':install'.
	at org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:66)
	at org.gradle.api.internal.tasks.DefaultTaskExecuter.execute(DefaultTaskExecuter.java:43)
	at org.gradle.api.internal.project.taskfactory.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:32)
	at org.gradle.api.internal.project.taskfactory.ExecutionShortCircuitTaskExecuter.execute(ExecutionShortCircuitTaskExecuter.java:50)
	at org.gradle.api.internal.tasks.SkipTaskExecuter.doExecute(SkipTaskExecuter.java:57)
	at org.gradle.api.internal.tasks.SkipTaskExecuter.execute(SkipTaskExecuter.java:35)
	at org.gradle.api.internal.tasks.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:32)
	at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:231)
	at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
	at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
	at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
	at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
	at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:153)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:107)
	at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:75)
	at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
	at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
	at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:209)
	at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:193)
	at org.gradle.launcher.Main.execute(Main.java:55)
	at org.gradle.launcher.Main.main(Main.java:40)
	at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
	at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
	at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: org.gradle.api.GradleException: Could not publish configurations [configuration ':archives'].
	at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService.publish(ErrorHandlingIvyService.java:44)
	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.publish(DefaultConfiguration.java:211)
	at org.gradle.api.tasks.Upload.upload(Upload.java:56)
	at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
	at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
	at org.gradle.api.tasks.Upload_Decorated.invokeMethod(Unknown Source)
	at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:131)
	at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:130)
	at org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:58)
	... 24 more
Caused by: Unable to initialize POM pom-default.xml: Not a v4.0.0 POM. for project unknown at /swd/prj/spock/build/poms/pom-default.xml
	at org.apache.maven.artifact.ant.Pom.initialiseMavenProject(Pom.java:213)
	at org.apache.maven.artifact.ant.AbstractArtifactTask.initializePom(AbstractArtifactTask.java:526)
	at org.apache.maven.artifact.ant.InstallDeployTaskSupport.initializePom(InstallDeployTaskSupport.java:59)
	at org.apache.maven.artifact.ant.InstallTask.doExecute(InstallTask.java:50)
	at org.gradle.api.internal.artifacts.publish.maven.deploy.CustomInstallTask.doExecute(CustomInstallTask.java:33)
	at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:718)
	at org.gradle.api.internal.artifacts.publish.maven.deploy.AbstractMavenResolver.execute(AbstractMavenResolver.java:189)
	at org.gradle.api.internal.artifacts.publish.maven.deploy.AbstractMavenResolver.commitPublishTransaction(AbstractMavenResolver.java:180)
	at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:262)
	at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher.publish(DefaultIvyDependencyPublisher.java:54)
	at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyService.publish(DefaultIvyService.java:144)
	at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsIvyService.publish(ShortcircuitEmptyConfigsIvyService.java:61)
	at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingIvyService.publish(ErrorHandlingIvyService.java:42)
	... 33 more
Caused by: org.apache.maven.project.InvalidProjectModelException: Not a v4.0.0 POM. for project unknown at /swd/prj/spock/build/poms/pom-default.xml
	at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1599)
	at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1571)
	at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
	at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
	at org.apache.maven.artifact.ant.Pom.initialiseMavenProject(Pom.java:207)
	... 45 more

Next I tried to manipulate the POM with xmlProvider.asElement(), but:

2. The DOM returned by asElement() is almost empty. In particular, it doesn't contain the parts I've added with the project {} builder.

3. None of the changes I make show up in the generated POM.



 Comments   
Comment by Peter Niederwieser [ 05/Jan/11 ]

Should be: 2. [..] In particular, it doesn't contain the parts I've added with the pom {} builder.

Comment by Peter Niederwieser [ 05/Jan/11 ]

I've now tried Adam's solution as described in http://www.mail-archive.com/user@gradle.codehaus.org/msg05389.html, but the pom {} builder seems to overwrite my changes.

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 [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 11:51:43 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.