【问题标题】:Difference in Maven release:prepare and install jars when using jythonMaven 发布的区别:使用 jython 时准备和安装 jars
【发布时间】:2012-07-24 03:14:10
【问题描述】:

我正在使用 Maven 3.0.4 以及 Jython 2.5.2 和 Pygments 1.5(通过鸡蛋)。我已将 jython-compile-maven-plugin 配置为,

<plugin>
<groupId>net.sf.mavenjython</groupId>
<artifactId>jython-compile-maven-plugin</artifactId>
<version>1.2</version>
<executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>jython</goal>
        </goals>
    </execution>
</executions>
<configuration>
    <libraries>
        <!-- Install the latest pygments library -->
        <param>Pygments</param>
    </libraries>
</configuration>

运行 mvn install 创建的 JAR 包含嵌入在 Lib 文件夹中的 Pygments 库。这可以确保我的所有代码都能正常工作。

当我运行 mvn release:prepare 命令时,问题就开始了。在这种情况下,只有我的代码进入 JAR,Pygments 库被排除在外。如果我查看 target/classes 文件夹,它包含我的代码和所需的 pygments 库。

知道我可能遗漏了什么或做错了什么吗?

【问题讨论】:

    标签: maven jython maven-release-plugin


    【解决方案1】:

    经过多次测试和试运行后,我能够自行解决问题。该解决方案使用配置 ma​​ven-jar-plugin 以包含 target/classes 文件夹中的所有文件。这样,installrelease:prepare 目标都会构建完全相同的二进制文件。

    <plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <includes>
            <include>**</include>
        </includes>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
    </plugin>
    

    我用于项目的整个构建条目如下:

    <build>
    <plugins>
        <!-- set compilation properties -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    
        <!-- Generate the project-javadoc.jar for OSS repository -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.8.1</version>
        </plugin>
    
        <!-- Generate the project-sources.jar for OSS repository -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1.2</version>
        </plugin>
    
        <!-- Install Jython and Pygments library -->
        <plugin>
            <groupId>net.sf.mavenjython</groupId>
            <artifactId>jython-compile-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>jython</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <libraries>
                    <!-- Install the latest pygments library -->
                    <param>Pygments</param>
                </libraries>
            </configuration>
        </plugin>       
    
        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <includes>
                    <include>**</include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </build>
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      • 1970-01-01
      • 2012-12-27
      • 2012-10-18
      • 1970-01-01
      相关资源
      最近更新 更多