如何使用Gradle配置UglifyJS? [英] How to configure UglifyJS with Gradle?

查看:140
本文介绍了如何使用Gradle配置UglifyJS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



是否有用于UglifyJ的现成的Gradle插件?我们正在尝试配置Uglify,类似于在此处完成的操作,但是该项目的所有者似乎具有指向他自己的私有工件,从而可以访问UglifyAntTask,这是一个由GitHub托管的项目,不遵循Gradle / Maven等(基本上是非托管)JAR。我们尝试将这个JAR下载到我们的项目中,并尝试使用gradle页面中建议的选项进行配置,如下所示:


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引发以下错误:

Gradle throws the following errror:


taskdef类uglify.ant.UglifyTask找不到
使用classloader AntClassLoader []

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

我希望至少有人一定需要包含非托管3rd党的JAR,并想出如何o如果要这样做,请指出我们已解决的问题/错误。

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.

谢谢,

Paddy

Thanks,
Paddy

推荐答案

以下是Gradle官方文档的描述方式:

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 ... )
}

请参见 http://www.gradle.org/docs/current/userguide/ant.html#N11416

HTH

这篇关于如何使用Gradle配置UglifyJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