Hmm, that seems to be the problem, but I can't seem to figure out a way around 
this. What I'm trying to do is extend the Jar/Zip tasks in Gradle to copy the 
contents of Jar/Zip files using JarInputStream/JarOutputStreams instead of 
decompressing the files to a temporary directory copying them and then 
decompressing. I am doing this by overriding the 'createCopyAction' method to 
return a custom class that implements CopyAction. However, I cannot use the 
protected methods in the class else I run into the cast exceptions below. 

Is there a better way that I could do this or am I just going to be limited at 
this point? 

-- John


On Monday, April 28, 2014 at 6:14 PM, John Engelman wrote:

> As I was getting this stack trace, it occurred to me what is probably 
> happening. I think I was inadvertently using a class from org.gradle.internal 
> and that's where the error is coming from: 
> 
> Caused by: java.lang.ClassCastException: org.apache.tools.zip.ZipOutputStream 
> cannot be cast to org.apache.tools.zip.ZipOutputStream
> at 
> com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction$1.execute(ShadowCopyAction.groovy)
> at org.gradle.internal.IoActions.withResource(IoActions.java:74)
> at org.gradle.internal.IoActions$withResource.call(Unknown Source)
> at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
> at 
> com.github.jengelman.gradle.plugins.shadow.tasks.ShadowCopyAction.execute(ShadowCopyAction.groovy:49)
> at 
> org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)
> at 
> org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
> at 
> org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
> at org.gradle.api.tasks.AbstractCopyTask.copy(AbstractCopyTask.java:65)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
> at 
> org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
> at 
> org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
> at 
> org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
> at 
> org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
> at 
> org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
> at 
> org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
> at 
> org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
> ... 47 more
> 
> 
> -- John
> 
> 
> On Monday, April 28, 2014 at 5:51 PM, Adam Murdoch [via Gradle] wrote:
> 
> > 
> > On 29 Apr 2014, at 12:40 am, John Engelman <[hidden email] 
> > (/user/SendEmail.jtp?type=node&node=5712626&i=0)> wrote:
> > > Hey everyone - 
> > > I'm trying to write a plugin that uses the Apache ZipOutputStream class 
> > > in it and I can't seem to get it to work. The class appears to be 
> > > available via 'gradleApi()', but when I publish the plugin and install it 
> > > to a project, I end up with a 
> > > NoClassDefFoundException for ZipOutputStream.
> > > Then I explicitly added the org.apache.ant:ant dependency to the plugin 
> > > and republished and now I get a ClassCastException:
> > > 
> > > Caused by: java.lang.ClassCastException: 
> > > org.apache.tools.zip.ZipOutputStream cannot be cast to 
> > > org.apache.tools.zip.ZipOutputStream.
> > 
> > Have you got a stack trace for this failure?
> > 
> > --
> > Adam Murdoch
> > Gradle Co-founder
> > http://www.gradle.org
> > VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
> > http://www.gradleware.com
> > 
> > Join us for Gradle Summit 2014, June 12th and 13th in Santa Clara, CA: 
> > http://www.gradlesummit.com 
> > 
> > 
> > If you reply to this email, your message will be added to the discussion 
> > below: 
> > http://gradle.1045684.n5.nabble.com/Dealing-with-ClassLoader-issues-in-Gradle-Plugins-tp5712621p5712626.html
> >  
> > To start a new topic under gradle-dev, email 
> > ml-node+s1045684n1436218...@n5.nabble.com 
> > (mailto:ml-node+s1045684n1436218...@n5.nabble.com) 
> > To unsubscribe from gradle-dev, click here 
> > (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1436218&code=am9obi5yLmVuZ2VsbWFuQGdtYWlsLmNvbXwxNDM2MjE4fDIyMTUyNjEzNQ==).
> > NAML 
> > (http://gradle.1045684.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)
> >  
> 





--
View this message in context: 
http://gradle.1045684.n5.nabble.com/Dealing-with-ClassLoader-issues-in-Gradle-Plugins-tp5712621p5712628.html
Sent from the gradle-dev mailing list archive at Nabble.com.

Reply via email to