You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Silvio Arcangeli <sa...@progress.com> on 2008/11/11 14:02:57 UTC

antrun plugin: is it possible to inherit external build.xml together with parent pom?

Hi all,

I'm trying to solve a puzzle which starts to look harder than I thought.

 

In my build platform I have project type that normally produces a jar
file, and in certain corner cases (for solving class loading issues) it
may have to produce also a second jar file if any class file is present
under a certain directory pattern.

 

First solution was to add a maven jar execution to my parent pom, but
that would always produce the "corner case" jar file also when it's
empty. I want to avoid this, as it would create confusion for all
"normal" cases, but couldn't find a way to avoid manifest-only jar files
using the maven jar plugin.

 

So I tried to solve it by replacing the maven jar with an ant task...
Since the "if" task is not available in maven (ant-contrib is not
included as far as I understood), I need to define a target if I want to
specify a conditional behavior, and this means that I cannot embed the
task directly in the pom file, and I'm forced to use an external build
file.

 

So I wrote my "build.xml" and called it from the pom. Everything works
fine if executed directly on the final project, but now I can't find a
way to move its execution in the parent pom and store "build.xml"
together with that pom file instead of having to store it somewhere in
the final project location...

 

Does anybody have any advice on how to solve it?

 

Thanks!

Silvio

 

p.s. here's my antrun execution:

 

      <plugin>

        <artifactId>maven-antrun-plugin</artifactId>

        <executions>

          <execution>

            <phase>package</phase>

            <configuration>

              <tasks>

                <property name="project_targetClasses"
value="${project.build.outputDirectory}"/>

                <property name="project_target"
value="${project.build.directory}"/>

                <property name="project_artifact"
value="${project.artifactId}"/>

                <property name="project_version"
value="${project.version}"/>

                <ant target="boot.fileset.jar"/>

              </tasks>

            </configuration>

            <goals>

              <goal>run</goal>

            </goals>

          </execution>

        </executions>

      </plugin>

 

And here's my build.xml:

 

<project name="My JAR file package" default="boot.fileset.jar">

            <fileset dir="${project_targetClasses}" id="boot.fileset"
includes="**/boot/*" />

 

            <target name="boot.fileset.checkExist">

                        <pathconvert refid="boot.fileset"
property="boot.fileset.notEmpty" setonempty="false" />

            </target>

 

            <target name="boot.fileset.jar"
depends="boot.fileset.checkExist" if="boot.fileset.notEmpty">

                        <jar
destfile="${project_target}/${project_artifact}-${project_version}-boot.
jar">

                                    <fileset refid="boot.fileset" />

                        </jar>

            </target>

</project>

 


RE: antrun plugin: is it possible to inherit external build.xml together with parent pom?

Posted by Silvio Arcangeli <sa...@progress.com>.
Thanks Justin,
I'll try that, so that I can avoid the external build.xml!

Ciao,
Silvio

-----Original Message-----
From: Edelson, Justin [mailto:Justin.Edelson@mtvstaff.com] 
Sent: martedì 11 novembre 2008 16.52
To: Maven Users List
Subject: RE: antrun plugin: is it possible to inherit external build.xml together with parent pom?

AFAIK, you can use ant-contrib with the antrun plugin. You just need to
add it as a plugin dependency.

Justin 

-----Original Message-----
From: Silvio Arcangeli [mailto:sarcange@progress.com] 
Sent: Tuesday, November 11, 2008 8:03 AM
To: users@maven.apache.org
Subject: antrun plugin: is it possible to inherit external build.xml
together with parent pom?

Hi all,

I'm trying to solve a puzzle which starts to look harder than I thought.

 

In my build platform I have project type that normally produces a jar
file, and in certain corner cases (for solving class loading issues) it
may have to produce also a second jar file if any class file is present
under a certain directory pattern.

 

First solution was to add a maven jar execution to my parent pom, but
that would always produce the "corner case" jar file also when it's
empty. I want to avoid this, as it would create confusion for all
"normal" cases, but couldn't find a way to avoid manifest-only jar files
using the maven jar plugin.

 

So I tried to solve it by replacing the maven jar with an ant task...
Since the "if" task is not available in maven (ant-contrib is not
included as far as I understood), I need to define a target if I want to
specify a conditional behavior, and this means that I cannot embed the
task directly in the pom file, and I'm forced to use an external build
file.

 

So I wrote my "build.xml" and called it from the pom. Everything works
fine if executed directly on the final project, but now I can't find a
way to move its execution in the parent pom and store "build.xml"
together with that pom file instead of having to store it somewhere in
the final project location...

 

