如何使用Maven创建可执行JAR而不包含3PP依赖项?

时间:2015-12-01 14:51:18

标签: java maven-2 build-process build-automation executable-jar

我想将我的项目打包在一个可执行的JAR中。问题是我想要执行任何3PP而只是因为许可问题而交付我的项目。我有依赖于另一个项目来构建这个独立的实例。但是当我跑步时,Maven会给我错误信息 “mvn clean install assembly:assembly” Pom.Xml看起来像这样:

http://maven.apache.org/xsd/maven-4.0.0.xsd“>     4.0.0

<groupId>se.ect.apc</groupId>
<artifactId>ect-app-validator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>AppValidator</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Build-Time>${maven.build.timestamp}</Build-Time>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>se.ect.main.EctMain</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Build-Time>${maven.build.timestamp}</Build-Time>
                    </manifestEntries>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <appendAssemblyId>false</appendAssemblyId>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
                <argLine>-XX:-UseSplitVerifier</argLine>
            </configuration>
        </plugin>
        <!-- -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>se.ect</groupId>
        <artifactId>ect-core</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.1.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jxr-plugin</artifactId>
            <version>2.3</version>
        </plugin>
        <!-- exists in apache parent -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.9.1</version>
            <configuration>
                <show>private</show>
                <nohelp>true</nohelp>
                <excludes>**/AppTest.java,**/ParserTestBase.java,**/Test*.java</excludes>
                <excludePackageNames>se.ect.mom.testtools</excludePackageNames>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-3</version>
            <inherited>true</inherited>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <linkXRef>false</linkXRef>
                <sourceEncoding>utf-8</sourceEncoding>
                <minimumTokens>100</minimumTokens>
                <targetJdk>1.8</targetJdk>
                <!-- <excludes> <exclude>**/Test*.java</exclude> </excludes> -->
                <excludeRoots>
                    <excludeRoot>target</excludeRoot>
                </excludeRoots>
            </configuration>
        </plugin>
    </plugins>
</reporting>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.6</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

0 个答案:

没有答案