[GRADLE-3204] After upgrade gradle to 2.0 version, the maven pom not support build property Created: 24/Nov/14  Updated: 10/Feb/17  Resolved: 10/Feb/17

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

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


 Description   

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?



 Comments   
Comment by Gradle Forums [ 24/Nov/14 ]

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
```

Comment by Gradle Forums [ 24/Nov/14 ]

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: [1]http://jira.codehaus.org/browse/GROOV...
----------------------------------------------------------------------------------------
[1] http://jira.codehaus.org/browse/GROOVY-7023

Comment by Gradle Forums [ 24/Nov/14 ]

Any workaround for this?

Comment by Gradle Forums [ 24/Nov/14 ]

As far as I know there is none.

Comment by Gradle Forums [ 24/Nov/14 ]

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]([1]http://gradle.org/docs/current/usergu...).
----------------------------------------------------------------------------------------
[1] http://gradle.org/docs/current/userguide/userguide_single.html

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 12:42:43 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.