Does anybody have any advice on how to solve it?

 

Thanks!

Silvio

 

p.s. here's my antrun execution:

 

      <plugin>

        <artifactId>maven-antrun-plugin</artifactId>

        <executions>

          <execution>

            <phase>package</phase>

            <configuration>

              <tasks>

                <property name="project_targetClasses"
value="${project.build.outputDirectory}"/>

                <property name="project_target"
value="${project.build.directory}"/>

                <property name="project_artifact"
value="${project.artifactId}"/>

                <property name="project_version"
value="${project.version}"/>

                <ant target="boot.fileset.jar"/>

              </tasks>

            </configuration>

            <goals>

              <goal>run</goal>

            </goals>

          </execution>

        </executions>

      </plugin>

 

And here's my build.xml:

 

<project name="My JAR file package" default="boot.fileset.jar">

            <fileset dir="${project_targetClasses}" id="boot.fileset"
includes="**/boot/*" />

 

            <target name="boot.fileset.checkExist">

                        <pathconvert refid="boot.fileset"
property="boot.fileset.notEmpty" setonempty="false" />

            </target>

 

            <target name="boot.fileset.jar"
depends="boot.fileset.checkExist" if="boot.fileset.notEmpty">

                        <jar
destfile="${project_target}/${project_artifact}-${project_version}-boot.
jar">

                                    <fileset refid="boot.fileset" />

                        </jar>

            </target>

</project>

 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: antrun plugin: is it possible to inherit external build.xml together with parent pom?

Posted by "Edelson, Justin" <Ju...@mtvstaff.com>.
AFAIK, you can use ant-contrib with the antrun plugin. You just need to
add it as a plugin dependency.

Justin 

-----Original Message-----
From: Silvio Arcangeli [mailto:sarcange@progress.com] 
Sent: Tuesday, November 11, 2008 8:03 AM
To: users@maven.apache.org
Subject: antrun plugin: is it possible to inherit external build.xml
together with parent pom?

Hi all,

I'm trying to solve a puzzle which starts to look harder than I thought.

 

In my build platform I have project type that normally produces a jar
file, and in certain corner cases (for solving class loading issues) it
may have to produce also a second jar file if any class file is present
under a certain directory pattern.

 

First solution was to add a maven jar execution to my parent pom, but
that would always produce the "corner case" jar file also when it's
empty. I want to avoid this, as it would create confusion for all
"normal" cases, but couldn't find a way to avoid manifest-only jar files
using the maven jar plugin.

 

So I tried to solve it by replacing the maven jar with an ant task...
Since the "if" task is not available in maven (ant-contrib is not
included as far as I understood), I need to define a target if I want to
specify a conditional behavior, and this means that I cannot embed the
task directly in the pom file, and I'm forced to use an external build
file.

 

So I wrote my "build.xml" and called it from the pom. Everything works
fine if executed directly on the final project, but now I can't find a
way to move its execution in the parent pom and store "build.xml"
together with that pom file instead of having to store it somewhere in
the final project location...

 

Does anybody have any advice on how to solve it?

 

Thanks!

Silvio

 

p.s. here's my antrun execution:

 

      <plugin>

        <artifactId>maven-antrun-plugin</artifactId>

        <executions>

          <execution>

            <phase>package</phase>

            <configuration>

              <tasks>

                <property name="project_targetClasses"
value="${project.build.outputDirectory}"/>

                <property name="project_target"
value="${project.build.directory}"/>

                <property name="project_artifact"
value="${project.artifactId}"/>

                <property name="project_version"
value="${project.version}"/>

                <ant target="boot.fileset.jar"/>

              </tasks>

            </configuration>

            <goals>

              <goal>run</goal>

            </goals>

          </execution>

        </executions>

      </plugin>

 

And here's my build.xml:

 

<project name="My JAR file package" default="boot.fileset.jar">

            <fileset dir="${project_targetClasses}" id="boot.fileset"
includes="**/boot/*" />

 

            <target name="boot.fileset.checkExist">

                        <pathconvert refid="boot.fileset"
property="boot.fileset.notEmpty" setonempty="false" />

            </target>

 

            <target name="boot.fileset.jar"
depends="boot.fileset.checkExist" if="boot.fileset.notEmpty">

                        <jar
destfile="${project_target}/${project_artifact}-${project_version}-boot.
jar">

                                    <fileset refid="boot.fileset" />

                        </jar>

            </target>

</project>

 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org