使用Maven我想创建一个带有自定义扩展名(.bar)的存档文件。我必须在其中包含一个类文件和一个XML文件。
我尝试过以下但无法完成它
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<target>
<echo message="generating document workflow .bar file" />
**I need to copy a .class file and an xml file then build the .bar file.**
<!-- Create a bar file. -->
<zip basedir="${project.build.outputDirectory}" destfile="${project.build.outputDirectory}/document-workflow.bar" />
</target>
</configuration>
</execution>
</executions>
</plugin>
你能指导我吗?
我有另一个要求。基本上,我想要复制到jar的类文件应该在根目录中,而不是在包结构中。
答案 0 :(得分:0)
希望它能解决您的问题:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>bar</id>
<phase>package</phase>
<configuration>
<target>
<echo message="generating document workflow .bar file" />
<!-- flatten files -->
<copy todir="${project.build.directory}/flattened_classes" flatten="true">
<fileset dir="${project.build.outputDirectory}">
<include name="**/*.class"/>
</fileset>
</copy>
<!-- Create a bar file. -->
<zip destfile="${project.build.directory}/document-workflow.bar" >
<fileset dir="${project.build.directory}/flattened_classes">
<include name="**/*.class"/>
</fileset>
<fileset dir="${project.build.directory}">
<include name="yourfile.xml"/>
</fileset>
</zip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>