[GRADLE-1497] "gradle install" fails with ClassCastError Created: 27/Apr/11 Updated: 04/Jan/13 Resolved: 28/Apr/11 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0-milestone-3 |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Luke Taylor | Assignee: | Peter Niederwieser |
Resolution: | Not A Bug | Votes: | 0 |
Attachments: | stacktrace.txt |
Description |
When running the Spring Security build with a "gradle install" command, I get Caused by: java.lang.ClassCastException: (full stacktrace attached). |
Comments |
Comment by Luke Taylor [ 27/Apr/11 ] |
I've worked out that this is related to the explicit creation of a org.apache.maven.model.Dependency instance (for commons-logging) within our build file (gradle/maven-deployment.gradle). If the relevant code is commented out then the install (or uploadArchives) command succeeds. |
Comment by Luke Taylor [ 27/Apr/11 ] |
As a workaround, I can read the Class of pom.dependencies[0] and call newInstance() to make sure I'm using the same classloader. |
Comment by Peter Niederwieser [ 28/Apr/11 ] |
Creating an org.apache.maven.model.Dependency and passing it to the maven installer/deployer no longer works because all Maven-related code now gets loaded by a separate class loader. (Actually I wonder why you don't get a NoClassDefFoundError.) But you should still be able to add dependencies with the POM builder, without referencing any Maven classes: http://gradle.org/latest/docs/userguide/userguide_single.html#pomBuilder |
Comment by Luke Taylor [ 28/Apr/11 ] |
Thanks Peter. That appears to work and seems like a cleaner solution. |