Maven install-plugin不会为包含作为依赖项的Eclipse Projects生成jar文件

时间:2017-11-20 19:34:46

标签: eclipse maven

我有两个Eclipse Maven项目,其中一个由另一个项目(动态Web项目)作为依赖项引用。当我使用Eclipse Export菜单导出web项目到war文件时,会为另一个项目生成一个jar文件,并将其包含在war文件的lib目录中,但直接使用Maven时(运行为/ Maven Build ... / clean install)没有生成jar文件,只有一个名为OtherProject.jar的空目录。

可以这样做,我遗失了一些东西,或者这是不可能的?

我的网站项目pom.xml是:

<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>
  <groupId>Group</groupId>
  <artifactId>MyWarProject</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.44</version>
    </dependency>

    ...
    other dependencies
    ...

    <dependency>
      <groupId>Group</groupId>
      <artifactId>OtherProject</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>
</project>

我的另一个项目pom.xml是:

<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>
  <groupId>Group</groupId>
  <artifactId>OtherProject</artifactId>
  <version>1.0</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <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>
        <configuration>
          <archive>
            <manifestFile>src/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    ...
    some dependencies
    ...
  </dependencies>
</project> 

0 个答案:

没有答案