【问题标题】:What is making the *sources.jar during Maven release?在 Maven 发布期间制作 *sources.jar 的原因是什么?
【发布时间】:2014-10-10 17:55:49
【问题描述】:

我确定我的插件中没有 maven-source-plugin,但是在 release:perform 期间总是会构建一个 [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>

【问题讨论】:

  • 顺便说一句:您使用的是非常旧版本的插件。

标签: maven maven-release-plugin


【解决方案1】:

如果有人想知道解决方法,以下是我自己的问题的答案:

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

【讨论】:

    【解决方案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>
    

    【讨论】:

    • 这正是根本原因,Maven发布插件文档清楚地表明“useReleaseProfile”默认为true;因此,如果不关闭它,它将使用超级 POM 的 maven-source-plugin。我真的很感谢你的回答。谢谢@khmarbaise
    猜你喜欢
    • 2019-04-03
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    相关资源
    最近更新 更多