IcedDante IcedDante - 7 months ago 86
Java Question

Running Gradle Build From Eclipse without test

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?


Under Eclipse > Menu bar "Windows" > Preferences > left hand side: Gradle> Arguments > Program Arguments > put -x test


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.

enter image description here

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:

  1. In GRADLE_HOME/init.d folder, create a global common file called shenzi.gradle
  2. In this common file, add the following:

        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


try this solution:


How to prevent gradle build from executing test task