I am using the PMD 3.1 maven plugin and it does not seem to recognise rules > 5.0.
ie. AvoidProtectedMethodInFinalClassNotExtending is not found when I do a maven build.
Failure executing PMD: Unable to find referenced rule AvoidProtectedMethodInFinalClassNotExtending; perhaps the rule name is mispelled?
I have set the target JDK to use 1.7
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.1</version>
<dependencies>
<dependency>
<groupId>au.com.patrick.vts.build.tools</groupId>
<artifactId>build-tools</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<configuration>
<failsOnError>true</failsOnError>
<targetJdk>${java-version}</targetJdk>
<linkXRef>true</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>compile</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
The current version 3.1 of maven-pmd-plugin uses PMD 5.0.5 and does not support 5.1 rules. There is an open ticket at the issue tracker to release a new version with PMD 5.1. All you can do at the moment is vote the issue up and hope it gets resolved soon or fix the issue yourself.
Related
I have a maven project. I am replacing maven-release-plugin with maven ci friendly feature. But I want to check if any of the dependency in pom has snapshot version. If so want to fail the build for production. But for staging I would like to continue the build.
Is there any github action which will checks for snapshot in dependency ?
Answering my own question. #khmarbaise was right. I did using following setup
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>initialize</phase>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed for Dependencies!</message>
</requireReleaseDeps>
<requireReleaseVersion>
<message>Snapshot Version is Not Allowed for Release</message>
</requireReleaseVersion>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
I have spring boot project with scala inside ( I use java+scala mixed ).
Some screens from intellij:
Some interesting parts in pom.xml
<scala.version>3.1.1</scala.version>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala3-library_3</artifactId>
<version>${scala.version}</version>
</dependency>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.6.1</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Not sure why, but when I do some change in scala file, I need to click Build Project button, to see if there are some errors, for java files all works fine.
ok I found..
in project settings had invalid SDK under Project and SDKs
changed both to:
now everything works fine
I've spent quite a bit of time figuring out how to invoke Maven shade plugin to build a uber-jar (with all dependencies).
Most of the google-able info that I found (including numerous examples, and Maven documentation) suggests that all I have to do is include the plugin into pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
and then "mvn package" (or any other goal that eventually invokes "package") will automatically trigger this plugin.
But no matter what I tried - the only way to actually invoke the plugin appears to be: running "mvn package shade:shade" (which seems to defeat the purpose of config-driven build). Same results whether running Maven from within Eclipse (STS Version: 3.8.2.RELEASE), or from command line (Apache Maven 3.3.9).
Am I missing anything?
UPD: solved, see answer by GauravJ.
I have managed to reproduce your problem. In your pom.xml, you must have defined plugin like below,
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
....
</plugins>
</pluginManagement>
</build>
instead of
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
This will probably fix your problem.
I was looking for hard-deploy option in Jboss &.x but I believe that option is no longer supported in Jboss 7.x
what I found was this Jboss link containing latest plugins
.
I have decided to use Jboss-as:redeploy option.It seems to work perfectly for me- kind of replacement for hard-deploy.But when I check my Jboss/standalone/deployment folder the timestamp of war is not updated.But code changes are reflected in the application.below is the maven plugin code that I am using
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.5.Final</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>redeploy</goal>
</goals>
</execution>
</executions>
</plugin>`
Is there any bug in jboss plugin there ?Is it the right way to achieve my hard-deploy goal in Jboss 7.x
There seems to be no hard-deploy feature in the jboss 7.We have now used maven plugin to copy the new build to the deployment directory and Jboss will detect the change and deploy the new WAR.Below is the code for the same:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>copy-war-file</id>
<phase>install</phase>
<configuration>
<tasks>
<copy file="target/myapp.war" tofile="${env.JBOSS_HOME}\standalone\deployments\myapp.war" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I wonder if it's possible to have the Maven Surefire plugin running several times (several executions) with different different versions of dependencies ?
This could be convenient for example to ensure that your code is still compatible with previous versions of project's dependencies.
I manage at least to run 2 executions of surefire :
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>test-default-deps</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
<execution>
<id>test-anotherversion-deps</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<reportsDirectory>${project.build.directory}/surefire-reports-anotherversion-deps</reportsDirectory>
<dependencies>
<!-- Version different of the default for the project -->
<dependency>
<groupId>com.dep.groupid</groupId>
<artifactId>dep-artifact</artifactId>
<version>anotherversion</version>
</dependency>
</dependencies>
</configuration>
</execution>
</executions>
</plugin>
But this different version is not taken into account during the 2nd execution.
Am I trying to do something unfeasible or am I doing in the wrong way ?
Is there another plugin that could be helpful for this purpose ?