开发者

Unable to disable generation of sources JAR with maven-release-plugin

I am trying to release a web project using Maven 2.2.1 and the maven-release-plugin 2.0-beta-9, but it always fails when doing release:perform on generating the sources jar for the EAR project, which makes sense since the EAR project doesn't have any source.

[INFO] [INFO] [source:jar {execution: attach-sources}]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] BUILD ERROR
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Error creating source archive: You must set at least one file.

To try to disable the building of a sources JAR for the EAR project, I added the following to the POM for my EAR project (the version of the release plugin is set in a parent POM):

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

Upon running the release again after checking in this change, I got the same error while generating the sources JAR for the EAR project, even though this should have been disabled by the previous POM snippet.

What am I doing wrong? Why is the sources JAR still being built?

Edit: I've tried to make the source plugin include my application.xml file so that this error doesn't occur by adding the following POM snippet:

<build>
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <configuration>
                <includes>
  开发者_运维问答                  <include>${basedir}/META-INF/**/*</include>
                </includes>
                <useDefaultExcludes>false</useDefaultExcludes>
            </configuration>
        </plugin>
    </plugins>
</build>

Unfortunately, this does not fix the problem either.


I finally figured it out. I needed to add my source files as part of the references:

<resources>
    <resource>
        <directory>${project.basedir}</directory>
        <includes>
            <include>META-INF/**/*</include>
        </includes>
        <excludes>
            <exclude>target/**/*</exclude>
            <exclude>bin/**/*</exclude>
            <exclude>META-INF/.svn/**/*</exclude>
        </excludes>
    </resource>
</resources>

Doing this made everything work again. I didn't need any special configuration for the release or source plugins to get it to work.


There was a bug in the maven-source-plugin version 2.1 that resulted in the same error as you describe here. Newer Version >= 2.1.1 contain the fix. Here is a link to this Bug for further information. http://jira.codehaus.org/browse/MSOURCES-44

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