I want to forbid usage of some annotations in a project. Specially #SneakyThrows annotation from lombok.
One way to do this is to fail while building maven artifact.
Are there some existing plugins to reach this?
I think it is possible to achive using static code analyzers like checkstyle. But I don't want to write new rule for it.
Also it is interesting if exists such plugins for gradle?
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${basedir}</basedir>
<includes>
<include>target/**/*.java</include>
</includes>
<regex>false</regex>
<replacements>
<replacement>
<token>#SneakyThrows</token>
<value>#### I-DONT-THINK-SO ####</value>
</replacement>
</replacements>
</configuration>
</plugin>
Related
So I'm creating a maven plugin using the maven-plugin-plugin. The HelpMojo in maven-plugin-plugin generates a java source file.
Unfortunately, PMD is picking this up and complaining about it. Is there a way to have PMD ignore just a single source file? Thanks!
Maven PMD Configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
</configuration>
</execution>
</executions>
</plugin>
Generated sources usually end up (with maven) in a subdirectory in target/generated-sources, for the maven-plugin-plugin it's target/generated-sources/plugin.
You can exclude these complete directories with excludeRoots, e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
<excludeRoots>
<excludeRoot>target/generated-sources/plugin</excludeRoot>
</excludeRoots>
</configuration>
</execution>
</executions>
</plugin>
There is also a file based exclude option.
How to sign all jars and wars that are generated in project when i clean and build with maven ? Is there such plugin and instruction how to use it. I found this http://maven.apache.org/plugins/maven-jarsigner-plugin/usage.html while searching the internet but there is no good instruction how to use or test it.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>sign</id>
<phase>install</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<archiveDirectory>jars location</archiveDirectory>
<includes>
<include>**/*.jar</include>
</includes>
<keystore>/path/to/keystore.jks</keystore>
<alias>...</alias>
<storepass>...</storepass>
<keypass>...</keypass>
</configuration>
</plugin>
This code worked for me
I use Coveralls in a Java project with Maven to create a coverage report for my project and I want to avoid some classes from being included in the coverage computation.
Now, I think that I the build phase I can exlcude the class, e.g. MyClassTest.java as follows:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/*MyClassTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.1.0</version>
</plugin>
Anyway, the coverage doesn't decrease, so I guess that the class MyClass is still computed from the Jacoco report.
In the travis file I call the report phase as follows:
- mvn clean test jacoco:report coveralls:report
Any idea?
My bad!
First the .java has to be removed and replace with .class as correctly suggested by Tunaki.
Second, I don't have to exclude the test class, but the class that I don't want to measure in the coverage!
So it is:
<excludes>
<exclude>**/*MyClass</exclude>
</excludes>
instead of
<excludes>
<exclude>**/*MyClassTest.java</exclude>
</excludes>
I have a set of integration tests which I need to run in specific order. So i created a BlahSuite.java inside the same package, and specified the order of classes there. And annotation as following
#RunWith(Suite.class)
#Suite.SuiteClasses({
And I added the plugin into pom as following
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.9</version>
<configuration>
<includes>
<include>**/*Suite.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
But still the tests are fired in different orders, feels like the Suite class is fully ignored. Any idea how to fix this ?
I found the answer at Stackoverflow question Run Junit Suite using Maven Command
So what my final setup is I just removed failsafe plugin and added following,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Suite.class</include>
</includes>
</configuration>
</plugin>
Is there a maven plugin capable of generating ISO images?
I need to take the output of some modules (mostly zip files containing jars) and combine them into a single ISO image.
Thanks
There is now an ISO9660 maven plugin that does the job:
https://github.com/stephenc/java-iso-tools/commits/master/iso9660-maven-plugin
Documentation is sparse but got it working with the following:
<plugin>
<groupId>com.github.stephenc.java-iso-tools</groupId>
<artifactId>iso9660-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<id>generate-iso</id>
<goals>
<goal>iso</goal>
</goals>
<phase>package</phase>
<configuration>
<finalName>${project.build.finalName}.iso</finalName>
<inputDirectory>${project.build.directory}/iso</inputDirectory>
</configuration>
</execution>
</executions>
</plugin>
I'm not aware of any native integration (certainly in the Assembly plugin), but it looks like the following library is available: http://jiic.berlios.de/
This could be wrapped in a Maven plugin, or for simpler integration used with the Maven AntRun plugin and the pre-bundled ant task.
<plugin>
<groupId>com.github.stephenc.java-iso-tools</groupId>
<artifactId>iso9660-maven-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<id>generate-iso-windows</id>
<goals>
<goal>iso</goal>
</goals>
<phase>prepare-package</phase>
<configuration>
<enableRockRidge>true</enableRockRidge>
<enableJoliet>true</enableJoliet>
<hideMovedDirectoriesStore>true</hideMovedDirectoriesStore>
<finalName>IsoFileName.iso</finalName>
<inputDirectory>target/input</inputDirectory>
</configuration>
</execution>
</executions>
</plugin>
From this mail archive exchange, it seems like the maven assembly plugin could do the trick. But it's only a third-hand info.
<plugin>
<!-- ISO generation. -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
<configuration>
<executable>genisoimage</executable>
<arguments>
<argument>-V</argument>
<argument>${iso.name}</argument>
<argument>-m</argument>
<argument>*.iso</argument>
<argument>-dir-mode</argument>
<argument>0555</argument>
<argument>-file-mode</argument>
<argument>0555</argument>
<argument>-gid</argument>
<argument>0</argument>
<argument>-uid</argument>
<argument>0</argument>
<argument>-iso-level</argument>
<argument>2</argument>
<argument>-J</argument>
<argument>-joliet-long</argument>
<argument>-r</argument>
<argument>-o</argument>
<argument>${project.build.directory}/${ iso.name }</argument>
<argument>${iso.preparation.dir}</argument>
</arguments>
</configuration>
</plugin>