Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Gradle plugin directly from command line

Tags:

gradle

In Maven, if I wanted to analyze my project with sonar, I could do:

mvn sonar:sonar

using the 'short' plugin name and goal.

In Gradle, is there a similar way to run plugins, without declaring them in the build.gradle script?

like image 387
Thorn G Avatar asked Jul 25 '13 15:07

Thorn G


People also ask

How do I run a Gradle task from the command line?

To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … ​ e.g. gradlew clean allTests.

How do I run a Gradle test from the command line?

Use the command ./gradlew test to run all tests.


2 Answers

This code works fine:

allprojects {
    buildscript {
        repositories {
            mavenCentral()
            maven {
                url "https://plugins.gradle.org/m2/"
            }
        }
        dependencies {
            classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
        }
    }

    apply plugin: 'java'
    apply plugin: 'jacoco'

    afterEvaluate { project ->
        project.apply plugin: 'org.sonarqube'
    }
}

gradle --init-script etc/quality.gradle sonarqube

like image 198
user2215355 Avatar answered Oct 12 '22 14:10

user2215355


There isn't currently, but there will be at some point. What you can do is to apply the plugin out-of-band (in some init.gradle).

like image 39
Peter Niederwieser Avatar answered Oct 12 '22 13:10

Peter Niederwieser