Gradle
  1. Gradle
  2. GRADLE-1114

Cannot upload: POM does not validate

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Resolution: Unresolved
    • Affects Version/s: 0.9
    • Fix Version/s: None

      Description

      I've got a pretty straightforward upload process, but it won't upload because the POM apparently won't validate. However, it seems valid to me, and it's generated pretty directly. I've attached the POM and the relevant files from the build directory.

      FAILURE: Build failed with an exception.

      • Where:
        Build file '/Users/robert/wkdir/ashlar/runtime/build.gradle'
      • What went wrong:
        Execution failed for task ':runtime:uploadArchives'.
        Cause: Could not publish configurations [configuration ':runtime:archives'].
      • Try:
        Run with -S option to get the full (very verbose) stacktrace.
      • Exception is:
        org.gradle.api.tasks.LocationAwareTaskExecutionException: Build file '/Users/robert/wkdir/ashlar/runtime/build.gradle'
        Execution failed for task ':runtime:uploadArchives'.
        at org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:63)
        at org.gradle.api.internal.tasks.DefaultTaskExecuter.execute(DefaultTaskExecuter.java:41)
        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:161)
        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.Main.execute(Main.java:93)
        at org.gradle.launcher.Main.main(Main.java:42)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:49)
        Caused by: org.gradle.api.GradleException: Could not publish configurations [configuration ':runtime: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:57)
        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:129)
        at org.gradle.api.internal.tasks.DefaultTaskExecuter.executeActions(DefaultTaskExecuter.java:55)
        ... 18 common frames omitted
        Caused by: org.apache.tools.ant.BuildException: Unable to initialize POM pom-default.xml: Failed to validate POM for project ashlar:ashlar-runtime at /Users/robert/wkdir/ashlar/runtime/build/poms/pom-default.xml
        at org.apache.maven.artifact.ant.Pom.initialiseMavenProject(Pom.java:211)
        at org.apache.maven.artifact.ant.AbstractArtifactTask.initializePom(AbstractArtifactTask.java:528)
        at org.apache.maven.artifact.ant.InstallDeployTaskSupport.initializePom(InstallDeployTaskSupport.java:60)
        at org.apache.maven.artifact.ant.DeployTask.doExecute(DeployTask.java:100)
        at org.gradle.api.internal.artifacts.publish.maven.deploy.CustomDeployTask.doExecute(CustomDeployTask.java:42)
        at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:721)
        at org.gradle.api.internal.artifacts.publish.maven.deploy.AbstractMavenResolver.execute(AbstractMavenResolver.java:185)
        at org.gradle.api.internal.artifacts.publish.maven.deploy.AbstractMavenResolver.commitPublishTransaction(AbstractMavenResolver.java:176)
        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)
        ... 27 common frames omitted
        Caused by: org.apache.maven.project.InvalidProjectModelException: Failed to validate POM for project ashlar:ashlar-runtime at /Users/robert/wkdir/ashlar/runtime/build/poms/pom-default.xml
        at org.apache.maven.project.DefaultMavenProjectBuilder.processProjectLogic(DefaultMavenProjectBuilder.java:1077)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:880)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508)
        at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
        at org.apache.maven.artifact.ant.Pom.initialiseMavenProject(Pom.java:207)
        ... 39 common frames omitted
      1. blaines_simplest_build.gradle
        1 kB
        Blaine Simpson
      2. blaines_with_workarounds_build.gradle
        6 kB
        Blaine Simpson
      3. build.gradle
        2 kB
        Robert Fischer
      4. pom-default.xml
        2 kB
        Robert Fischer

        Activity

        Hide
        Hans Dockter
        added a comment -

        The upload works for me if I use: repository(url: "file://localhost/tmp/robertRepo/") as a repository. Could you try this on your machine? One other thing I need to do differently was to use: compile files("/Users/hans/Downloads/cojen-2.2.1.jar", "/Users/hans/Downloads/trove-2.1.0a2/lib/trove-2.1.0a2.jar"), as they were not available from the defined repos.

        For some reason I can't get a local ssh upload working to check if wagon-ssh is the culprit.

        Show
        Hans Dockter
        added a comment - The upload works for me if I use: repository(url: "file://localhost/tmp/robertRepo/") as a repository. Could you try this on your machine? One other thing I need to do differently was to use: compile files("/Users/hans/Downloads/cojen-2.2.1.jar", "/Users/hans/Downloads/trove-2.1.0a2/lib/trove-2.1.0a2.jar") , as they were not available from the defined repos. For some reason I can't get a local ssh upload working to check if wagon-ssh is the culprit.
        Hide
        lucas gray
        added a comment -

        I'm having the same issues, and I've narrowed it down to this: trying to deploy (ftp for me) to my local repository fails in this fashion when my project has dependencies that exist in the repository I'm publishing to. Unsure if the problem is simply because they're not in central, or if the problem is because of the 'circular-ness' of publishing to a repo that the dependencies come from.

        Show
        lucas gray
        added a comment - I'm having the same issues, and I've narrowed it down to this: trying to deploy (ftp for me) to my local repository fails in this fashion when my project has dependencies that exist in the repository I'm publishing to. Unsure if the problem is simply because they're not in central, or if the problem is because of the 'circular-ness' of publishing to a repo that the dependencies come from.
        Hide
        Blaine Simpson
        added a comment - - edited

        I am having this problem, and it persists after narrowing the test case drastically and eliminating the issues mentioned by Hans and Lucas about dependency availability and remote transfer protocols. My test case is a simple, non-nested project using only the Java and Maven plugins, attempting to publish to a local file repository, and it works perfectly well other than the Maven plugin features.

        I don't know of a more simple way to try to do what the Maven Plugin chapter of the user guide says to do, and it totally is not working.

        Attachment descriptions:

        • blaines_simplest_build.gradle: Stripped-down use case exhibiting uploadArchives abortion with "Failed to validate POM..."
        • blaines_with_workarounds_build.gradle: Same but with several attempted work-arounds including references to sources of work-arounds.

        Update: Seems that a cache (I think the $HOME/.gradle one) was retaining some bad configs from an earlier attempt, because after wiping $HOME/.gradle and the project cache, uploadArchives is now working for me.

        _

        Show
        Blaine Simpson
        added a comment - - edited I am having this problem, and it persists after narrowing the test case drastically and eliminating the issues mentioned by Hans and Lucas about dependency availability and remote transfer protocols. My test case is a simple, non-nested project using only the Java and Maven plugins, attempting to publish to a local file repository, and it works perfectly well other than the Maven plugin features. I don't know of a more simple way to try to do what the Maven Plugin chapter of the user guide says to do, and it totally is not working. Attachment descriptions: blaines_simplest_build.gradle: Stripped-down use case exhibiting uploadArchives abortion with "Failed to validate POM..." blaines_with_workarounds_build.gradle: Same but with several attempted work-arounds including references to sources of work-arounds. Update: Seems that a cache (I think the $HOME/.gradle one) was retaining some bad configs from an earlier attempt, because after wiping $HOME/.gradle and the project cache, uploadArchives is now working for me. _
        Hide
        Stanford S. Guillory
        added a comment -

        I am experiencing the exact same symptoms when trying do deploy my artifacts to a Sonatype Nexus instance. Are there any plans to work on this defect in the near future? Thx

        Show
        Stanford S. Guillory
        added a comment - I am experiencing the exact same symptoms when trying do deploy my artifacts to a Sonatype Nexus instance. Are there any plans to work on this defect in the near future? Thx
        Hide
        Nick Spor
        added a comment -

        Hi, if you have any dependencies like this: testRuntime group: 'junit', name: 'junit', version: '4.8' ive found that it will throw this error, after removing these dependencies from the task that was calling uploadArchives the pom validated and the war/pom would upload successfully.

        Show
        Nick Spor
        added a comment - Hi, if you have any dependencies like this: testRuntime group: 'junit', name: 'junit', version: '4.8' ive found that it will throw this error, after removing these dependencies from the task that was calling uploadArchives the pom validated and the war/pom would upload successfully.
        Hide
        Erich Oswald
        added a comment -

        I got the same error when I tried to publish a project that included a dependency to a JAR file in a flatDir repository. In the generated POM the groupId and version for that dependency were missing (well, can hardly blame Gradle for that ). When I moved the dependency to our local Maven proxy, publishing worked.

        Wouldn't it make sense if Gradle either ignored such incomplete dependencies when generating the pom-default.xml or at least gave a warning that it had to generate incomplete dependencies and the upload might fail?

        Show
        Erich Oswald
        added a comment - I got the same error when I tried to publish a project that included a dependency to a JAR file in a flatDir repository. In the generated POM the groupId and version for that dependency were missing (well, can hardly blame Gradle for that ). When I moved the dependency to our local Maven proxy, publishing worked. Wouldn't it make sense if Gradle either ignored such incomplete dependencies when generating the pom-default.xml or at least gave a warning that it had to generate incomplete dependencies and the upload might fail?
        Hide
        Andreas Tschabuschnig
        added a comment -

        Still affected in 1.7 using plugin "maven-publish". Task "generatePomFileForMavenJarPublication" will create pom-default.xml without version information for external dependencies, whenever a dependencies version is set dynamically. Below code illustrates how I (used to) set the version for dependencies. The problem solved itself once I made sure each dependency is added including the version information.

        allprojects {
            configurations.all {
                resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                   if (!details.requested.version) {
                        def defaultVersion = getVersionFor(details)
                        if (!defaultVersion) {
                            if (details.requested.group.startsWith('com.mycompany')) {
                                defaultVersion = project.version
                            }
                            else {
                                throw new NullPointerException("no version defined for " + details.requested)
                            }
                        }
                        logger.debug ("Using version '${defaultVersion}' for ${details.requested}")
                        details.useVersion(defaultVersion)
                    }
                }
            }
        }
        
        Show
        Andreas Tschabuschnig
        added a comment - Still affected in 1.7 using plugin "maven-publish". Task "generatePomFileForMavenJarPublication" will create pom-default.xml without version information for external dependencies, whenever a dependencies version is set dynamically. Below code illustrates how I (used to) set the version for dependencies. The problem solved itself once I made sure each dependency is added including the version information. allprojects { configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> if (!details.requested.version) { def defaultVersion = getVersionFor(details) if (!defaultVersion) { if (details.requested.group.startsWith('com.mycompany')) { defaultVersion = project.version } else { throw new NullPointerException( "no version defined for " + details.requested) } } logger.debug ( "Using version '${defaultVersion}' for ${details.requested}" ) details.useVersion(defaultVersion) } } } }

          People

          • Assignee:
            Unassigned
            Reporter:
            Robert Fischer
          • Votes:
            13 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

            • Created:
              Updated: