I’ve used a Maven archetype (webapp-javaee6) to create a new Java EE 6 project but don’t understand why certain things are put inside the build element of the POM. To be specific I don’t understand why the javaee-endorsed-api.jar is copied over to the endorsed directory. According to the answer to this question, this is needed for compilation but my project compiles fine when I remove the related plugin element under build.
Since javax:javaee-web-api is already provided as a dependency in the POM, can this not be used for compiling?
<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>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
It should compile, because there is also a dependency to this artifact:
Maven manual page describes provided as follows:
So in my opinion copying this dependency has no impact on compiling.
However archetype’s author wanted for some reason to copy Java EE 6 API package to endorsed directory. This might be helpful if you decide to start Jetty server and do some testing in “Test Phase” (for example with JUnit).
If you’re not using it – just remove it.