我有一个使用 java 插件的 gradle 构建文件。如果我想从命令行调用构建并避免运行单元测试,我可以这样做:
gradle build -x test
但是,我们将从 Eclipse 调用 gradle 任务。我需要为这种构建构建一个特殊的任务吗?我该怎么做?
最佳答案
在 Eclipse > 菜单栏“Windows”> Preferences >
左侧:Gradle> Arguments > Program Arguments >
放 -x test
和
在 Eclipse > 菜单栏“Windows”> Preferences >
左侧:Gradle EnIDE>
选中 -x test (-- exclude-task test) 或使用 gradle assemble
行。
看看是否有帮助。确保 Eclipse 设置/已知 GRADLE_HOME。
更新:
这将停止从任何项目(因为它是全局的)运行测试任务。
如果你只是想运行 gradle clean build -x test
或类似的(偶尔并且只在某些项目上),那么做这样的事情:
- 在 GRADLE_HOME/init.d 文件夹中,创建一个名为
shenzi.gradle
的全局通用文件> 在这个通用文件中,添加以下内容:
allprojects{ apply plugin: 'java' apply plugin: 'groovy' // blah blah uncomment if you need. //apply plugin: 'pmd' //apply plugin: 'findbugs' //apply plugin: 'checkstyle' //apply plugin: 'jacoco' tasks.withType(Compile) { options.debug = true options.compilerArgs = ["-g"] } // .. // .. more code exists here for commented out lines as shown above, so ignore this in your version // .. task myAliasNoTestBuild() << { // see link below on how to create alias tasks } }
或
试试这个解决方案:https://www.mail-archive.com/user@gradle.codehaus.org/msg09173.html
或
关于java - 在没有测试的情况下从 Eclipse 运行 Gradle 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25145162/