在没有测试的情况下从 Eclipse 运行 Gradle Build
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25145162/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running Gradle Build From Eclipse without test
提问by IcedDante
I have a gradle build file that uses the java plugin. If I want to invoke build from the command line and avoiding running unit tests I can just do this:
我有一个使用 java 插件的 gradle 构建文件。如果我想从命令行调用 build 并避免运行单元测试,我可以这样做:
gradle build -x test
However, we'll be calling gradle tasks from Eclipse. Do I need to build a special task for this kind of build? How would I go about doing it?
但是,我们将从 Eclipse 调用 gradle 任务。我需要为这种构建构建一个特殊的任务吗?我将如何去做?
采纳答案by AKS
Under Eclipse > Menu bar "Windows" > Preferences >
left hand side: Gradle> Arguments > Program Arguments >
put -x test
在Eclipse > Menu bar "Windows" > Preferences >
左侧下方:Gradle> Arguments > Program Arguments >
放-x test
and
和
Under Eclipse > Menu bar "Windows" > Preferences >
left hand side: Gradle EnIDE>
check box the box next to -x test (--exclude-task test) or use gradle assemble
line.
在Eclipse > Menu bar "Windows" > Preferences >
左侧下方:Gradle EnIDE>
选中-x test (--exclude-task test) or use gradle assemble
行旁边的框。
See if that helps. Make sure GRADLE_HOME is set / known to Eclipse.
看看是否有帮助。确保 GRADLE_HOME 已为 Eclipse 设置/已知。
UPDATE:
THIS will stop running test task from any project (as it's global).
If you just want to run gradle clean build -x test
or similar (once in a while and only on some project), then do something like this:
更新:
这将停止从任何项目运行测试任务(因为它是全局的)。如果你只是想运行gradle clean build -x test
或类似的(偶尔并且只在某个项目上),那么做这样的事情:
- In GRADLE_HOME/init.d folder, create a global common file called
shenzi.gradle
In this common file, add the following:
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 } }
- 在 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 } }
OR
或者
try this solution: https://www.mail-archive.com/[email protected]/msg09173.html
试试这个解决方案:https: //www.mail-archive.com/[email protected]/msg09173.html
OR
或者
回答by rinuthomaz
You can locally set this in eclipse
你可以在 eclipse 本地设置这个
Right Click on build.gradle --> Run As --> Gradle build -->This will open a window.
右键单击build.gradle --> Run As --> Gradle build -->这将打开一个窗口。
Gradle task as :build
Program args as -x test
Refer below Image.. All set .. Run Now..
参考下图.. 全部设置.. 立即运行..