English 中文(简体)
不同的单体和试验。 jar
原标题:Different MANIFEST.MF for default jar-file and tests.jar

I m 试图创建不同的MANIFEST.MF文档,用于封闭包装的工艺品和测试包。 <代码>maven-jar-plugin 正在用于在<代码>上添加斜体。 MANIFEST.MF——迄今为止,这项工作非常出色。 但是,如果我选择了测试项目的不同模板文件MANIFEST.MF, 仅仅使用两种手法的第二个参考模板......

如何利用<条码>PROD-MANIFEST.MF-template用于正常包装和TEST-MANIFEST.MF-template用于测试-jar-包装?

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
            <execution>
                <id>test-manifest-mf</id>
                <phase>package</phase>
                <goals>
                    <goal>test-jar</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                </manifest>
                <manifestFile>foo/TEST-MANIFEST.MF</manifestFile>
            </archive>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
            <execution>
                <id>default-manifest-mf</id>
                <phase>package</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                </manifest>
                <manifestFile>foo/PROD-MANIFEST.MF</manifestFile>
            </archive>
        </configuration>
    </plugin>
问题回答

各位在简介中提供的每个原始构造。

<profiles>
  <profile>
    <id>PROD</id>
    <build>
      <plugins>
        // your PROD plugin configuration
      </plugins>
    </build>
  </profile>
  <profile>
    <id>TEST</id>
    <build>
      <plugins>
        // your TEST plugin configuration
      </plugins>
    </build>
  </profile>
</profiles>

然后,你援引Maven, 说明

mvn package -P PROD

希望会有所帮助。

为此:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <executions>
      <execution>
        <id>test-manifest-mf</id>
        <phase>package</phase>
        <goals>
            <goal>test-jar</goal>
        </goals>
        <configuration>
          <archive>
            <manifest>
                <addClasspath>true</addClasspath>
            </manifest>
            <manifestFile>foo/TEST-MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </execution>

      <execution>
        <id>default-manifest-mf</id>
        <phase>package</phase>
        <goals>
            <goal>jar</goal>
        </goals>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
            <manifestFile>foo/PROD-MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>

This configuration is performing 2 different executions of the same plugin, each of which has its own archive configuration.

如果在您的级别上出现某种母子 p,其档案在处决之外配置,例如:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
    <archive>
       ... other archive config ...
    </archive>
  </configuration>
</plugin>

然后,该组合将与你违约时的组合合并。 如果您不希望做到这一点,则添加<条码>combine. Self 等内容:<archive>:

<archive combine.self="override">

http://maven.apache.org/pom.html#Plugins"rel=“nofollow”的插图部分,POM参考资料。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签