You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "luke w patterson (JIRA)" <ji...@codehaus.org> on 2010/12/21 12:59:57 UTC

[jira] Updated: (MINVOKER-112) duplicate script classpath entries are not filtered out, can cause ClassCastException

     [ http://jira.codehaus.org/browse/MINVOKER-112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

luke w patterson updated MINVOKER-112:
--------------------------------------

    Attachment: script-classpath-duplicates-fix.patch

(attaching fix patch)

Here's a small, clean patch to fix the issue.

It simply removes any class path entries that are duplicated.  Like I mentioned earlier, the logic could probably be smarter, and could try to merge the dependencies using GAV awareness, but this is a good start for now.  This patch fixes situations that would otherwise be clearly wrong (two of same jars on classpath).  I don't think it could cause any passivity issues later if the logic was made more robust.

> duplicate script classpath entries are not filtered out, can cause ClassCastException
> -------------------------------------------------------------------------------------
>
>                 Key: MINVOKER-112
>                 URL: http://jira.codehaus.org/browse/MINVOKER-112
>             Project: Maven 2.x Invoker Plugin
>          Issue Type: Bug
>            Reporter: luke w patterson
>         Attachments: script-classpath-duplicates-fix.patch, script-classpath-duplicates-it.patch
>
>
> (it test case attached)
> when addTestClassPath http://maven.apache.org/plugins/maven-invoker-plugin/run-mojo.html#addTestClassPath
> is set to "true" but the consuming project also depends on groovy or beanshell, scripts fail with ClassCastException,
> because the jars end up on the classpath twice
> error example:
> {noformat} 
> groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class Script1. Reason: java.lang.ClassCastException: Script1 cannot be cast to groovy.lang.GroovyObject
> 	at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:432)
> 	at groovy.lang.GroovyShell.parse(GroovyShell.java:584)
> 	at groovy.lang.GroovyShell.parse(GroovyShell.java:564)
> 	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:542)
> 	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:518)
> 	at org.apache.maven.plugin.invoker.GroovyScriptInterpreter.evaluateScript(GroovyScriptInterpreter.java:83)
> {noformat}
> I created a fix locally, but it's rough right now.  Will polish it up and submit later.  Basically, it adds 
> {code}
> /**
>  * @parameter expression="${plugin.artifacts}"
>  * @required
>  * @readonly
>  */
> private List pluginArtifacts;
> {code}
> to AbstractInvokerMojo, and then spins through the Artifacts, retrieving their file paths, and removes those from the list sent to "scriptRunner.setClassPath"
> Granted, the proposed fix could be smarter, cause it only filters out exact matches, but it's better than the current behavior.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira