• maven源码打包


    1.打包时附加外部Jar包

      <!--编译+外部 Jar打包-->
              <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                  <source>1.7</source>
                  <target>1.7</target>
                  <encoding>UTF-8</encoding>
                  <compilerArguments>
                       <extdirs>${project.basedir}/libs</extdirs>
                   </compilerArguments>
                </configuration>
             </plugin>

    2.打包时附加源码
              <!-- 源码打包 -->
                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
               <!-- 完成绑定.执行完打包后执行 -->
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals><goal>jar-no-fork</goal></goals>
                    </execution>
                </executions>
                </plugin>

    3.pom依赖打包
                <!-- 依赖打包 -->
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.5.4</version>
                    <configuration>

          <!--这部分可有可无,加上的话则直接生成可运行jar包-->
                        <!--<archive>
                           <manifest>
                                <mainClass>${exec.mainClass}</mainClass>
                            </manifest>
                        </archive>-->
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                    <executions>  
                      <execution>
                        <id>make-assembly</id>  
                        <phase>package</phase>
                        <goals><goal>single</goal></goals>  
                      </execution>  
                    </executions>
              </plugin>

    打包依赖的class文件命令:

      mvn assembly:assembly

    如果不希望依赖的JAR包变成CLASS

      可以修改ASSEMBLY插件.本地地址一般是 ${user_home}.m2orgapachemavenpluginsmaven-assembly-plugin2.4
      打开此目录下的maven-assembly-plugin-2.4.jar,找到assembliesjar-with-dependencies.xml 把里面的UNPACK改成FALSE即可

  • 相关阅读:
    8/30 sql脚本
    navicat批量添加uuid去重
    循环向JsonArray添加对象
    java String字符串去除()里的内容
    工厂模式
    Thymeleaf学习
    SSH开发常用常见的src下建的包名
    04jQuery操作03
    04jQuery筛选jquery对象02
    04jQuery筛选jquery对象01
  • 原文地址:https://www.cnblogs.com/q924152020/p/8885595.html
Copyright © 2020-2023  润新知