I’m a freshman to Gradle and trying to convert one of my maven poms.
In my pom.xml, there is a plugin definition, like below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
<dependency>
<groupId>cn.yusiwen</groupId>
<artifactId>maven-build-helper</artifactId>
<version>${maven-build-helper.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>checkstyle-validation</id>
<phase>compile</phase>
<configuration>
<violationSeverity>warn</violationSeverity>
<!--suppress UnresolvedMavenProperty -->
<configLocation>checkstyle.xml</configLocation>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
<excludes>**/enums/*Enum.java,**/Launcher.java,**/*Application.java</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
You can see, the plugin maven-checkstyle-plugin
depends on other maven artifacts. I’ve packed my configuration file checkstype.xml
in my artifact cn.yusiwen:maven-build-helper
and inject it into the plugin classpath, so the plugin can load the configuration file at runtime.
Can I apply checkstyle plugin in Gradle and inject my artifact cn.yusiwen:maven-build-helper
into it like maven does?
Thanks a lot!