Maven的EJB的插件。如何从生成的客户端中排除工件?

时间:2013-05-23 06:10:31

标签: java maven

我有一个EJB maven模块。它与编译范围有一些依赖关系。如何从生成的客户端中排除这些依赖项?

<dependencies>
  <dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.2</version>
</dependency>
</dependencies>

 <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ejb-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <generateClient>true</generateClient>
        </configuration>
      </plugin>
    </plugins>
  </build>

1 个答案:

答案 0 :(得分:0)

你可以使用这样的东西来排除传递依赖:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>  <!-- declare the exclusion here -->
          <groupId>sample.ProjectB</groupId>
          <artifactId>Project-B</artifactId>
        </exclusion>
      </exclusions> 
    </dependency>
  </dependencies>
</project>

如果你有这样的依赖,你不喜欢将它打包到你的EJB模块(通常是一个jar文件):

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>

定义scope of the dependency as provided like this

可能很有用
<project>
  ...
  <dependencies>
    <dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

<强>更新 也许你可以尝试使用可选标志:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>
  </dependencies>