2

我正在使用 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 库。

关于我可能遗漏或做错了什么的任何想法?

4

1 回答 1

0

经过大量的试运行后,我能够自行解决问题。该解决方案使用配置maven-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>

希望这可以帮助。

于 2012-07-25T03:27:09.250 回答