I've got my project structured as such:
Here is the plugin element I'm using for the maven-war-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<packagingExcludes>webapp/resources/styleguide</packagingExcludes>
</configuration>
</plugin>
My end-goal is to include the styleguide dir when publishing to a local Tomcat server, but when packagin a WAR file using "mvn package" the styleguide will be excluded.
Am I going about this the wrong way? Is there more info I can provide to portray what I'm doing more clearly?
Related
I have Maven Problems warning in Eclipse, because of my pom.xml war-plugin configuration.
The project has multi modules. The hierarchy is here:
Project hierarchy
I need to pack content of specific directory (webapp in module2) to module. The main part of top pom.xml configuration is here:
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<webResources>
<resource>
<directory>../module2/src/main/webapp</directory>
</resource>
</webResources>
<packagingExcludes>**/*.db,**/*.scss,**/*.example,**/abrepository/**,,**/abconnection.xml</packagingExcludes>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
The main part of module configuration is here:
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>modul</warName>
</configuration>
</plugin>
</plugins>
With this war-plugin config I have this warning which I want to exlude:
***module\..\module2\src\main\webapp" directory outside of project base directory. (org.apache.maven.plugins:maven-war-plugin:3.2.0:war:default-war:package) pom.xml /module line 1 Maven Build Participant Problem
Can I get rid of it, or can I add the content of the folder (webapp) to .war package in different way?
Thanks for any help.
Unlike the overwriting version warning, where on can add a comment "$NO-MVN-MAN-VER$" after the version, there does not seem to exist an elegant solution to this problem so far.
The only thing you can do (and I did in my case) is to disable "Maven Build Participant Problems" alltogether:
Problems View -> Arrow down button in the tor-right corner
"Configure Contents"
In your active config, deactivate within "Maven Problems" the check box "Maven Build Participant Problems"
I build my project with mvn clean install, however I want to generate a subfolder in the target folder and put the generated jar file in there. I saw these two questions Maven: specify the outputDirectory only for packaging a jar? and maven: how to place the output jar into another folder however their answer doesn't seem to work.
This is how my maven build looks like:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>${project.build.directory}/blah</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
However I get the .jar file still in target directory. I also noticed that the project packaging is set as <packaging>eclipse-plugin</packaging> if I change this to jar, then it works fine, however I do need it to be eclipse-plugin. I am also using tycho for the eclipse plugin. Am I missing something that was not mentioned before?
From your packaging of eclipse-plugin I'm guessing you're using Tycho. Tycho doesn't seem to use any of the maven plugins, so configuring the maven-jar-plugin isn't going to help. Instead try configuring the tycho-packaging-plugin, specifically the buildDirectory property:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<buildDirectory>${project.build.directory}/blah</buildDirectory>
</configuration>
</plugin>
It seems Maven keep using use an old version of my code when packaging a war archive.
I build my war using a simple "mvn clean install".
I deleted the /target folder by hand and checked that there were no .class elsewhere in my project (as described here).
Each time I check the generated archive, an old version of my code has been packaged inside. Yet, the same code is properly packaged on my colleague's machine (he uses m2e).
Does anyone have the same problem ?
Here is the most relevant part of the POM:
<packaging>war</packaging>
...
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</build>
It appears that the old code is still present somewhere; my guess would be your local repository. Try deleting any entry there that could contain the old code and then building your project again.
Check the <dependency> entry in pom.xml for that jar file. Change the <version> of that dependency to the latest one.
What I do is:
Create a new project with IntelliJ with Maven module.
Add Framework support to this project and pick: JSF.
Go to pom.xml and add: packaging: war.
And from Maven window in IntelliJ I click: Clean Install.
Well build fails, because maven is looking for a webapp directory instead of a directory called web. For building the project.
So, if I rename the folder web to webapp build goes fine.
However, I want to learn more about IntelliJ and maven, so I want to force maven to use the folder web. How can I properly do this
Using the command line? I mean without invvolving IntelliJ at all?
Using Intellij?
Regards.
You can configure this in the pom.xml file for your project.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>web</warSourceDirectory>
</configuration>
</plugin>
</plugins>
You can find the documentation here
If IntelliJ behaves as expected, it should pick up this new configuration.
Have a look at this post, which explains how to change the default webapp directory:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>web</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
I've got the maven-enunciate-plugin integrated so that it generates documentation during the build and outputs it to the docs directory under the target directory. As I'm new to Maven I would like to know what would be the ideal way to configure my build so that it packages the docs directory into the WAR artifact of my build. Currently it is left outside of the WAR.
Thanks,
Mike
Please take a look at this and this
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<!--
Exclude JCL and LOG4J since all logging should go through SLF4J.
Note that we're excluding log4j-<version>.jar but keeping
log4j-over-slf4j-<version>.jar
-->
<packagingExcludes>
WEB-INF/lib/commons-logging-*.jar,
%regex[WEB-INF/lib/log4j-(?!over-slf4j).*.jar]
</packagingExcludes>
<packagingIncludes>
**/docs
</packagingIncludes>
</configuration>
</plugin>
</plugins>
</build>
...
</project>