After upgrade gradle to 2.0 version, the maven pom not support build property

after upgrade gradle to 2.0 version, looks like the build property is not supported in maven pom modifying, it will report error: No such property: SCRIPT_CLASS_NAME for class: org.apache.maven.model.Model

the code would like this: def customizePom(pom, gradleProject) {

pom.project {

build {…}

} }

anyone can help?

I’m also facing this issue, the pom task seems to be broken due to it.

Here is the exact stacktrace: ‘’’ Caused by: groovy.lang.MissingPropertyException: No such property: _SCRIPT_CLASS NAME for class: org.apache.maven.model.Model

at hibernate_enhance_maven_plugin_3l2b5148946n5lldtu1d8ivrke$_run_closur e5_closure12_closure14.doCall(C:\hibernate-orm\tooling\hibernate-enhance-maven-plugin\hibernate-enhance-mave n-plugin.gradle:82)

at hibernate_enhance_maven_plugin_3l2b5148946n5lldtu1d8ivrke$_run_closur e5_closure12_closure14.doCall(C:\hibernate-orm\tooling\hibernate-enhance-maven-plugin\hibernate-enhance-mave n-plugin.gradle)

at org.gradle.api.publication.maven.internal.DefaultMavenPom.project(Def aultMavenPom.java:131)

at org.gradle.api.publication.maven.internal.DefaultMavenPom.project(Def aultMavenPom.java:42)

at hibernate_enhance_maven_plugin_3l2b5148946n5lldtu1d8ivrke$_run_closur e5_closure12.doCall(C:\hiber nate-orm\tooling\hibernate-enhance-maven-plugin\hibernate-enhance-maven-plugin.g radle:78)

at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedActi on.java:59)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:91)

at org.gradle.api.plugins.MavenPluginConvention.pom(MavenPluginConventio n.java:103)

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMeth od(BeanDynamicObject.java:225)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObj ect.java:129)

at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicOb ject.invokeMethod(DefaultConvention.java:212)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(Composite DynamicObject.java:147)

at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java: 79)

at hibernate_enhance_maven_plugin_3l2b5148946n5lldtu1d8ivrke$_run_closur e5.doCall(C:\hibernate-orm\t ooling\hibernate-enhance-maven-plugin\hibernate-enhance-maven-plugin.gradle:71)

at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedActi on.java:59)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:130)

at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:110)

at org.gradle.api.internal.AbstractTask.configure(AbstractTask.java:473)

at org.gradle.api.internal.project.AbstractProject.task(AbstractProject. java:840)

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMeth od(BeanDynamicObject.java:225)

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObj ect.java:129)

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(Composite DynamicObject.java:147)

at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java: 79)

at hibernate_enhance_maven_plugin_3l2b5148946n5lldtu1d8ivrke.run(C:\hibernate-orm\tooling\hibernate- enhance-maven-plugin\hibernate-enhance-maven-plugin.gradle:70)

at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptR unnerImpl.run(DefaultScriptRunnerFactory.java:52)

… 34 more ‘’’

Apparently the problem occurs no matter what has been put into the build property even as simple definition as fallows will fail:

‘’’ task writeNewPom << {

pom {

project {

build {

}

}

}.writeTo("$buildDir/newpom.xml") } processResources.dependsOn writeNewPom ‘’’

Edit:

After a bit of debuging, the problem occurs due to the fact that declaring the build {} closure in the build script causes that the actual #build(Script) method that is defined in FactoryBuilderSupport is being invoked, instead of being handled by the invokeMethod and createNodes. Suprisingly this behaviour does not occur in Gradle 1.9 and Groovy 1.8.6.

Compare stack traces: for invocation on “project”: ‘’’ at groovy.util.FactoryBuilderSupport.doInvokeMethod(FactoryBuilderSupport.java:779)

at groovy.util.FactoryBuilderSupport.invokeMethod(FactoryBuilderSupport.java:499)

at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:907)

at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:884)

at org.gradle.api.publication.maven.internal.DefaultMavenPom.project(DefaultMavenPom.java:131)

at org.gradle.api.publication.maven.internal.DefaultMavenPom.project(DefaultMavenPom.java:42)

at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:601)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) ‘’’

and for invocation for “build” ‘’’ at groovy.util.FactoryBuilderSupport.build(FactoryBuilderSupport.java:1163)

at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1) ‘’’

I’ve created a related Groovy issue hopping to find solution for this: http://jira.codehaus.org/browse/GROOVY-7023

Any workaround for this?

As far as I know there is none.

One workaround is to customize the POM on the XML level (‘pom.withXml {}’). (With the new ‘maven-publish’ plugin, this is the only way to customize the POM.) The samples in the gradle-all distribution should have an example, and probably also the Gradle User Guide.

Peter, and what if we are customizing the POM on the XML level and still get this error? The build runs fine from command line. The problem is actually in trying to refresh this project in IntelliJ after upgrading gradlew from 1.9 to 2.2.