什么在Maven发布期间制作* sources.jar?

时间:2014-10-10 17:55:49

标签: maven maven-release-plugin

我确信我的插件中没有maven-source-plugin,但是[project-name] -sources.jar总是在发布期间构建:执行。在构建生命周期的其他阶段似乎没有这样做。

不幸的是,这个[project-name] -sources.jar被上传到我们的存储库(Nexus)。管理层希望所有来源都保存在SVN中,远离存储库。

我该怎么做?这肯定不是装配问题。我们尝试了不同的构建配置文件,但[project-name] -sources.jar仍然存在。我们只是不希望在发布期间将任何源代码上传到存储库。

任何想法?

提前致谢。

以下是我们在标签中使用的所有内容:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>

        <!-- Release Reference: http://maven.apache.org/maven-release/maven-release-plugin/index.html -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.4.2</version>
            <configuration>
                <tagBase>http://some.url.here</tagBase>
                <checkModificationExcludes>
                    <checkModificationExclude>.classpath</checkModificationExclude>
                    <checkModificationExclude>.factorypath</checkModificationExclude>
                    <checkModificationExclude>.project</checkModificationExclude>
                    <checkModificationExclude>.rest-shell.log</checkModificationExclude>
                    <checkModificationExclude>.springBeans</checkModificationExclude>
                    <checkModificationExclude>.apt-generated/**</checkModificationExclude>
                    <checkModificationExclude>.settings/**</checkModificationExclude>
                    <checkModificationExclude>src\main\resources\rebel.xml</checkModificationExclude>
                </checkModificationExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin> 
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <archive>
                    <index>true</index>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                    <manifestEntries>
                        <version>${project.version}</version>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

    </plugins>
</build>

2 个答案:

答案 0 :(得分:2)

简单的回答是,在发布运行期间,maven-sources-plugin附加到构建生命周期(包阶段),该属性由属性performRelease激活。这在super-pom which defines this are a profile.

中定义

这是超级pom的适当部分:

  <profiles>
    <!-- NOTE: The release profile will be removed from future versions of the super POM -->
    <profile>
      <id>release-profile</id>

      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <updateReleaseInfo>true</updateReleaseInfo>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

答案 1 :(得分:2)

所以这里是我自己问题的答案,以防有人想知道这些工作:

    <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <configuration>
      ...
      <useReleaseProfile>false</useReleaseProfile>
      ...
    </configuration>
  </plugin>
</plugins>