2

我正在使用 maven-webstart-plugin 生成 2 个 JNLP(jnlpA 和 jnlpB),配置为 2 个执行。该项目有2个依赖项:

  • dependencyA.jar (这取决于一些公地和其他如 A1.jar、A2.jar、A3.jar...)
  • dependencyB.jar(这取决于一些公共和其他如 B1.jar、B2.jar、B3.jar...)。

我需要 jnlpA 具有依赖项 dependencyA.jar、commons 和 A1.jar、A2.jar、A3.jar ......以及 jnlpB 依赖项B.jar、commons 和 B1.jar、B2.jar、B3.jar ......我不知道如何使用 maven-webstart-plugin 做到这一点。

我试过这个:

  1. 使用名为“excludeTransitive”的插件属性设置为 false(默认)。在这种情况下,两个 JNLP 都将具有所有依赖项。

  2. 将“excludeTransitive”更改为 true,在这种情况下,JNLP 都将只有 dependencyA.jar 和 dependencyB.jar 作为依赖项。

  3. 将“excludeTransitive”设置为 false(默认),使用选项 exclude 和 include 插件允许在每次执行中使用:

    • 如果我在jnlpA的执行中使用exclude,并且我排除了dependencyB.jar,那么jnlpA仍然具有dependenci B1.jar,B2.jar... IE只排除依赖而不是它的所有传递依赖。
    • 如果我在 jnlpA 的执行中使用了 include,并且我包含了 dependencyA.jar,则不包括 A1.jar、A2.jar...。IE 仅包括此依赖项,而不包括其所有传递依赖项。

所以,我的问题是我需要在执行中包含或排除一个依赖项,但它的所有传递依赖项

当我尝试选项 3 时,我的 pom 示例是:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>MyJnlp</artifactId>
<packaging>pom</packaging>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>webstart-maven-plugin</artifactId>
            <version>1.0-beta-3</version>
            <executions>
                <execution>
                    <id>install-jnlp</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>jnlp-inline</goal>
                    </goals>
                    <configuration>
                        <workDirectory>target/dist</workDirectory>
                        <jnlp>
                            <inputTemplate>src/main/jnlp/jnlpA-template.vm</inputTemplate>
                            <outputFile>jnlpA.jnlp</outputFile>
                            <mainClass>Start</mainClass>
                        </jnlp>
                        <dependencies>
                            <excludes>
                                <exclude>xxx:dependencyB</exclude>
                            </excludes>
                        </dependencies>
                    </configuration>
                </execution>
                <execution>
                    <id>uninstall-jnlp</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>jnlp-inline</goal>
                    </goals>
                    <configuration>
                        <workDirectory>target/dist</workDirectory>
                        <jnlp>
                            <inputTemplate>src/main/jnlp/jnlpB-template.vm</inputTemplate>
                            <outputFile>jnlpB.jnlp</outputFile>
                            <mainClass>Uninstaller</mainClass>
                        </jnlp>
                        <dependencies>
                            <excludes>
                                <exclude>xxx:dependencyA</exclude>
                            </excludes>
                        </dependencies>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <excludeTransitive>false</excludeTransitive><resourcesDirectory>${project.basedir}/src/main/jnlp/resources</resourcesDirectory>
                <jnlp>
                    <inputTemplateResourcePath>${project.basedir}</inputTemplateResourcePath>
                </jnlp>
                <gzip>true</gzip>
                <makeArchive>false</makeArchive>
                <outputJarVersions>false</outputJarVersions>
                <verbose>true</verbose>
                <encoding>ISO-8859-1</encoding>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>xxx</groupId>
        <artifactId>dependencyA</artifactId>
        <version>1.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>xxx</groupId>
        <artifactId>dependencyB</artifactId>
        <version>1.0</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

4

0 回答 0