1
votes

I currently have a Maven build that calls on an ant task to run. This ant task has a dependency on some external libs. Those libs are currently hardcoded in my system. I would like to move those external libs to a local Maven repo and have maven retrieve them from the repo, but am not sure how to do this.

My current task is defined as (edited the full task definition for brevity):

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

                <!-- Ant Custom Folder copying plugin -->
                <execution>
                    <id>rename_files</id>
                    <phase>process-resources</phase>
                    <configuration>
                        <tasks>
                            <taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${env.ANT_HOME}/lib/ant-contrib-1.0b3.jar" />
                            <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpath="${env.ANT_HOME}/lib/AntelopeTasks_3.4.1.jar" />
                            <typedef name="trim" classname="ise.antelope.tasks.typedefs.string.Trim" classpath="${env.ANT_HOME}/lib/AntelopeTasks_3.4.1.jar" />
                            <typedef name="lastindexof" classname="ise.antelope.tasks.typedefs.string.LastIndexOf" classpath="${env.ANT_HOME}/lib/AntelopeTasks_3.4.1.jar" />
                            <typedef name="substring" classname="ise.antelope.tasks.typedefs.string.Substring" classpath="${env.ANT_HOME}/lib/AntelopeTasks_3.4.1.jar" />
                            <typedef name="listfiles" classname="ise.antelope.tasks.typedefs.file.FileList" classpath="${env.ANT_HOME}/lib/AntelopeTasks_3.4.1.jar" />
                            <taskdef name="fileutil" classname="ise.antelope.tasks.FileUtilTask" classpath="${env.ANT_HOME}/lib/AntelopeTasks_3.4.1.jar" />

                            <!-- CSS -->
                            <for param="file">
                                <path>
                                    <fileset dir="target\Com-${project.version}\style\" includes="*.css" />
                                </path>
                                <sequential>
                                    <fileutil file="@{file}" property="fileWithoutPath">
                                        <listfiles includepath="false" />
                                    </fileutil>
                                </sequential>
                            </for>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I know I can define <dependencies> as part of my plugin def, but not sure how do redefine my taskdef to point to the dependency vs the rar jar file.

1

1 Answers

2
votes

After sifting around a lot, I figured out I can do the following.

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <dependencies>
                <dependency>
                    <groupId>ant-contrib</groupId>
                    <artifactId>ant-contrib</artifactId>
                    <version>1.0b3</version>
                </dependency>
                <dependency>
                    <groupId>org.tigris.antelope</groupId>
                    <artifactId>antelopetasks</artifactId>
                    <version>3.4.1</version>
                </dependency>
            </dependencies>
            <executions>

                <!-- Ant Custom Folder copying plugin -->
                <execution>
                    <id>rename_files</id>
                    <phase>process-resources</phase>
                    <configuration>
                        <tasks>
                            <taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="maven.plugin.classpath" />
                            <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="maven.plugin.classpath" />
                            <typedef name="trim" classname="ise.antelope.tasks.typedefs.string.Trim" classpathref="maven.plugin.classpath" />
                            <typedef name="lastindexof" classname="ise.antelope.tasks.typedefs.string.LastIndexOf" classpathref="maven.plugin.classpath" />
                            <typedef name="substring" classname="ise.antelope.tasks.typedefs.string.Substring" classpathref="maven.plugin.classpath" />
                            <typedef name="listfiles" classname="ise.antelope.tasks.typedefs.file.FileList" classpathref="maven.plugin.classpath" />
                            <taskdef name="fileutil" classname="ise.antelope.tasks.FileUtilTask" classpathref="maven.plugin.classpath" />

                   </tasks>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

Just have to use classpathref and point to maven.plugin.classpath in the task defn.

Hope this helps someone else in the future.