[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: Text File stacktrace.txt    

 Description   

When running the Spring Security build with a "gradle install" command, I get

Caused by: java.lang.ClassCastException:
org.apache.maven.model.Dependency cannot be cast to
org.apache.maven.model.Dependency

(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
Let me know if this works out for you.

Comment by Luke Taylor [ 28/Apr/11 ]

Thanks Peter. That appears to work and seems like a cleaner solution.

Generated at Wed Jun 30 11:57:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.