Could not find goal 'devmode' in plugin org.codehaus.mojo - java

I am a beginner in GWT and Maven. I created a new GWT Application project in Eclipse. Then, I converted that project into Maven Project by right-click on Project name => Configure => Convert to Maven Project and I saw that a pom file was generated for that project. Next, I run as project as Maven build but it was not compiled since a goal was not specified there. Actually, I don't understand what exactly have I to write under that goal section, therefore, I wrote package under that and then again I built maven and it compiled successfully.
After that, I tried to run this maven project in Command Prompt on the SuperDevMode using the 2nd step mentioned on Run the GWT Project under the Setting up a new project section. But while following these steps on Command Prompt, I got an error that devmode could not be found. Here is my Command prompt log:
C:\Users\TEST>cd eclipse-workspace/MyWebApp
C:\Users\TEST\eclipse-workspace\MyWebApp>mvn war:exploded
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenApp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-war-plugin:3.1.0:exploded (default-cli) # abcdef ---
[INFO] Exploding webapp
[INFO] Assembling webapp [abcdef] in [C:\Users\TEST\eclipse-workspace\MyWebApp\target\abcdef-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [63 msecs]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.920 s
[INFO] Finished at: 2017-08-30T11:24:53+05:30
[INFO] Final Memory: 12M/107M
[INFO] ------------------------------------------------------------------------
C:\Users\TEST\eclipse-workspace\MyWebApp>mvn gwt:devmode
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.301 s
[INFO] Finished at: 2017-08-30T11:25:02+05:30
[INFO] Final Memory: 8M/107M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'devmode' in plugin org.codehaus.mojo:gwt-maven-plugin:2.8.1 among available goals clean, compile, compile-report, css, debug, eclipse, eclipseTest, generateAsync, help, i18n, mergewebxml, resources, run, run-codeserver, source-jar, test -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
Here is my pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyWebApp</groupId>
<artifactId>abcdef</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<name>MavenApp</name>
<description>It is a maven app</description>
</project>
I searched a lot to resolve this error but found no solution for that issue. Please help me to fix this issue as I am very confused on how to fix it.
Edit: After further study, I used mvn gwt:run as an alternative to the command mvn gwt:devmode, but still I got another error on command prompt as given below:
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run (default-cli) on project MyWebApp: The parameters 'runTarget' for goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run are missing or invalid

Without any more information than gwt:devmode, Maven will try to find an appropriate plugin, based on its default settings. It happens that a gwt-maven-plugin exists with org.codehaus.mojo as groupId, fitting in Maven built-in plugin resolution.
But this is not the plugin you're looking for.
You are probably trying to use this one, so just add this to your pom.xml, in the <plugins> section:
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-8</version>
<extensions>true</extensions>
<configuration>
<moduleName>com.example.app.App</moduleName>
</configuration>
</plugin>
Adapting the moduleName if needed.

Well, I was able to solve this issue by copying some dependencies, plugin, and configuration from the pom.xml file (which is generated in the project created by the webAppCreator using maven) to the pom.xml file of my project created in the Eclipse. So, this is my pom.xml file created finally:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyPersonalProject</groupId>
<artifactId>MyPersonalProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<!-- Setting maven.compiler.source to something different to 1.8
needs that you configure the sourceLevel in gwt-maven-plugin since
GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Don't let your Mac use a crazy non-standard encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<!-- ensure all GWT deps use the same version (unless overridden) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.8.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-6</version>
<executions>
<execution>
<goals>
<goal>import-sources</goal>
<goal>compile</goal>
<goal>import-test-sources</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<moduleName>mypackage.MyPersonalproject</moduleName>
<failOnError>true</failOnError>
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use
a different source language for java compilation -->
<sourceLevel>1.8</sourceLevel>
<!-- Compiler configuration -->
<compilerArgs>
<!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
<arg>-compileReport</arg>
<arg>-XcompilerMetrics</arg>
</compilerArgs>
<!-- DevMode configuration -->
<warDir>${project.build.directory}/${project.build.finalName}</warDir>
<classpathScope>compile+runtime</classpathScope>
<!-- URL(s) that should be opened by DevMode (gwt:devmode). -->
<startupUrls>
<startupUrl>MyPersonalProject.html</startupUrl>
</startupUrls>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run this application using maven in the Command Prompt, it ran successfully except showing 2 or 3 warnings in the Command Prompt log. Also, I noticed that the SNAPSHOT generated in the version is different for the pom.xml created by Eclipse as compared to the one created by the maven project on command prompt.

Related

I cannot compile my javafx maven project on Raspberry pi

I created a java project which compiles and runs fine on my mac with "mvn compile". But once I fetch it from gitlab on my Pi it won't compile on linux.
I consulted many pages but none seem to apply to this particular issue.
Can anyone help me? I would be really grateful!
The error:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< SmartMirror:SmartMirror >-----------------------
[INFO] Building SmartMirror 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.816 s
[INFO] Finished at: 2022-07-23T14:54:44+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project SmartMirror: Could not resolve dependencies for project SmartMirror:SmartMirror:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.openjfx:javafx-controls:jar:${javafx.platform}:19-ea+9, org.openjfx:javafx-graphics:jar:${javafx.platform}:19-ea+9, org.openjfx:javafx-base:jar:${javafx.platform}:19-ea+9, org.openjfx:javafx-fxml:jar:${javafx.platform}:19-ea+9: Failure to find org.openjfx:javafx-controls:jar:${javafx.platform}:19-ea+9 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The POM.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SmartMirror</groupId>
<artifactId>SmartMirror</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<mainClass>main.Main</mainClass>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
<javafx.platform>linux</javafx.platform>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>main.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>19-ea+9</version>
<classifier>linux</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>19-ea+9</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
</project>
The module-info.java file:
module SmartMirror {
exports weather to javafx.graphics, javafx.fxml;
exports main to javafx.graphics, javafx.fxml;
opens weather to javafx.graphics, javafx.fxml;
opens main to javafx.graphics, javafx.fxml;
requires javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires transitive javafx.graphics;
requires transitive json;
}
Edit:
Thank you so far for your answers. Though the issue persists. Any more ideas?
I used this command on Raspberry Pi 3B (Raspberry Pi OS lite 32bit) :
mvn -Djavafx.platform=linux-arm32-monocle clean compile
if you use 64bit version :
mvn -Djavafx.platform=linux-aarch64-monocle clean compile

Maven build failure classNotFoundException

It's my first time trying out maven and I can't understand why I keep getting classnotfoundexception every time I am trying to build. This is the error I am receiving:
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< owmapi:owmapi >----------------------------
[INFO] Building OwmAPICase 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) # owmapi ---
[WARNING]
java.lang.ClassNotFoundException: owmapi.Main
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:246)
at java.base/java.lang.Thread.run(Thread.java:832)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.582 s
[INFO] Finished at: 2021-02-28T14:09:17+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project owmapi: An exception occured while executing the Java class. owmapi.Main -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
And this is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>owmapi</groupId> <!-- case.se.ctk -->
<artifactId>owmapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>OwmAPICase</name>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<mainClass>owmapi.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/net.aksingh/owm-japis -->
<dependency>
<groupId>net.aksingh</groupId>
<artifactId>owm-japis</artifactId>
<version>2.5.3.0</version>
</dependency>
</dependencies>
</project>
Everything works fine if i simply run the project as a java application in eclipse but for some reason it won't work with maven. I guess the problem lies in mainClass in my pom but I've tried several solutions to no avail.
I think your main class have some dependencies on the jar mentioned in the pom.xml. You're simply creating a target jar which doesn't have those dependencies included. You need to create the uber/fat jar which include all the relevant dependencies. You can use this following plugin maven-assembly-plugin for creating the target jar.
Assumption: Main.java class is under package owmapi.
<build>
<finalName>owmapi</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>owmapi.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>

