I am working with Kotlin and want to do static analysis using Detekt plugin. My problem is, when I want to download it from Maven central repository, it is giving me below error. But when I use company's repository (Nexus), it does not give me any error and downloads it smoothly. I don't understand this.
Can someone tell me why this is happening? I want to use this plugin and have not found out any other alternative.
Below is my error :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (detekt) on project agathe: Execution detekt of goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.8 or one of its dependencies could not be resolved: Could not find artifact com.beust:jcommander:jar:1.74 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
Kindly find my POM file below.
<properties>
..
<sonar.kotlin.detekt.reportPaths>${project.build.directory}/detekt.xml</sonar.kotlin.detekt.reportPaths>
..
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<!-- This can be run separately with mvn antrun:run#detekt -->
<id>detekt</id>
<phase>verify</phase>
<configuration>
<target name="detekt">
<java taskname="detekt" dir="${basedir}"
fork="true"
failonerror="false"
classname="io.gitlab.arturbosch.detekt.cli.Main"
classpathref="maven.plugin.classpath">
<arg value="--input"/>
<arg value="${basedir}/src"/>
<arg value="--filters"/>
<arg value=".*/target/.*,.*/resources/.*"/>
<arg value="--report"/>
<arg value="xml:${project.build.directory}/detekt.xml"/>
</java>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-cli</artifactId>
<version>1.0.0-RC14</version>
</dependency>
</dependencies>
</plugin>
Related
Is it possible to set the max DFA states before table used rather than inlining in the configuration of the plugin maven antlr3 like the extended option -Xmaxinlinedfastates in the command line of antlr.Tool ?
I find it for ant script but nothing with maven.
If yes, how to ?
Thanks.
Thanks to Jiri Tousek.
I found an alternative to what I call a gap in the maven antlr3 plugin. Using the maven antrun plugin allowed me to solve this problem.
Here is the statement I made in pom.xml and that works for me:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<target>
<!-- Place any Ant task here. You can add anything you can add between
<target> and </target> in a build.xml. -->
<java classname="org.antlr.Tool" fork="true"
failonerror="true">
<arg value="-verbose" />
<arg value="-Xmaxinlinedfastates"/>
<arg value="10"/> <!-- Value for the exended option -Xmaxinlinedfastates -->
<arg path="./src/main/antlr3/*.g" />
</java>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I am able to run the FitNesse suite from maven build with the following setup.
<properties>
<fitnesse.version>20160618</fitnesse.version>
</properties>
<dependencies>
<dependency>
<groupId>org.fitnesse</groupId>
<artifactId>fitnesse</artifactId>
<version>${fitnesse.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.fitnesse.plugins</groupId>
<artifactId>maven-classpath-plugin</artifactId>
<version>1.6</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>start-fitnesse-integration</id>
<phase>integration-test</phase>
<configuration>
<tasks>
<echo taskname="fitnesse" message="Starting FitNesse..." />
<java classname="fitnesseMain.FitNesseMain" classpathref="maven.runtime.classpath"
fork="true" failonerror="true">
<jvmarg value="-Xmx1024m" />
<arg line="-p 9000" />
<arg line="-c FrontPage.TestSuite?suite&format=text" />
<arg line="-e 0" />
<!-- <arg line="-d ." /> -->
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am running the FitNesse suite using the below command.
mvn clean install
Now I want to configure execution of multiple FitNesse suites as part of pom.xml and want to run specific suite as part of maven build.
How can I achieve this?
There are a couple of ways to configure multiple suites to be run:
Add multiple execution elements to your pom (inside the executions element you already have) one per suite, each with a unique id
Place all suites you want to run under a shared parent suite (and run the parent suite). You can also use symbolic links to achieve this.
Create a suite query page to indicate which suites should be run (and run that page).
Create a suite cross reference page and run that
Give all suites the same tag and use filters to select all suites to run based on the tag
P.S. Why are you using the antrun plugin instead of maven-exec?
I have a multi-module maven project in the following structure:
root-module
|__module-a
| |__src
| |__main
| |__xsd
| | |__my.xsd
| |__xjb
| |__my.xjb
|__module-b
The POM for root module simply aggregates module a and b (among other things):
<project>
<artifactId>root-module</artifactId>
<packaging>pom</packaging>
<modules>
<module>module-a</module>
<module>module-b</module>
</modules>
</project>
And the POM for module a is as follows (among other things):
<project>
<parent>
<artifactId>root-module</artifactId>
</parent>
<artifactId>module-a</artifactId>
<properties>
<my-definitions.xsd>${basedir}/src/main/xsd/my.xsd</my-definitions.xsd>
<my-bindings.xjb>${basedir}/src/main/xjb/my.xjb</my-bindings.xjb>
<my.output>${basedir}/target/generated-sources/jaxb/my</my.output>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-my-classes</id>
<phase>generate-sources</phase>
<goals><goal>xjc</goal></goals>
<configuration>
<sources><source>${my-definitions.xsd}</source></sources>
<xjbSources><xjbSource>${my-bindings.xjb}</xjbSource></xjbSources>
<outputDirectory>${my.output}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
So when I run mvn at module-a, everything works fine and the build succeeds. But when I run it at root-module, I get an exception from the XJC plugin where it tries to find the bindings file under the root-module:
com.sun.istack.SAXParseException2; IOException thrown when processing "file:/home/root-module/src/main/xjb/my.xjb". Exception: java.io.FileNotFoundException: /home/root-module/src/main/xjb/my.xjb (The system cannot find the path specified).
What is interesting is, it is able to locate the XSD correctly:
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.1:xjc (generate-my-classe) on project module-a:
[ERROR] +=================== [XJC Error]
[ERROR] |
[ERROR] | 0: file:/home/root-module/module-a/src/main/xsd/my.xsd
[ERROR] |
[ERROR] +=================== [End XJC Error]
Any clues?
Is this a configuration issue in the build script?
Specifics of my build system:
Using Maven 3.2.5
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.1</version>
Referring JAXB2 Maven plugin documentation from here.
Also searched few related questions on SO, but they do not explain my specific problem anywhere.
UPDATE: Looks like an open issue. Keeping the thread open in case there is a workaround.
Updating to version 2.2 of the plugin appears to work.
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
I had the same problem when using version 2.1 of the plugin. Simply changing to version 2.2 fixed the issue.
Until a plugin resolution is available, I am using the following ant-run hack:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-my-classes</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/generated-sources/jaxb/my" />
<exec executable="${env.JAVA_HOME}/bin/xjc.exe" dir="${project.basedir}/src/main/xsd">
<arg value="-p" />
<arg value="my.package" />
<arg value="-b" />
<arg value="${project.basedir}/src/main/xjb" />
<arg value="-d" />
<arg value="${project.build.directory}/generated-sources/jaxb" />
<arg value="." />
</exec>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
UPDATES:
Discussion on Github.
Considering Apache CXF Utils as an alternative.
I am migrating a project to Maven and as we were used to always reference our builds by the latest change number in our Perforce SCM repository, I would like to be able to extract this information
I am trying to configure Maven scm plugin via following resources:
http://maven.apache.org/scm/maven-scm-plugin/usage.html for generic usage
http://www.perforce.com/perforce/doc.current/manuals/p4maven/index.html
First I don't understand how to make it work, so if anybody has a fully working example, I will be happy to, on my side I have tried by adding in my pom:
<scm>
<connection>
scm:perforce:localhost:1666://depot/
<my_project>
/
<version>
</connection>
<developerConnection>
scm:perforce:localhost:1666:/depot/
<my_project>
/
<version>
</developerConnection>
<url>http://somerepository.com/view.cvs</url>
</scm>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.6</version>
<dependencies>
<!-- P4Maven -->
<dependency>
<groupId>com.perforce</groupId>
<artifactId>p4maven</artifactId>
<version>[2011,2012)</version>
</dependency>
</dependencies>
<configuration>
<connectionType>//depot/proto/kernel/kernel/04.00/maven2</connectionType>
<username>my local username</username>
<password>xxxxxx</password>
<includes>**</includes>
</configuration>
</plugin>
</plugins>
this is leading me to:
[INFO] --- maven-scm-plugin:1.6:checkout (default-cli) # kernel ---
mars 27, 2012 9:54:08 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
Avertissement: Error injecting: org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider
java.lang.NoClassDefFoundError: org/apache/maven/scm/command/info/InfoScmResult
Surely forgot something, I will try to read again the instructions and see what I miss, but if anybody knows ...
Anyway, my question is rather: is it worth trying it ?
I don't see in the available actions from scm plugin anything that will help me getting the last change information and integrate it into a reference build number. Shall I develop my own plugin for this ?
Thanks in advance.
I got some advice from one of the P4Maven developers that might help.
First, check your configuration. The "..." in the "" tag should be one of the tag names in the "" tag (i.e. "connection" or "developerConnection")
There two options to use Maven with Perforce SCM.
Use the default (built-in) Maven Perforce SCM provider (p4 commandline based)
Note that you'll need the p4 commandline executable installed
You can set the username and password using environment variables or JVM args
[environment variables]
P4CLIENT=
P4USER=
P4PASSWD=
or
[JVM args]
-Dusername= -Dpassword=
[pom.xml]
...
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.4</version>
</plugin>
...
...
<!-- SCM Settings -->
<scm>
<connection>scmerforce:localhost:1666://depot/someproject</connection>
<developerConnection>scmerforce:localhost:1666://depot/someproject</developerConnection>
<url>scmerforce://depot/simple</url>
</scm>
...
Use the P4Maven Perforce SCM provider (P4Java based)
[pom.xml]
...
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.4</version>
<dependencies>
<!-- P4Maven -->
<dependency>
<groupId>com.perforce</groupId>
<artifactId>p4maven</artifactId>
<version>[2011,2012)</version>
</dependency>
</dependencies>
<configuration>
<connectionType>connection</connectionType>
<username>someuser</username>
<password>somepassword</password>
<includes>**</includes>
</configuration>
</plugin>
...
...
scm4:localhost:1666://depot/someproject
scm4:localhost:1666://depot/someproject
scm4://depot/someproject
...
Note that for P4Maven we're overriding the default provider inside the "maven-scm-plugin" plugin.
Note that we're using "scmp4" (if using P4Maven) instead of "scmperforce" (built-in default) as the provider name, since "perforce" is taken by the existing default implementation.
I was struggling with exactly the same problem recently - I just wanted to get a Perforce revision number to use it in maven artifacts (for example as a part of a name). I checked buildnumber-maven-plugin, but it does not support Perforce at all. I also tried maven-release-plugin, but it seems to me as it does too much and I even didn't find out if it will do what I need.
Anyway I ended up with a solution which I don't like, but it works. I get this revision number directly with p4 executable via ant and antrun plugin (you must use the latest 1.7 version to export ant property to maven). You also need to have p4 executable available.
After this plugin configuration is used you have ${revision.number} available in maven.
<!-- Get Perforce latest change number -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
</dependency>
</dependencies>
<configuration>
<exportAntProperties>true</exportAntProperties>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="maven.plugin.classpath"/>
<!-- Login to p4 -->
<exec executable="p4" inputstring="${p4.password}">
<arg value="-p${p4.server}"/>
<arg value="-c${p4.client}"/>
<arg value="-u${p4.username}"/>
<arg value="login"/>
</exec>
<!-- Get reivision description text -->
<exec executable="p4" outputproperty="revision.description">
<arg value="-p${p4.server}"/>
<arg value="-c${p4.client}"/>
<arg value="-u${p4.username}"/>
<arg value="changes"/>
<arg value="-m1"/>
<arg value="//...#have"/>
</exec>
<!-- Logout from p4 -->
<exec executable="p4">
<arg value="-p${p4.server}"/>
<arg value="-c${p4.client}"/>
<arg value="-u${p4.username}"/>
<arg value="logout"/>
</exec>
<!-- Parse revision description to retrieve only revision number -->
<propertyregex property="revision.number"
input="${revision.description}"
regexp="Change ([0-9]*) on ([a-z,0-9]*)"
select="\1"
casesensitive="false"/>
<echo>Perforce latest revision number: ${revision.number}</echo>
</target>
</configuration>
</execution>
</executions>
</plugin>
It's been a few years since the question was asked, but in the interval p4maven has been rewritten, and the updated documentation is startlingly hard to find.
Here's the new README.md. I followed it through and everything works. At this point, 1.0.6 is the latest version in maven central.
I discovered the source from a link on the Maven build number plugin page.
I landed here while searching for solution of a similar issue "NO Configuration could be determinded" which i faced with Code Collaborator client with P4. I ended up in uninstalling P4 client and reinstalling to get it working.
there is -f option in maven, that allows to specify alternate pom.xml file. Is there a possibility, that I can also bring this behaviour to the executed modules? Now it looks like, that when I have this structure: projectA: pom.xml pom.xml2
projectB: pom.xml pom.xml2
And when I run maven with -f pom.xml2 option as reactor with projectB specified as module, it looks like that it picks pom.xml2 from the projectA, and it picks pom.xml from projectB. Is there a way, how can I propagate the -f option to the modules?
Thanks for answering.
Because we can specified pom file in module definition.1
Here's an example for using alternative pom file in module.
<modules>
<module>child1/pom-jdk14.xml</module>
<module>child2/pom-jdk14.xml</module>
</modules>
As Jörn Horstmann comments I would try lots of things to get this working with profiles in one pom.
If that's not possible the only way I can think of to get this working is to bypass the normal maven mechanism by using a "switching pom" with profiles. This pom is put as pom.xml in each module and has a profile for each of your pom.xml2 (or others) and in that profile executes another maven build f.e. via the antrun-plugin with the -f for the pom you need:
<profile>
<id>xml2</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build pom.xml2</id>
<phase>prepare-package</phase> <!-- whatever suits you -->
<configuration>
<target>
<echo level="info" message="Building pom.xml2..." />
<exec executable="cmd" dir=".">
<arg value="/c" />
<arg value="mvn" />
<arg value="-f" />
<arg value="pom.xml2" />
<arg value="install" /> <!-- enter which phase you need -->
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>