Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.GroovyCastException Exception when using GrettyStartTask #18

Closed
rainoko opened this issue May 15, 2014 · 4 comments
Closed

.GroovyCastException Exception when using GrettyStartTask #18

rainoko opened this issue May 15, 2014 · 4 comments
Assignees

Comments

@rainoko
Copy link

rainoko commented May 15, 2014

Relevant gradle parts

...
import org.akhikhl.gretty.*

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.akhikhl.gretty:gretty7-plugin:0.0.17'
}
}

apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty7-0.0.17.plugin'
....
task ('jettyRunForIntegrationTest', type: GrettyStartTask) {
integrationTest = true
}

Result

Exception in thread "Thread-3" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.akhikhl.gretty7.ScannerManager@45b109c6' with class 'org.akhikhl.gretty7.ScannerManager' to class 'org.akhikhl.gretty.ScannerManagerBase'
at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:599)
at org.akhikhl.gretty.GrettyStartTask.runJetty(GrettyStartTask.groovy:199)

@akhikhl akhikhl self-assigned this May 15, 2014
@akhikhl
Copy link
Owner

akhikhl commented May 15, 2014

Issue is well-reproducible, I'll try to fix it.

@akhikhl
Copy link
Owner

akhikhl commented May 15, 2014

OK, here is the solution. Replace the line:

apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty7-0.0.17.plugin'

with:

apply plugin: 'gretty7'

and then error is gone.

Source of the problem seems to be the following: as soon as you include gretty-plugin twice (once in buildscript and again in "grettyX-0.0.X.plugin"), gradle gets confused and cannot load classes properly.

General recommendation:
If you use apply-from '... grettyX-0.0.X.plugin', then you don't need classpath for gretty in buildscript, since .plugin file already does it for you.
Of course, you are not obliged to use apply-from, you can do apply-plugin instead.
I'll update usage section in wiki on this.

@akhikhl akhikhl closed this as completed May 15, 2014
@rainoko
Copy link
Author

rainoko commented May 15, 2014

thanx for solution. but i needed to use classpath in buildscript because otherwise gradle didn't find the GrettyStartTask class at all.

@akhikhl
Copy link
Owner

akhikhl commented May 15, 2014

Ah, I understand. Yes, when you do "apply-from", importing the package does not work. I don't know why - it looks like deficiency/bug in gradle.

The complete working solution for you:

import org.akhikhl.gretty.*

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'org.akhikhl.gretty:gretty7-plugin:0.0.17'
  }
}

repositories {
  mavenCentral()
}

apply plugin: 'gretty7'

task ('jettyRunForIntegrationTest', type: GrettyStartTask) {
  integrationTest = true
}

akhikhl pushed a commit that referenced this issue Jul 31, 2016
henrik242 pushed a commit to henrik242/gretty that referenced this issue Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants