Maven plugin插件---appassembler-maven-plugin快速配置

Maven plugin插件---appassembler-maven-plugin快速配置

使用appassembler-maven-plugin 打包自定义目录

1.Pom中添加

    <plugin>
        <artifactId>maven-resources-pluginartifactId>
        <executions>
            <execution>
                <id>copy-resourcesid>
                <phase>packagephase>
                <goals>
                    <goal>copy-resourcesgoal>
                goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/${project.name}/classesoutputDirectory>
                    <resources>
                        <resource>
                            <directory>${project.build.directory}/classesdirectory>
                            <filtering>falsefiltering>
                        resource>
                    resources>
                configuration>
            execution>
        executions>
    plugin>
    <plugin>
        <groupId>org.codehaus.mojogroupId>
        <artifactId>appassembler-maven-pluginartifactId>
        <version>2.0.0version>
        <configuration>
            
            <platforms>
                <platform>windowsplatform>
                <platform>unixplatform>
            platforms>
            
            <assembleDirectory>${project.build.directory}/${project.name}assembleDirectory>
            
            <repositoryName>librepositoryName>
            
            <binFolder>binbinFolder>
            
            <repositoryLayout>flatrepositoryLayout>
            <encoding>UTF-8encoding>
            <logsDirectory>logslogsDirectory>
            <tempDirectory>tmptempDirectory>
            <programs>
                <program>
                    
                    <mainClass>org.ko.web.ApplicationmainClass>
                    <jvmSettings>
                        <extraArguments>
                            <extraArgument>-serverextraArgument>
                            <extraArgument>-Xmx2GextraArgument>
                            <extraArgument>-Xms2GextraArgument>
                        extraArguments>
                    jvmSettings>
                program>
            programs>
        configuration>
    plugin>

2.修改启动的主类-对应自己的main入口

    
    <mainClass>org.ko.web.ApplicationmainClass>

3.使用maven命令打包

    mvn clean package appassembler:assemble

4.修改
- {project.name}/target/{project.name}/bin/application.bat
- 找到CLASSPATH, 在后面添加:”%BASEDIR%”\classes;

    set CLASSPATH="%BASEDIR%"\classes;...

5.启动:{project.name}/target/{project.name}/bin/application.bat

6.错误
- 命令行过长–set CLASSPATH时REPO有可能过多, 这里使用通配符

    set CLASSPATH="%BASEDIR%"\classes;"%REPO%"\*;

7.GitHub demo
Demo: appassembler-maven-plugin简单Demo

8.参考
maven: 用appassembler-maven-plugin打包含有自定义目录的JAVA程序

posted @ 2018-01-03 15:50 eat.u 阅读( ...) 评论( ...) 编辑 收藏

你可能感兴趣的:(Maven plugin插件---appassembler-maven-plugin快速配置)