Maven jboss plugin error: "no plugin found for prefix jboss-as" - maven

I get the following error when trying to run the jboss-as:deploy goal.
No plugin found for prefix 'jboss-as' in the current project and in
the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]
available from the repositories [local (/home/user/.m2/repository),
central (http://repo.maven.apache.org/maven2)] -> [Help 1]
I tried out everything written here maven-javadoc-plugin and failsafe-maven-plugin missing when build JBoss Seam examples, but no luck. I need to make this plug-in work without having to add anything in the maven settings file (only in pom).

Assuming your build section has something like this in it:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<jbossHome>/usr/jboss-4.2.3.GA</jbossHome>
<serverName>all</serverName>
<fileName>target/my-project.war</fileName>
</configuration>
</plugin>
</plugins>
</build>
Then you should be using jboss:deploy instead of jboss-as:deploy. But if its like:
<build>
...
<plugins>
...
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.2.Final</version>
</plugin>
</plugins>
</build>
Then you should be using jboss-as:deploy instead of jboss:deploy.
Both worked for me with a fresh install of maven 3.0.4 with a bare pom.

Yes, Welsh is right.
The first one is located here and the second one here.
So, pay attention if you need to use the "jboss-as" goal specifier or the "jboss" goal specifier.

Related

running secbugs maven plugin from command line/ maven plugin configuration parameters in command line

maybe this is a generic question with regards to how to transfer maven plugin paramters from the pom.xml to the commandline, but I have usually done this without problems using the method below. For the find-security-bugs plugin, however, it is not working.
The find-security-bugs plugin docu says that you can configure the plugin in your pom.xml as follows:
<plugins>
[...]
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.7.2.1</version>
<configuration>
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>1.12.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
I would like to do the same, but cannot do any changes to the pom.xml I'm testing, so would have to specify everything in the command line.
I'm running (from powershell, therefore the quotation marks):
mvn com.github.spotbugs:spotbugs-maven-plugin:4.7.2.1:check -"Dplugins.plugin.groupId=com.h3xstream.findsecbugs" -"Dplugins.plugin.artifactId=findsecbugs-plugin" -"Dplugins.plugin.version=1.12.0" -"DincludeFilterFile=secbugsfilter.xml"
but the parameters are not used. Is there any way to run a plugin with a configuration like this from the command line without specifying anything in the pom?

when to use <build> plugin in maven pom.xml?

In our project, we have configured jetty inside build plugin in pom, i want to understand configuration settings in pom/ what and all we can configure in pom.
what is <build><plugin> section in pom, when to use.
difficult to understand from tutorials because lot of different examples which is making confuse.
Please can somebody explain for the above in detail?
Plugins defined in your buildsection plugins tag will be executed during the build of your project.
There are many plugins that do something with your build.
For example the maven-compiler-plugin which allows you to set the Java version for your project.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
a list of maven build plugins supported by maven itself

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: 3.2:sonar

Can anyone help me in getting solution for the below error.
Below are the version of the components to configure
SonarQube 5.1.2
Soanr-Runner 2.4
Java 1.7 [ I have to use 1.7 only since my code supports only 1.7]
mavn 3.3.9
sonar-cobertura-plugin-1.6.3
sonar-findbugs-plugin-3.3
cobertura 2.6
Execution command
mvn -fn -e org.sonarsource.scanner.maven:sonar-maven-plugin:RELEASE:sonar -Dsonar.jdbc.url="jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" -Dsonar.host.url=http://localhost:9000 -DskipTests
In Console Window I am getting error
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:
3.2:sonar (default-cli) on project NWT_Core: Execution default-cli of goal org.s
onarsource.scanner.maven:sonar-maven-plugin:3.2:sonar failed: Unable to load the
mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.
2' due to an API incompatibility: org.codehaus.plexus.component.repository.excep
tion.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0
Since the 3.2, the SonarQube maven plugin requires Java 8.
You have to use the 3.0.2 version for Java 7.
You have to explicitely add this statement to your pom :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.2</version>
</plugin>
Because if you do not do so, by default this plugin uses the LATEST version of the plugin (3.2), hence your error.
See http://docs.sonarqube.org/display/HOME/Frequently+Asked+Questions#FrequentlyAskedQuestions-ShouldIlockversionofSonarQubeMavenplugininmypom.xml?
Regardless of what you compile your code with, the SonarQube analysis should be run with a specific Java version.
You simply need to use different JDK versions for the compilation and analysis.
For SonarQube 6.* compatibility], make sure the JAVA_HOME=/path/to/java8
For SonarQube 9.* compatibility], make sure the JAVA_HOME=/path/to/java11
In my case I had a parent pom with
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</pluginManagement>
</build>
I've added my own version also within pluginManagement in my child pom but this didn't work I had to add the plugin to the <build><plugins> nodes instead of <build><pluginManagement><plugins>. Only then new newer version had been used.
Maybe this helps someone.
Recently, install Sonorqube.5.12 image in docker and push the project into Sonorqube. Initially we were facing some maven console errors like major.minor version 52.0.
Later, has been fixed by below step's for me.
Add this plugs in maven.
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
Next, Add default DB setup in ~/.m2/settings.xml file
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>jdbc:h2:tcp://localhost:9092/sonar</sonar.jdbc.url>
<sonar.host.url>http://localhost:9000</sonar.host.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.pdf.username>admin</sonar.pdf.username>
<sonar.pdf.password>admin</sonar.pdf.password>
</properties>
</profile>
It worked for me after using Maven->update project , mvn clean install, mvn clean compile

Should pluginManagement be used in submodules?

I am reading sonatype's tutorial on multimodule projects and I see that in submodule they use the <pluginManagement> configuration like this:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
This confuses me as I thought that <pluginManagement> is to be used in parent POM to provide common plugin configuration for submodules. What are the reasons for using plugin managment in children poms ?
Most of the time <pluginManagement> is used in parent pom files.
It configures plugins. But makes them not active part of the build. Therefor you need to add them to the <plugins> part of the Maven pom file. Most not done in parent pom files, but done in the (sub) modules, using / refering to that (parent) pom.
I think this is special to the use of the surefire plugin.
Since you execute the plugin with mvn test the surefire plugin will be executed with the configuration specified in the pluginManagement block. Other plugins are not executed directly but by binding them to another lifecycle phase and thus must be specified in the plugin block.
See the usage page of the surefire plugin.

Specify which maven build plugins to use in a parent pom

I have a couple of projects, all using the same plugins in the build section.
Is it possible to specify which plugins to run inside the build section in a central place?
I know you can put the plugin configuration in a parent poms pluginManagement section, but then you still have to list all plugins in the build section.
For example I want something like:
parent.pom
<pluginManagement>
<plugins>
<plugin>
<artifactId>plugin1</artifactId>
...
</plugin>
<plugin>
<artifactId>plugin2</artifactId>
...
</plugin>
</plugins>
</pluginManagement>
child.pom
<build>
<include-plugins-from-parent-without-listing-plugin1-and-plugin2/>
</build>
Also, I would like to do the same thing with reports. Define in a single file which reports to run and include this in every other project.
Update: any other way of synchronizing the same build settings between multiple projects is fine too. I just do not want to copy&paste the same stuff in all POM files.
Inside parent.pom declare the plugins inside <build>\<plugins> instead of <pluginManagement>:
<build>
<plugins>
<plugin>
<artifactId>plugin1</artifactId>
...
</plugin>
</plugins>
</build>

Resources