Skip to content

catalpas/catalpa-assembly-descriptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

catalpa-assembly-descriptor

自定义的打包描述,分为两个描述文件updatestandalone

update

update只会将项目打成jar包然后将项目和依赖包统一的复制到lib文件夹下,将配置文件既Resoures中的文件复制到config文件夹中

standalone

standaloneupdate的基础上增加两个文件夹binlogs,分别用来保存可运行文件和日志,其中bin文件夹将拷贝项目中src/main/bin目录中的内容。logs文件夹自动生成

如何使用

pom.xml中加入

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>3.1.1</version>
    <dependencies>
        <dependency>
            <groupId>com.github.catalpas</groupId>
            <artifactId>catalpa-assembly-descriptor</artifactId>
            <version>0.0.1</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <id>xry-assemble</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <descriptorRefs>
            <descriptorRef>catalpa-assembly-update</descriptorRef>
        </descriptorRefs>
    </configuration>
</plugin>

然后运行mvn clean package

more

既然本插件会将resoures文件夹下的文件拷贝到config文件夹,那么在生成的jar文件中就不需要包含任何的配置文件了,可以添加下面的内容来避免配置文件冲突。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <addMavenDescriptor>false</addMavenDescriptor>
            <index>true</index>
            <manifest>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
        </archive>
        <excludes>
            <exclude>**/**.properties</exclude>
            <exclude>**/**.xml</exclude>
            <exclude>**/**.yml</exclude>
        </excludes>
    </configuration>
</plugin>

这一段的内容会将所有propertiesxmlyml文件剔除,如果在实际应用中有用到别的配置文件请自行添加