gradle-js-plugin icon indicating copy to clipboard operation
gradle-js-plugin copied to clipboard

MinifyJsTask doesn't work from an included file

Open esycat opened this issue 12 years ago • 4 comments

It seems that something goes wrong with CompilerOptions instance if a task of MinifyJsTask type is defined in a standalone file that is then included via apply from.

Please, check this example: https://dl.dropbox.com/u/1571429/devroom/gradle-js-test.tar

buildAlt task uses minifyJsLocal task that is defined right in build.gradle and it does work properly. But build, which depends on minifyJsExtermal from commons/minify.gradle, produces the following exception:

Execution failed for task ':minifyJsExtermal'.
> No signature of method: com.eriwen.gradle.js.JsMinifier.minifyJsFile() is applicable for argument types: (java.util.LinkedHashSet, java.util.LinkedHashSet, java.io.File, com.google.javascript.jscomp.CompilerOptions, java.lang.String, java.lang.String) values: [[/Volumes/Users/esycat/tmp/gradle-js-test/js/main.js], ...]
  Possible solutions: minifyJsFile(java.util.Set, java.util.Set, java.io.File, com.google.javascript.jscomp.CompilerOptions, java.lang.String, java.lang.String)
  The following classes appear as argument class and as parameter class, but are defined by different class loader:
  com.google.javascript.jscomp.CompilerOptions (defined by 'org.gradle.util.MutableURLClassLoader@7f3846fc' and 'org.gradle.util.MutableURLClassLoader@6574f7a7')
  If one of the method suggestions matches the method you wanted to call,
  then check your class loader setup.

esycat avatar Mar 25 '13 08:03 esycat

Hi @eriwen,

I have also run into this issue (in a multi-project setup).

Do you have any timelines in mind for this fix? If not, are there any workarounds?

Thanks.

clalbus avatar Dec 17 '13 15:12 clalbus

I've moved the test code: https://gist.github.com/esycat/8122571 Still and issue with v1.9 of the plugin and Gradle v1.10.

esycat avatar Dec 25 '13 11:12 esycat

It seems a workaround for this is to apply the plugin by class name instead of the extension name (i.e. JsPlugin instead of 'js') inside the includable file. An example: https://github.com/esycat/devops/blob/master/gradle/project/minify.gradle

esycat avatar Feb 22 '14 07:02 esycat

Same issue.

benweizhu avatar Jun 21 '16 05:06 benweizhu