Just to wrap this up: http://issues.gradle.org/browse/GRADLE-2863
Has been fixed in master (1.8) On 07/08/2013, at 4:59 PM, Xavier Ducrohet <x...@google.com> wrote: > Thanks for looking into this Luke. > All my variables were declared with types, but I did have a string operation > as an argument (str1 + str2). > > I've refactored my code into a non decorated class and it fixed it anyway, > but that's good to know in case some other part of our plugins fail > mysteriously. > > thanks! > > > On Wed, Aug 7, 2013 at 8:37 AM, Luke Daley <luke.da...@gradleware.com> wrote: > Hi Xav, > > I've been able to track down the exact problem. It's a confluence of Groovy > quirks/bugs and a mistake on our side. I'm still working through how we want > to fix it and will post the JIRA issue explaining the situation when I'm done. > > In the meantime, the workaround is to make sure all your arguments have the > correct runtime type when calling this method. That is, ensure all the > variables you are passing to downloadFile() are declared with types. Also if > you are passing Groovy Strings (e.g. "$foo bar") you have to call toString() > on it when passing. > > This workaround won't be necessary in 1.8. > > On 07/08/2013, at 4:28 PM, Xavier Ducrohet <x...@google.com> wrote: > > > Hey Luke, > > > > the method signature is > > > > private File downloadFile(String, String, String, File, boolean, > > boolean) throws IOException; > > > > > > > > > > On Wed, Aug 7, 2013 at 5:25 AM, Luke Daley <luke.da...@gradleware.com> > > wrote: > > > > On 07/08/2013, at 8:57 AM, Luke Daley <l...@ldaley.com> wrote: > > > > > > > > > > > On 07/08/2013, at 8:04, Luke Daley <l...@ldaley.com> wrote: > > > > > >> Are you able to share the exact code? > > >> > > >> I think I know what this is but need to see the code. > > > > > > Nevermind, I have enough. > > > > Actually… I do need to see the param types and values :) > > > > I've tracked the issue down, and it's very dependent on the types used. I > > want to make sure it's the same thing, and need this info to confirm. > > > > > > > >> On 07/08/2013, at 1:51, Xavier Ducrohet <x...@google.com> wrote: > > >> > > >>> I just encountered something very very strange in 1.7. > > >>> > > >>> I rarely run this code, but I ran it on 1.6 with no issue. I'm trying > > >>> to run it with 1.7 (to update some of our local prebuilts to update to > > >>> 1.7) and it's failing with something that makes no sense. > > >>> > > >>> I have a Groovy class that extends DefaultTask and looks something like > > >>> this: > > >>> > > >>> class DownloadArtifactsTask extends DefaultTask { > > >>> @TaskAction > > >>> void something() { > > >>> pullArtifact(...); > > >>> } > > >>> > > >>> private void pullArtifact(...) { > > >>> try { > > >>> downloadFile(...) > > >>> } catch (IOException e2) { > > >>> // ignore > > >>> } > > >>> } > > >>> > > >>> private File downloadFile(...) throws IOException { > > >>> if (...) { > > >>> throw new IOException(...); > > >>> } > > >>> } > > >>> } > > >>> > > >>> > > >>> What happens is that when downloadFile throws an IOException, it's not > > >>> caught in pullArtifact. I was really confused at first. So I put a > > >>> catch on Throwable, and noticed that my original exception was > > >>> encapsulated in a GradleException. > > >>> > > >>> Nothing in my code does this obviously. The stack trace looks like this: > > >>> > > >>> org.gradle.api.GradleException: Could not call > > >>> DownloadArtifactsTask.downloadFile() on task ':downloadArtifacts' > > >>> at org.gradle.util.JavaMethod.invoke(JavaMethod.java:69) > > >>> at > > >>> org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:295) > > >>> at > > >>> org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:136) > > >>> at > > >>> org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:147) > > >>> at > > >>> com.android.build.gradle.buildsrc.DownloadArtifactsTask_Decorated.invokeMethod(Unknown > > >>> Source) > > >>> at > > >>> org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.call(PogoInterceptableSite.java:45) > > >>> at > > >>> org.codehaus.groovy.runtime.callsite.PogoInterceptableSite.callCurrent(PogoInterceptableSite.java:55) > > >>> at > > >>> com.android.build.gradle.buildsrc.DownloadArtifactsTask.pullArtifact(DownloadArtifactsTask.groovy:204) > > >>> .... > > >>> Caused by: java.io.FileNotFoundException: http://xxx > > >>> at > > >>> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1434) > > >>> at java.net.URL.openStream(URL.java:1010) > > >>> at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:844) > > >>> at org.apache.commons.io.FileUtils$copyURLToFile.call(Unknown > > >>> Source) > > >>> at > > >>> com.android.build.gradle.buildsrc.DownloadArtifactsTask.downloadFile(DownloadArtifactsTask.groovy:256) > > >>> > > >>> > > >>> DownloadArtifactsTask.groovy:204 is where downloadFile() is called. > > >>> > > >>> Anyone has a clue? > > > > -- > > Luke Daley > > Principal Engineer, Gradleware > > http://gradleware.com > > > > > > --------------------------------------------------------------------- > > To unsubscribe from this list, please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > > -- > Luke Daley > Principal Engineer, Gradleware > http://gradleware.com > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > -- Luke Daley Principal Engineer, Gradleware http://gradleware.com --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email