I want to change the path of my target folder in maven. I am using C:/plugins but when I am updating my maven project I am getting An internal error occurred during: "Updating Maven Project". Path must include project and resource name: /ProjectName
<build>
<directory>/your/directory</directory>
</build>
Change in your pom.xml.
You should use profiles.
<profiles>
<profile>
<id>otherOutputDir</id>
<build>
<directory>yourDirectory</directory>
</build>
</profile>
</profiles>
Related
i have a Maven multi project with several modules in the pom.xml.
But for the sonar-Scan i want to use other modules (includes and excludes)!
The property-file (sonar-project.properties) is not used in Maven-Projects, so the properties sonar.modules and xxx.sonar.projectBaseDir are not working.
How can i configure it with Maven?
You can use Maven profiles to include only specific modules: http://maven.apache.org/guides/introduction/introduction-to-profiles.html
Example:
<profiles>
<profile>
<id>all</id>
<modules>
<module>module-A</module>
<module>module-B</module>
<module>module-C</module>
</modules>
</profile>
<profile>
<id>sonar</id>
<modules>
<module>module-A</module>
<module>module-C</module>
<module>module-D</module>
</modules>
</profile>
</profiles>
Execute mvn -Psonar clean package sonar:sonar
I have a maven project, but the father and son structure, I would like to perform mvn package in the parent structure at the same time want to specify the sub-project pom.xml file profile an id
You can define the sub-project module in your parent pom file profile as below:
<profiles>
<profile>
<id>all-deps</id>
<modules>
<module>sub-project</module>
</modules>
</profile>
</profiles>
Now you can use following maven commands to include the sub-project from parent
mvn package --activate-profiles all-deps
EDIT: I've just updated my Eclipse installation from Kepler to Luna - all of my Maven projects were running fine before the update
I am receiving the error which is preventing my Maven project from installing:
The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.5.1 is missing, no dependency information available
And when I navigate to Maven's Lifecycle Mapping in Eclipse I see
compiler:compile | error
compiler:text Compile | error
I have maven-compiler-plugin:jar:3.1 (including the POM file) in my .m2 repository and would like to use that instead.
How could this be configured in Eclipse? Alternatively, if this is not the solution to the problem, how could this be resolved?
You need to edit your pom.xml to set the version of the compiler plugin to be used. As described on the plugin's homepage, you configure the maven-compiler-plugin in the build-section of your project's pom.xml like so:
<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>
If you want to use the local repository of your Maven installation (instead of Eclipse's embedded version), go to Preferences -> Maven -> Installations and add your Maven installation there.
I have a project bird with the following components in pom.xml
<groupId>com.myorg</groupId>
<artifactId>bird</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>bird</name>
<modules>
<module>persistence</module>
<module>business</module>
<module>service</module>
<module>web</module>
</modules>
and the web module pom.xml
<parent>
<artifactId>bird</artifactId>
<groupId>com.myorg</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>web</artifactId>
<packaging>war</packaging>
The web module creates a war file named web-1.0-SNAPSHOT.war
How can I configure maven to build it as bird.war?
You can use the following in the web module that produces the war:
<build>
<finalName>bird</finalName>
. . .
</build>
This leads to a file called bird.war to be created when goal "war:war" is used.
You need to configure the war plugin:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>bird.war</warName>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
More info here
Lookup pom.xml > project tag > build tag.
I would like solution below.
<artifactId>bird</artifactId>
<name>bird</name>
<build>
...
<finalName>${project.artifactId}</finalName>
OR
<finalName>${project.name}</finalName>
...
</build>
Worked for me. ^^
You can follow the below step to modify the .war file name if you are using maven project.
Open pom.xml file of your maven project and go to the tag <build></build>,
In that give your desired name between this tag :
<finalName></finalName>.
ex. : <finalName>krutik</finalName>
After deploying this .war you will be able to access url with:
http://localhost:8080/krutik/
If you want to access the url with slash '/' then you will have
to specify then name as below:
e.x. : <finalName>krutik#maheta</finalName>
After deploying this .war you will be able to access url with:
http://localhost:8080/krutik/maheta
I have a war artefact and I need use some of their classes from a jar.
I can't move the classes to another project, then I deploy the classes and resources included in my webapp as an "attached" artifact using the following configuration:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
This will result in two artifacts being deployed: mywebapp-1.0-SNAPSHOT.war and mywebapp-1.0-SNAPSHOT-classes.jar.
To use those classes I Referencing the artifact as follows:
<dependency>
<groupId>mygroup</groupId>
<artifactId>mywebapp</artifactId>
<version>${project.version}</version>
<classifier>classes</classifier>
</dependency>
When I compiled from Jenkins everything works correctly, but when I run the tests locally from Eclipse can not find the reference classes. (java.lang.NoClassDefFoundError)
I think it might be a bug in the maven eclipse plugin, someone has any idea that can be happening?
Workaround is described on http://wiki.eclipse.org/M2E-WTP_FAQ:
A workaround exists though, we need to change the dependency whether the project is built in Eclipse or not. In your dependent project, you can configure the following :
<dependencies>
...
<dependency>
<groupId>com.company</groupId>
<artifactId>mywebapp</artifactId>
<version>1.0.0-SNAPSHOT</version>
<classifier>${webClassifier}</classifier>
</dependency>
...
</dependencies>
...
<properties>
...
<webClassifier>classes</webClassifier>
</properties>
...
<profiles>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<webClassifier></webClassifier>
</properties>
</profile>
</profiles>
The m2e profile is automatically activated when the project is built with m2e, ignored in other circumstances. In that case only, the dependent project will use an empty classifier to reference the web project, which will be added to the classpath as expected.
My simple answer is the following link to the bug tracking system of Eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=365419
See the answers inside.
Yes it's a problem with Eclipse itself..
The solution within Eclipse just add the project manually within your workspace to the appropriate project where you need the classes out of your war project.