When importing an existing Maven project into Eclipse, where is the JDK / JRE being driven from? For example, as per below, on import, its being set to J2SE 1.4 however I want it to be JDK 1.8.
How can I set it in the Maven pom so that when other devs get the project, on import Eclipse will point to JDK 1.8 and not 1.4?
My suggestion is to specify the version of Java from the configuration of the maven-compiler-plugin plugin. Please check the following skeleton.
<?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">
...
<properties>
...
<java.version>1.8</java.version>
...
</properties>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<verbose>true</verbose>
<debug>${debug}</debug>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
...
</plugins>
...
<resources>
...
</resources>
...
</build>
...
</project>
Related
Am creating new java project using the pom.xml file. when i run the command mvn clean install am getting build failure error.
Can anyone please help me to resolve this issue.
and my pom.xml is like this
<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</groupId>
<artifactId>tasapitesting</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tasapitesting</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpversion>1.8</wtpversion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3.9</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Maven Central doesn't seem to have a 3.3.9 build for maven-compiler-plugin (see here). Regardless, the 3.3 generation is quite old. Unless you absolutely, positively have to use such an old version, just move forward to a newer version that actually exists, like 3.6.0, and you should be fine.
I have installed the JBoss AS tools in my eclipse. Then I have created an WildFly 8.0 server. I have parent project pom.xml like below:
<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.company</groupId>
<artifactId>trx-server-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.7</java-version>
<javaee-api-version>7.0</javaee-api-version>
</properties>
<modules>
<module>trx-server-ear</module>
<module>trx-server-domain</module>
<module>trx-server-services</module>
<module>trx-server-web</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${javaee-api-version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<!-- compiler plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.4</version>
<configuration>
<ejbVersion>3.2</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
And ear project pom.xml is like:
<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>com.company</groupId>
<artifactId>trx-server-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>trx-server-ear</artifactId>
<packaging>ear</packaging>
<dependencies>
<dependency>
<groupId>com.company</groupId>
<artifactId>trx-server-web</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.company</groupId>
<artifactId>trx-server-services</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
</dependencies>
<build>
<finalName>trx-server</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<finalName>trx-server</finalName>
<version>7</version>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
<modules>
<webModule>
<groupId>com.company</groupId>
<artifactId>trx-server-web</artifactId>
<contextRoot>/trx-server-web</contextRoot>
</webModule>
<ejbModule>
<groupId>com.company</groupId>
<artifactId>trx-server-services</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
I defined the trx-server-domain module as jar file and packaged into the lib folder. When run mvn clean install on my parent pom.xml, I got an ear file named trx-server.ear. Then the trx-server.ear file structure is like:
-- trx-server
-- lib
-- trx-server-domain-1.0.0.jar
-- trx-server-services-1.0.0.jar
-- trx-server-web-1.0.0.war
I can deploy this ear file to WildFly server manually (via web management page). Everything is fine for that.
My problem is when I deploy some changes via Eclipse, I mean via the server adapter. The root web contextRoot is not what I defined in the ear project pom.xml file. And the trx-server-domain will be deploy as EJB which should be a jar file under lib folder.
I got a trx-server-ear.ear folder in the WildFly deployments directory which is not what I wanted. The structures of this folder is:
trx-server-ear.ear
-- trx-server-domain-1.0.0.jar
-- trx-server-services-1.0.0.jar
-- trx-server-web-1.0.0.war
No lib folder and all jar/war files are in same level.
The problem only exist when I deploy the ear in the Eclipse. Is there any other plungin I should install?
Anyone could give me example of how to configure the ear with multiple modules?
I have a project with a POM that looks like this:
<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>
<artifactId>my-parent</artifactId>
<groupId>com.company</groupId>
<version>2</version>
</parent>
<groupId>com.company</groupId>
<artifactId>resources-silo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ejb</packaging>
<name>Some EJB component</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>simple-command</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- some jars ... -->
</dependencies>
</project>
I want to use m2eclipse with m2e-wtp to deploy this project to Glassfish 3. However, m2e-wtp does not deploy the dependencies. I know that building superjars with jar-with-dependencies is probably not the way to go for EJB projects, but I cannot really change this without messing up the customer's build / deployment processes.
So, the problem is that the deployment assembly wizard does not display the maven dependencies:
I need a solution that works without changing the pom.xml, since that would disturb the customer's build processes. I am aware that using an EAR would be the preferred solution here.
Is the behaviour that I'm seeing a bug or is it an inherent limitation in the way m2e-wtp and the ejb packaging work?
Is it even possible to have m2e-wtp extract dependency jars into the deployed application?
I have a maven project with 1 parent and 5 modules. One of the modules (call it P) is of packaging "maven-plugin", which is configured to be run in the execution phase "process-test-classes of other module (call it T).
The module T has pom.xml as follows. I omitted dependencies, but they don't include P. As in many other cases it all works perfectly in command line.
Question: Whatever I do Eclipse shows "Could not find artifact org.local.enhancer:pom:0.0.2-SNAPSHOT pom.xml /test line 1 Maven Configuration Problem".
Seems like the issue started after installing "m2e-wtp" v0.17 to resolve other issue with offending jars. Configuration is Eclipse Juno SR2, m2e v1.3.1, m2e-wtp v0.17.
<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>
<artifactId>parent</artifactId>
<groupId>org.local</groupId>
<version>0.0.2</version>
<relativePath>..</relativePath>
</parent>
<artifactId>test</artifactId>
<dependencies>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.local</groupId>
<artifactId>enhancer</artifactId>
<version>0.0.2-SNAPSHOT</version>
<executions>
<execution>
<phase>process-test-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Does anybody have any insight on this? Thanks!
I installed m2eclipse plugin in my eclipse.I have a java project in eclipse. Then I add a pom.xml into the root folder of my project. Convert my project into maven project. Now the problem comes: I can download jar contained in pom.xml, but can't import it into my java file.
Always got java compile error in my project. In package explorer view,I can see maven dependencies.
I have tried this:maven clean, restart eclipse, project clean.
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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TomLabs</groupId>
<artifactId>TomLabs</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<description>Tom source code</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.media</groupId>
<artifactId>jmf</artifactId>
<version>2.1.1e</version>
</dependency>
</dependencies>
</project>
One possibility could be the package/class what you are trying to import is not available in the version of the jar file you have mentioned in the pom.xml.