ronk
ronk

Reputation: 203

Maven-release-plugin and builder-helper plugin


I guess i am missing something..
I want to make a release of my project.
I added maven-release-plugin to my pom. In addition, i have another source code dir aside from java(call it gen-src). When i make the first steps in the maven release (i.e prepare) everything is ok, but when i make perform it does not take the gen-src in account.

<plugin>
       <groupId>org.codehaus.mojo</groupId>
      <artifactId>build-helper-maven-plugin</artifactId>
      <version>1.7</version>
       <executions>
          <execution>
               <id>add-source</id>
               <phase>generate-sources</phase>

               <goals>
                  <goal>add-source</goal>
               </goals>
               <configuration>
                   <sources>
                        <source>src/main/gen_src</source>
                   </sources>
               </configuration>
          </execution>
       </executions>
    </plugin>

I suspect that it may be connected to the fact that the phase is generated-sources. Do i need to attach the add-source goal to another phase? If yes, how?
I also read in here - this is similar problem though i am not using flex..no answer. Any idea?
Thanks.

Upvotes: 5

Views: 1144

Answers (2)

Bruno Medeiros
Bruno Medeiros

Reputation: 2399

I had the same problem in the past and I think I know what's happening. The release:perform phase checkouts a copy of the tag to be released to 'target/checkout' folder and fork a maven process to build this checkout. As you have a problem only in the release:perform phase, it must be related to the fact that maven in running a fork process on the 'target/checkout' folder, not in the './' folder.

I ended up fixing this problem removing build helper, but I don't know if you could do the same, so if I were you I would try avoiding relative paths on configurations. You can configure the build-helper like that:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.7</version>
   <executions>
      <execution>
           <id>add-source</id>
           <phase>generate-sources</phase>

           <goals>
              <goal>add-source</goal>
           </goals>
           <configuration>
               <sources>
                    <source>${basedir}/src/main/gen_src</source>
               </sources>
           </configuration>
      </execution>
   </executions>
</plugin>

Defining explicitly the ${basedir} could avoid this problem because ${basedir} will resolve to the fork path (your_workspace/project/target/checkout) instead of the current path (your_workspace/project). If this doesn't fix the problem, I believe we should file a bug against build-helper-maven-plugin because there should be no errors only in the perform phase.

Upvotes: 1

MaDa
MaDa

Reputation: 10762

The generated source classes won't make it into the binary jar — there you'll find only .class files resulting from compilation of both regular and generated sources. Maven release plug-in will, though, include the extra source directory into sources jar.

There is no need to execute "add-source" goal in any other phase; what you could find useful is letting the clean plug-in know that it should include the extra directory:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
    <filesets>
        <fileset>
            <directory>${basedir}/src/main/gen_src</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </fileset>
    </filesets>
</configuration>
</plugin>

Upvotes: 0

Related Questions