Issue with specifying goal in pom.xml (a Maven project) - eclipse

I have the following code.
I am trying to create a 'pom.xml' file for a bukkit plugin (Minecraft) using Maven.
<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>newestfile.here</groupId>
<artifactId>newestplugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
This gave me the error:
No goals have been specified for this build. You must specify a valid lifecycle phase or a goal
I thus amended the code by adding 3 lines below 'executions', to set a goal which I specified as being 'test', given that I want to run the code and see if I get any errors (i.e., if it works).
However, this gives me the error: 'invalid goal for this plugin: test'.
<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>newestfile.here</groupId>
<artifactId>newestplugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
I would be so grateful for a helping hand!

I changed the version to 3.10.1 and the target to 17 as follows, and the code successfully ran:
<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>newestfile.here</groupId>
<artifactId>newestplugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Thanks so much for all your help!

Related

Maven install-plugin does not generate jars files for Eclipse Projects included as dependencies

I have two Eclipse Maven projects, one of them is referenced by the other project (a dynamic web project) as a dependency. When I export, using Eclipse Export menu, the web project to a war file a jar file is generated for the other project and included in the lib directory in the war file, but when using Maven directly (Run as / Maven Build... / clean install) no jar file is generated but only an empty directory with the name OtherProject.jar.
Can this be done and I am missing some thing, or is it impossible?
My web project pom.xml is:
<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>Group</groupId>
<artifactId>MyWarProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
...
other dependencies
...
<dependency>
<groupId>Group</groupId>
<artifactId>OtherProject</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
My other project pom.xml is:
<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>Group</groupId>
<artifactId>OtherProject</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
some dependencies
...
</dependencies>
</project>

cyclic dependency using the p2-maven-plugin

I 've been using the p2-maven-plugin and I have some problems: it seems to be generating cycling dependencies but I could not find why (the same jars in maven show no problem). I am wondering whether anyone can help.
here 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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.reficio.rcp</groupId>
<artifactId>example-p2-site</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<!-- specify your depencies here -->
<!-- groupId:artifactId:version -->
<artifact><id>org.apache.shiro:shiro-aspectj:1.3.2</id></artifact>
<artifact><id>org.apache.shiro:shiro-core:1.3.2</id></artifact>
<artifact><id>org.apache.shiro:shiro-ehcache:1.3.2</id></artifact>
<artifact><id>net.sf.ehcache:ehcache-core:2.6.9</id></artifact>
<artifact><id>net.sf.ehcache:ehcache:2.9.0</id></artifact>
<artifact><id>commons-logging:commons-logging:1.1.1</id></artifact>
<artifact><id>org.slf4j:slf4j-simple:1.6.1</id></artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>reficio</id>
<url>http://repo.reficio.org/maven/</url>
</pluginRepository>
</pluginRepositories>
here is the cyclic dependency (look for org.apache.shiro.core)
Thanks in advance
K. Apostolou

MapStruct generate code

I'm learning to use MapStruct according to reference guide.
The eclipse verion is
Eclipse Java EE IDE for Web Developers.
Version: Kepler Service Release 2
pom.xml is as below just the same as the reference guide
<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.map</groupId>
<artifactId>MapStruct</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<org.mapstruct.version>1.0.0.Final</org.mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<configuration>
<defaultOutputDirectory>
${project.build.directory}/generated-sources
</defaultOutputDirectory>
<processors>
<processor>org.mapstruct.ap.MappingProcessor</processor>
</processors>
<options>
<mapstruct.suppressGeneratorTimestamp>
true</mapstruct.suppressGeneratorTimestamp>
<mapstruct.defaultComponentModel>cdi</mapstruct.defaultComponentModel>
</options>
</configuration>
<executions>
<execution>
<id>process</id>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
#Mapper
public interface CarMapper {
CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);
#Mapping(source = "name", target = "fullName")
CarDto car2CarDto(Car car);
}
It says that the implement codes would generate when building project. However, it doesn't seem to generate under the target/generated-sources folder
After adding the M2E plug-in, use mvn clean install and the codes are generated.

Failed to execute goal org.wildfly.swarm:wildfly-swarm-plugin:1.0.0.Alpha4:create (default) on project

My pom file looks like below. What else is missing in this pom 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>com.bbbb</groupId>
<artifactId>graph</artifactId>
<version>1.0.0</version>
<name>graph</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-jaxrs</artifactId>
<version>1.0.0.Alpha4</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>1.0.0.Alpha4</version>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The WildFly Swarm plugin needs to be defined as:
<plugins>
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>1.0.0.Alpha8</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

Maven GWT (SmartGWT): How to organize my project to prevent long compilation

Dear StackOverflow Users,
I want to split my huge application written in SmartGWT, compiled by maven, into several subprojects, for example: common, custom-widgets, forms, custom-datasources, sites.
The main idea is: once subproject is compilated by GWT can be easy used in other sub-project to skip compilation again. (sorry for my english, but I think You got my point)
example subproject pom.xml is:
<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>eu.nanobeauty</groupId>
<artifactId>nanobeauty</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>nanoBeauty :: Common</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Common.gwt.xml is :
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.smartgwt.SmartGwtNoTheme"/>
<source path="common"/>
</module>
and the parent pom.xml is:
<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>eu.nanobeauty</groupId>
<artifactId>nanobeauty</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>nanoBeauty :: Parent</name>
<modules>
<module>datasources</module>
<!-- multimodule : each form different project -->
<module>forms</module>
<!-- multimodule : each site different project -->
<module>sites</module>
<module>common</module>
</modules>
<properties>
<gwt.version>2.5.0</gwt.version>
<smartgwt.version>3.1</smartgwt.version>
<java.version>1.6</java.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.war.plugin.version>2.1.1</maven.war.plugin.version>
</properties>
<repositories>
<repository>
<id>smartclient</id>
<url>http://smartclient.com/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>${smartgwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
After long night googling i found solution:
It cannot be done this way I want to achieve.
GWT needs source files to generate JS files. Main module pom.xml is ok and example .gwt.xml file above is also ok. Only change is in sub-module pom.xml files only goal is resources.
So for every submodule I need to setup pom.xml that looks like similar to:
<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>eu.nanobeauty</groupId>
<artifactId>nanobeauty</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>nanoBeauty :: Common</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Based on this documents:
Resources goal
Multimodule project