Run Ant task from Maven

I use Ant to create a custom jar library, which I then use as a dependency in Maven.

<dependency>
    <groupId> test-lib </groupId>
    <artifactId> test-lib </artifactId>
    <version> 1.0.0system </scope>
    <systemPath> $ {basedir} /src/main/webapp/WEB-INF/lib/test-lib-1.0.0.jar </systemPath>
</dependency>

So basically what I am doing now:

1) run Ant to create a custom library (test-lib-1.0.0.jar)
2) run: mvn compile to compile my project using a special library among others.

Do I have the opportunity to do all this (batch jar and compiling project) from Maven? I found the maven run plugin and here are my settings:

<plugin>
    <artifactId> maven-antrun-plugin </artifactId>
    <version> 1.4
    <executions>
        <execution>
            <phase> ????? what to put here ????? / phase>
            <configuration>
                <tasks>
                    <ant antfile = "$ {basedir} /build.xml">
                        <target name = "prepare-test-lib" />
                    </ant>
                </tasks>
            </configuration>
            <goals>
                <goal> run </goal>
            </goals>
        </execution>
    </executions>
</plugin>

But when you start: mvn compilehe complains of the lack of artifact: test-lib-1.0.0.jar. I used compilation, generate-resouces, ... in the tag <phase/>, but nothing works.

- ?

+3
1

Maven Antrun Plugin Maven ClassPaths AntRun, , , : , AntRun, , . .

, mavenize test-lib, . , Ant Maven test-lib . "", :

my-project
|-- my-module
|   |-- src
|   |   `-- main
|   |       `-- java
|   `-- pom.xml
|-- test-lib
|   |-- src
|   |   `-- main
|   |       `-- java
|   `-- pom.xml
`-- pom.xml

my-project/pom.xml - pom <packaging>pom</packaging> <modules>:

<modules>
  <module>my-module</module>
  <module>test-lib</module>
</modules>

my-module/pom.xml test-lib:

<dependency>
  <groupId>your.group.id</groupId>
  <artifactId>test-lib</artifactId>
  <version>1.0-SNAPSHOT</version>
</dependency>

, , . Sonatype ( ).

( (ab) system ).

+2

Source: https://habr.com/ru/post/1760112/


All Articles