Hi Alex,

I don’t have a full solution for you, just a clue.  I had a similar confusing 
error using an in-house Gradle plugin with a multi-project build, under Gradle 
1.4.  The underlying cause was that, if a plugin is applied in multiple 
subprojects but not in their parent project (usually the root project) Gradle 
seems to load the plugins for each project into a separate classloader.  That 
gives you class cast exceptions when the plugin instance on one project tries 
to use objects from the plugin on another project.  The “fix” was to apply the 
plugin in the root project as well, even though it wasn’t used there.

I think we also had a similar problem using plugin objects within the build 
script: we were declaring variables using the explicit type we expected, 
instead of just “def”; but the type in the script was from a different 
classloader than the object we were handling.  In that case, I think it was a 
sufficient workaround, to just change the declaration to use “def”.

If the above doesn’t help, I wonder if your problem is not that you have >1 
buildscript dependency, but that you have that JFrog plugin at all.  Does the 
error still happen if you don’t have the protobuf plugin?  And if you have 
protobuf but not build-info-extractor?

In any case, it would be good to re-run with -s or -S to see where the class 
cast exception is happening.  If it’s inside the JFrog plugin, maybe it needs a 
code change.  Or maybe there’s some other way to write your multi-project build 
so you don’t effectively pass things between projects.

Hope that helps,

Hugh Greene, Senior Software Developer
Toshiba Medical Visualization Systems Europe, Ltd
Bonnington Bond, 2 Anderson Place, Edinburgh EH6 5NP, UK
Tel + 44 (0)131 472 4792 / Fax + 44 (0) 131 472 4799
http://www.tmvse.com / mailto:[email protected]

DISCLAIMER
Unless indicated otherwise, the information contained in this message is 
privileged and confidential, and is intended only for the use of the 
addressee(s) named above and others who have been specifically authorized to 
receive it. If you are not the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this message and/or attachments 
is strictly prohibited. The company accepts no liability for any damage caused 
by any virus transmitted by this email. Furthermore, the company does not 
warrant a proper and complete transmission of this information, nor does it 
accept liability for any delays. If you have received this message in error, 
please contact the sender and delete the message.

From: Alex Silva [mailto:[email protected]]
Sent: 15 October 2015 09:02
To: [email protected]
Subject: [Artifactory-users] Gradle plugin and multi projects


Hi all,

I am using the Gradle plugin for publishing artifacts to Artifactory. I also 
have a multi-project build with Gradle. All the subprojects apply the plugin in 
their build.gradle files.

I have seen a strange problem in this configuration. Whenever a subproject 
declares more than one classpath dependency as in the following example:

buildscript {

  repositories {

    maven {

      url "https://plugins.gradle.org/m2/";

    }

  }



  dependencies {

    classpath "com.google.protobuf:protobuf-gradle-plugin:0.7.0"

    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"

  }

}



apply plugin: "java"

apply plugin: "maven-publish"

apply plugin: "com.google.protobuf"

apply plugin: "com.jfrog.artifactory"

Then Gradle fails to configure the root project with the error:

Cannot cast object 
'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention@6dded900' 
with class 
'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention' to class 
'org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention'

It succeeds to configure a single individual project, though. It also succeeds 
if I remove the Artifactory plugin classpath from these projects that declare 
more than one classpath, but I actually need this plugin in all subprojects.

Thanks,
​
--
Qnective

Alex Silva
Software Engineer

Thurgauerstrasse 54 | 8050 Zürich | Switzerland
http://www.qnective.com/ | 
[email protected]<mailto:[email protected]>

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
------------------------------------------------------------------------------
_______________________________________________
Artifactory-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/artifactory-users

Reply via email to