Maven including non-defined dependencies

My Maven is failing with the following error:
[ERROR] Failed to execute goal on project sdcf4j-twitch: Could not resolve dependencies for project com.github.twitch4j:sdcf4j-twitch:jar:1.0.9: Failed to collect dependencies at com.github.twitch4j:twitch4j:jar:v0.10.2 -> org.projectlombok:lombok:jar:+: Failed to read artifact descriptor for org.projectlombok:lombok:jar:+: Could not transfer artifact org.projectlombok:lombok:pom:+ from/to jitpack.io (https://jitpack.io): Transfer failed for https://jitpack.io/org/projectlombok/lombok/+/lombok-+.pom 400 Bad Request -> [Help 1]
I already tried completely wiping Intellij IDEA's files, and re-adding the dependencies, which didn't help with the error, but some wrong dependencies, that my IDE displayed.
Of course I already tried without any lombok plugin, (lombok) annotation paths and a mvn clear, but that didn't help either.
The Maven code for that project is the following:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j</artifactId>
<version>1.0.9</version>
</parent>
<groupId>com.github.twitch4j</groupId>
<artifactId>sdcf4j-twitch</artifactId>
<version>1.0.9</version>
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</path>
</annotationProcessorPaths>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- The core module -->
<dependency>
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.twitch4j</groupId>
<artifactId>twitch4j</artifactId>
<version>v0.10.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The Parent Pom does not differ from the original at https://github.com/Bastian/sdcf4j/blob/8f569ee5dc36be09c6595c12833d109b7127c23e/pom.xml.
If one sets up the folders correctly, you can add sdcf4j-twitch as a module in sdcf4j, just like sdcf4j-core,sdcf4j-discord4j in L17
Complete Build log:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.github.twitch4j:sdcf4j-twitch >------------------
[INFO] Building sdcf4j-twitch 1.0.9
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from jitpack.io: https://jitpack.io/org/projectlombok/lombok/+/lombok-+.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.968 s
[INFO] Finished at: 2020-12-10T22:55:31+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project sdcf4j-twitch: Could not resolve dependencies for project com.github.twitch4j:sdcf4j-twitch:jar:1.0.9: Failed to collect dependencies at com.github.twitch4j:twitch4j:jar:v0.10.2 -> org.projectlombok:lombok:jar:+: Failed to read artifact descriptor for org.projectlombok:lombok:jar:+: Could not transfer artifact org.projectlombok:lombok:pom:+ from/to jitpack.io (https://jitpack.io): Transfer failed for https://jitpack.io/org/projectlombok/lombok/+/lombok-+.pom 400 Bad Request -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Maven sonar misconfiguration, maybe missing source directory?

When I do a mvn clean package locally everything works fine. When I do a mvn clean package on the jenkins server I get errors. I am running Jenkins 1.596, Maven 3.2.5, SonarQube 4.5.1, Maven plug-in 2.4 is defined in the Jenkins sonar settings.
This is the output from the Jenkins job.
[INFO] --- sonar-maven-plugin:2.4:sonar (default-cli) # myproject ---
[INFO] SonarQube version: 4.5.1
INFO: Work directory: /var/lib/jenkins/workspace/myporject/target/sonar
[INFO] [22:48:12.147] Base dir: /var/lib/jenkins/workspace/myproject
[INFO] [22:48:12.148] Working dir: /var/lib/jenkins/workspace/myproject/target/sonar
[INFO] [22:48:12.148] Source paths: src
[INFO] [22:48:12.148] Test paths: src/test/java
[INFO] [22:48:12.148] Binary dirs: target/classes
[INFO] [22:48:12.148] Source encoding: UTF-8, default locale: en_US
[INFO] [22:48:12.148] Index files
[ERROR] File [relative=src/test/java/com/blah/web/service.java, abs=/var/lib/jenkins/workspace/myproject/src/test/java/com/blah/web/service.java] can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.4:sonar (default-cli) on project myproject: File [relative=src/test/java/com/blah/web/service.java, abs=/var/lib/jenkins/workspace/myproject/src/test/java/com/blah/web/service.java] can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.4:sonar (default-cli) on project myproject: File [relative=src/test/java/com/blah/web/service.java, abs=/var/lib/jenkins/workspace/myproject/src/test/java/com/blah/web/service.java] can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
It appears that something is missing from my Sonar plug-in settings but I'm not sure what or where to define it.
Here are some snippets from my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blah</groupId>
<artifactId>myproject</artifactId>
<version>99</version>
<packaging>war</packaging>
<name>myproject</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<routePath>${pom.project.build.directory}/routes</routePath>
<spring.release.version>3.2.4.RELEASE</spring.release.version>
<rabbitmq.version>3.1.4</rabbitmq.version>
<spring.amqp.version>1.2.0.RELEASE</spring.amqp.version>
</properties>
<build>
<finalName>myproject</finalName>
<sourceDirectory>src</sourceDirectory>
<scriptSourceDirectory>src/main/java</scriptSourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.8.0-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.1.8-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>GROOVY_DSL_SUPPORT</classpathContainer>
</classpathContainers>
<sourceIncludes>
<sourceInclude>**/*.groovy</sourceInclude>
</sourceIncludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/integration/**/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
The problem seems to be that your source folder is a prefix of your test folder. In other words, if you say that your test folder is src/test/java/, your source folder should be src/main/java, not src since this causes the plugin to find the same class twice, which is what causes the error
Removing <sourceDirectory>src</sourceDirectory> should do the trick since it will use maven's default (src/main/java). While you're at it, remove also testSourceDirectory since you are setting it to the default value, so you don't need it. In general the pom should be as simple as possible since maven is all about convention over configuration

Error running project in eclipse wtih maven "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile" [duplicate]

This question already has answers here:
How to set specific Java version to Maven?
(28 answers)
Closed 8 years ago.
I'm learning google app engine programs with eclipse and maven but I've been stuck on this error since 2 days. I've looked everywhere on the internet but couldn't get a solution to my problem.
Here's the console output
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building helloworld 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> appengine-maven-plugin:1.9.4:devserver (default-cli) > package # helloworld >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # helloworld ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/AdioJack/Developer/Scalable Apps (Udacity)/ud859-master/Lesson_2/000_Hello_Endpoints/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # helloworld ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/AdioJack/Developer/Scalable Apps (Udacity)/ud859-master/Lesson_2/000_Hello_Endpoints/target/helloworld-1.0-SNAPSHOT/WEB-INF/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.462 s
[INFO] Finished at: 2014-09-10T12:34:38+05:30
[INFO] Final Memory: 6M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project helloworld: Fatal error compiling: invalid target release: 1.7 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
and here's the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.google.training.helloworld</groupId>
<artifactId>helloworld</artifactId>
<properties>
<appengine.app.version>1</appengine.app.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<prerequisites>
<maven>3.1.0</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-endpoints</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>1.9.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>1.9.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application-->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.1</version>
<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-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
<!-- the list has a default value of ** -->
<includes>
<include>WEB-INF/*.discovery</include>
<include>WEB-INF/*.api</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<!-- Comment in the below snippet to bind to all IPs instead of just localhost -->
<!-- address>0.0.0.0</address>
<port>8080</port -->
<!-- Comment in the below snippet to enable local debugging with a remove debugger
like those included with Eclipse or IntelliJ -->
<!-- jvmFlags>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n</jvmFlag>
</jvmFlags -->
</configuration>
<executions>
<execution>
<goals>
<goal>endpoints_get_discovery_doc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here's java & maven version information
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T02:28:10+05:30)
Maven home: /usr/local/Cellar/maven/3.2.3/libexec
Java version: 1.8.0_20, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10", arch: "x86_64", family: "mac"
This question is different from
How to set specific java version to Maven
I've only 1 version of java installed i.e. JDK 8
This is the command I ran in terminal to make maven is using latest java version
export JAVA_HOME=$(/usr/libexec/java_home)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project helloworld: Fatal error compiling: invalid target release: 1.7 -> [Help 1]
If you look at the error, its complaining about an JDK7. Make sure you are using correct version of Java to be able to compile the application. You need atleast jdk1.7 (or higher).
As the question is tagged for eclipse, you can also set the available java compilers in the 'installeded JREs' option inside eclipse
Apart from that, you can also set the compliance level inside the pom of the project as below
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source> <!-- or 1.8 -->
<target>1.7</target> <!-- or 1.8 -->
</configuration>
</plugin>
You have to install java 7 for the compile to work, however, java 8 and newer should also work

Categories

Resources