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:
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?
To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build. As a result, the test sources aren't compiled, and therefore, aren't executed.
By default, Gradle will run all tests that it detects, which it does by inspecting the compiled test classes. This detection uses different criteria depending on the test framework used. For JUnit, Gradle scans for both JUnit 3 and 4 test classes.
Selecting Which Build to Execute When you run the gradle command, it looks for a build file in the current directory. You can use the –b option to select a particular build file along with absolute path. The following example selects a project hello from myproject. gradle file, which is located in the subdir/.
Under Eclipse > Menu bar "Windows" > Preferences >
left hand side: Gradle> Arguments > Program Arguments >
put -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.
See if that helps. Make sure GRADLE_HOME is set / known to 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:
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
}
}
OR
try this solution: https://www.mail-archive.com/[email protected]/msg09173.html
OR
How to prevent gradle build from executing test task
You can locally set this in eclipse
Right Click on build.gradle --> Run As --> Gradle build --> This will open a window.
Gradle task as :build
Program args as -x test
Refer below Image.. All set .. Run Now..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With