1. Maven 配置
<!--如果需要进行文件复制操作时,需要引入antrun 插件,并在Package 周期前执行该操作,这样才能将文件一起打包--> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>prepare-package</phase> <configuration> <tasks> <copy file="src/main/resources/config.properties" todir="${basedir}/target"/> <copy file="src/main/resources/log4j.properties" todir="${basedir}/target"/> <copy file="run.bat" todir="${basedir}/target"/> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
<!--需要引入Assembly 插件 --> <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>distro-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>src/assemble/bin.xml</descriptor> </descriptors> </configuration> </execution> </executions> |
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd"> <id>bin</id> <formats> <format>tar.gz</format> </formats> <includeBaseDirectory>false</includeBaseDirectory><dependencySets> <dependencySet> <useProjectArtifact>true</useProjectArtifact> <outputDirectory>lib</outputDirectory><!-- <includes> <include>${project.groupId}:${project.artifactId}</include> </includes> --> <scope>runtime</scope> </dependencySet> </dependencySets> <fileSets> <fileSet> <directory>${project.build.directory}/lib</directory> <outputDirectory>lib</outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> <fileSet> <directory>${project.build.directory}/</directory> <outputDirectory></outputDirectory> <includes> <include>*.properties</include> <include>*.bat</include> </includes> </fileSet> </fileSets></assembly> |