What is making the *sources.jar during Maven release?

不打扰是莪最后的温柔 提交于 2019-12-11 04:49:47

问题


I am certain that I do not have maven-source-plugin in my plugins, but a [project-name]-sources.jar is always getting built during release:perform. It doesn't seem to be doing it during other stages of the build life-cycle.

Unfortunately, this [project-name]-sources.jar gets uploaded to our repository (Nexus). Management wants all sources to be kept in SVN and away from the repository.

How do I do that? This is certainly not an assembly issue. We've tried different build profiles but the [project-name]-sources.jar still remained. We just don't want any source codes get uploaded to the repository during releases.

Any idea any one?

Thanks in advance.

Below is all we use in the tag:

    <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>

回答1:


The simply answer is that during the release run the maven-sources-plugin is attached to the build life cylce (package phase) which is activated by a property performRelease. This is defined in the super-pom which defines this are a profile.

Here is the appropriate part of the super 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>



回答2:


So here is the answer to my own question in case anyone wants to know the work around:

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


来源:https://stackoverflow.com/questions/26305312/what-is-making-the-sources-jar-during-maven-release

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!