Error parsing poms in 1.0-m7 on changing dependencies


(Benn Sundsrud) #1

My buildscript has a dependency on an internal plugin that is coming out of a maven repo, and I’m currently testing against our snapshot version. This problem has appeared in milestone 7, it does not occur under milestone 6.

buildscript {
 configurations.all {
  resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
 }
 repositories {
                // Internal maven repo
  maven { url "http://build.mycompany.com/artifactory/repo" }
 }
 dependencies {
  classpath group: 'com.mycompany', name: 'MyGradlePlugin', version: '1.0-SNAPSHOT', changing: true
 }
}

If the plugin does not exist in %GRADLE_HOME%/caches/artifacts-7, it downloads and uses it correctly. If there is already a version in the cache but there is a newer snapshot in the repo, I get the following exception:

[Fatal Error] MyGradlePlugin-1.0-20120105.200842-5.pom:1:44: Content is not allowed in prolog.
org.xml.sax.SAXParseException: Content is not allowed in prolog.
 at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:249)
 at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
 at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:153)
 at org.apache.ivy.util.XMLHelper.parseToDom(XMLHelper.java:196)
 at org.apache.ivy.plugins.parser.m2.PomReader.<init>(PomReader.java:95)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser.parseDescriptor(GradlePomModuleDescriptorParser.java:105)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DownloadingRepositoryCacheManager.parseModuleDescriptor(DownloadingRepositoryCacheManager.java:170)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DownloadingRepositoryCacheManager.cacheModuleDescriptor(DownloadingRepositoryCacheManager.java:146)
 at org.apache.ivy.plugins.resolver.BasicResolver.parse(BasicResolver.java:546)
 at org.apache.ivy.plugins.resolver.BasicResolver.getDependency(BasicResolver.java:266)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyResolverAdapter$1.create(DependencyResolverAdapter.java:77)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyResolverAdapter$1.create(DependencyResolverAdapter.java:74)
 at org.gradle.cache.internal.DefaultCacheAccess.longRunningOperation(DefaultCacheAccess.java:172)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.longRunningOperation(DefaultPersistentDirectoryStore.java:107)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.longRunningOperation(DefaultCacheLockingManager.java:57)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.DependencyResolverAdapter.getDependency(DependencyResolverAdapter.java:74)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain$ModuleResolution.resolveModule(UserResolverChain.java:271)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain$ModuleResolution.findModule(UserResolverChain.java:208)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.findLatestModule(UserResolverChain.java:97)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain.getDependency(UserResolverChain.java:73)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.IvyResolverBackedDependencyToModuleResolver$DefaultModuleVersionResolver.getDescriptor(IvyResolverBackedDependencyToModuleResolver.java:83)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ModuleVersionSelectorResolveState.resolve(DependencyGraphBuilder.java:870)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DefaultModuleRevisionResolveState.getDescriptor(DependencyGraphBuilder.java:606)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(DependencyGraphBuilder.java:309)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(DependencyGraphBuilder.java:285)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:119)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:55)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:68)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:36)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.create(CacheLockingArtifactDependencyResolver.java:34)
 at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:126)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:99)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:49)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:34)
 at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:42)
 at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDependencyResolver.java:78)
 at org.gradle.api.internal.artifacts.ivyservice.EventBroadcastingArtifactDependencyResolver.resolve(EventBroadcastingArtifactDependencyResolver.java:37)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:36)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:234)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:493)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getFiles(DefaultConfiguration.java:204)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getFiles(Unknown Source)
 at org.gradle.api.internal.initialization.DefaultScriptHandler.updateClassPath(DefaultScriptHandler.java:36)
 at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:118)
 at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
 at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:475)
 at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:74)
 at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
 at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
 at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38)
 at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:35)
 at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:451)
 at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:446)
 at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
 at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:137)
 at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
 at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:76)
 at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
 at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
 at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
 at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:238)
 at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:222)
 at org.gradle.launcher.Main.doAction(Main.java:48)
 at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
 at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
 at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
 at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
 at org.gradle.launcher.Main.main(Main.java:39)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
 at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
 at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
  FAILURE: Build failed with an exception.
  * What went wrong:
Could not resolve group:com.mycompany, module:MyGradlePlugin, version:1.0-SNAPSHOT.
Required by:
    :trunk:unspecified
Cause: java.text.ParseException: Content is not allowed in prolog.

I’m building this on windows 7, so I’m somewhat suspicious of a line ending problem. The pom in question is generated by gradle and looks fine, starting with

<?xml version="1.0" encoding="UTF-8"?>
<project ...>

The error mentions line 1 char 44, which is well past the end of the first line (it’s 38 chars long). Looking at the pom with a hex editor shows that the line endings are CR LF.

Did anything change between m6 and m7 for maven repo resolution? This problem seems to be related to http://forums.gradle.org/gradle/topics/cache_problem_in_m5_when_running_in_teamcity_pom_file_download_corruption, since it’s the same error and they both seem to be ivy-related.


#2

Lots of things have changed in dependency resolution between m6 and m7. Check out the release notes if you want to know more.

My suspicion is that the snapshot file is locked prior to dependency resolution: this doesn’t happen with normal dependency jars, but may be an issue with plugin dependencies. Once the cached jar is in use, we can’t download the new snapshot to replace it.

If this is the issue, it’s probably been fixed in a recent nightly build. We are now storing all cached artifacts based on their SHA1 checksum, so if your plugin jar has changed, we don’t need to overwrite the existing jar in order to download it.

Would you be able to try out a nightly release?: http://gradle.org/nightly Naturally there may be other things broken (that aren’t covered by our automated test suite), but in general the nightlies are pretty solid.


(Benn Sundsrud) #3

Thanks, this is indeed fixed in the nightlies.


#4

Excellent. Thanks for letting us know.