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?
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.
Use the command ./gradlew test to run all tests.
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
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
).
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