How to configure UglifyJS with Gradle?

为君一笑 提交于 2019-12-24 13:23:43

问题



Are there any ready-to-use Gradle plugins to use for UglifyJs? We are trying to configure Uglify something similar to what has been done here, but the owner of that project seems to have his own private artifactory to which he points to, thereby getting access to UglifyAntTask, which is a github-hosted project not following Gradle/Maven etc. (basically non-managed) JAR. We tried downloading this JAR to our project and tried configuring using the options suggested in gradle page as follows:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar') (or)
    compile files('uglifyjs-java-v1.0.jar')
}

Note: The (or) is not there in actual code, I mentioned only to indicate that we tried both options but it was not picking the JAR.

So at a later step, when we gave

ant.taskdef(name: "uglify", classname: "uglify.ant.UglifyTask", classpath: configurations.uglifyjs.asPath)

Gradle throws the following errror:

taskdef class uglify.ant.UglifyTask cannot be found using the classloader AntClassLoader[]

I am hoping that at least some one must have had the need to include non-managed 3rd party JAR and have figured out how to do this, if so, please point the solution/mistake we have made.

Thanks,
Paddy


回答1:


Here is how the offical Gradle documentation describe it:

configurations {
  uglifyjs
}
dependencies {
  uglifyjs files('uglifyjs-java-v1.0.jar')
}
task uglifyjs << {
  ant.taskdef(name: 'uglifyjs', classname: 'uglify.ant.UglifyTask', classpath: configurations.uglifyjs.asPath)
  ant.uglifyjs( ... UglifyJS Ant Task parameters ... )
}

See http://www.gradle.org/docs/current/userguide/ant.html#N11416

HTH



来源:https://stackoverflow.com/questions/18213312/how-to-configure-uglifyjs-with-gradle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!