zoukankan      html  css  js  c++  java
  • 【maven】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即可

  • 相关阅读:
    Oracle select for update and for update nowait
    Oracle DML , DDL , DCL
    Shell变量的作用域:Shell全局变量、环境变量和局部变量
    Shell脚本的调试方法
    openlayers6地图全图以及框选截图导出功能(附源码下载)
    Markdown基本语法
    sql 四大排名函数---(ROW_NUMBER、RANK、DENSE_RANK、NTILE)简介
    Newtonsoft.Json 去掉
    辽宁软考报名地址
    burp suite professional安装及使用教程
  • 原文地址:https://www.cnblogs.com/shangxiaofei/p/10374443.html
Copyright © 2011-2022 走看看