I have issues building my maven project. It requires building two jars - one of them is built by default maven-jar-plugin which just contains the complied class folders of my Java code and the other, customized one made by maven-assembly-plugin in package phase is an executable jar with all the dependency jars added.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-
plugin:2.2-beta-5:single (executable-jar-generation) on project enhanced-
search: Execution executable-jar-generation of goal
org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single failed: For
artifact {com.fmr.es:enhanced-search:1.0:jar}: An attached artifact must
have a different ID than its corresponding main artifact. -> [Help 1]
I've been following Manually attach main artifact if built by maven-assembly-plugin as reference since the problem is more or less same.
As the answer says, I add the ant-plugin code which overwrites my main jar with the executable one to install on the repository with the package phase.
But before maven even reaches this plugin, the above error crops up. I can't do the vice-versa since there has to be the executable jar created in the first place to overwrite the main one.
Anymore feedback is really appreciated.
The following is the assembly plugin which creates my executable jar along with the assembly.xml
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<id>executable-jar-generation</id>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>executable-enhanced-search-1.0</finalName>
<descriptors>
<descriptor>assembly-jar.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-
plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven
assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-
1.1.2.xsd">
<baseDirectory>/</baseDirectory>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>../../target/classes</directory>
<includes>
<include>**/*</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>
The following is the tailored ant task as mentioned in the link I posted above.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<copy file="../../target/executable-enhanced-search-
1.0.jar" tofile="../../target/enhanced-search-
1.0.jar" overwrite="true" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>