Maven: plugin to fail assembly if a string is found

During development, I have the habit of wrapping code that should not be in production inside the TODEL tag. For instance:

//TODEL - START //used to test the crashing behavior String s = null; int i = s.length; //TODEL - END 

Is there a maven plugin that can disable jenkins if I accidentally post a file containing "TODEL"?

+4
source share
1 answer

The only thing you can do is use the maven checkstyle plugin . You can configure the rule and make the assembly unsuccessful if it does not comply with these rules.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>my-checkstyle.xml</configLocation> </configuration> </plugin> 

maven.checkstyle.fail.on.violation configuration maven.checkstyle.fail.on.violation .

Then mvn checkstyle:check . Or configure it to be executed in the phase of your choice (compilation or technological resources), adding to the plugin configuration:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <executions> <execution> <id>TODEL</id> <configuration> <configLocation>my-checkstyle.xml</configLocation> </configuration> <goals> <goal>check</goal> </goals> <phase>validate</phase> </execution> </executions> </plugin> 

Additional information: http://maven.apache.org/plugins/maven-checkstyle-plugin

+5
source

All Articles