0

所以我使用的是 WAS8.5,我需要在我的项目中包含 WAS 库。我试过这个...

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <archive>
          <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addClasspath>true</addClasspath>
          </manifest>
          <manifestEntries>
              <Class-Path>C:\Program Files (x86)\IBM\WebSphere\AppServer\plugins</Class-Path>
              <Class-Path>C:\Program Files (x86)\IBM\WebSphere\AppServer\java\jre\lib</Class-Path>
          </manifestEntries>
      </archive>
    </configuration>
</plugin>

但我仍然看到...

错误:包 javax.jms 不存在

尽管...

二进制文件 ./plugins/javax.j2ee.jms.jar 匹配

但这似乎不适用于 mvn 包,所以我的问题是 2 折

1.)我应该使用 mvn package 还是 mvn jar:jar 因为后者似乎无法识别我的类的存储位置。如果我应该使用 jar 如何包含源目录。

2.) 如果我使用包,如何在类路径中包含该文件夹?

4

2 回答 2

1

我猜你在谈论编译时问题而不是运行时问题。清单信息用于运行时,您正确配置它的方式使其仅对您的系统有用。Apache Maven 是关于可预测的构建,这意味着您必须定义每个依赖项而不是定义库文件夹。您应该“安装”所需的 jar 到您的本地存储库(安装实际上是一个副本)。见http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

于 2013-09-20T20:34:42.627 回答
0

我发现自动化构建而不用命令行打扰的最佳解决方案是使用 maven-install-plugin 从我的 pom.xml 安装:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>2.2</version>
            <executions>                    
                <execution>
                    <id>proguard</id>
                    <inherited>false</inherited>
                    <phase>validate</phase>
                    <configuration>
                        <file>${pom.basedir}/lib/proguard-4.8.jar</file>
                        <repositoryLayout>default</repositoryLayout>
                        <groupId>net.sf.proguard</groupId>
                        <artifactId>proguard</artifactId>
                        <version>4.8</version>
                        <packaging>jar</packaging>
                        <generatePom>true</generatePom>
                    </configuration>
                    <goals>
                        <goal>install-file</goal>
                    </goals>
                </execution>
           </plugin>

所以我将我的 jar 放入 $PROJECT_HOME/lib 文件夹并将这个执行添加到验证阶段,以便它安装在每个 maven 执行上。

这是很多文本,但它完全自动化了其他机器上的构建。

于 2013-09-23T13:50:04.377 回答