You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gerald Reinhart <ge...@googlemail.com> on 2007/08/24 10:06:47 UTC

[m2] How can we replace the artifact created by Maven by another artifact created by antrun ?

Hi,

Hypothesis:
- in a multi-modules project managed by Maven2
- an specific artifact can't be created by Maven2 [1]
- this artifact is created by an antrun call [2]
- another antrun call replace the fake artifact created by Maven by the
right artifact created antrun [2]
- the install goal is OK: the right artifact is installed in my repository
- another module depends of the artifact of the first module

Problem:
- when I do an install of the first artifact in my repository and a compile
the other module => BUILD SUCCESSFUL [3]
- when I do a global build from the parent => BUILD FAILURE [4]

On the first build,  it's OK because maven resolve the dependency by the
local repository.
On the second build, it's KO because maven takes the artifact it has created
during the global build, so the fake artifact....

I don't know what to do with that... an idea ?

Regards

Gerald Reinhart


[1] In my context, I have a split weblogic directory, some ant weblogic
targets generate EJBs, EJBs Client, WebService and an EAR. It would be a
nightmare to transform those ant weblogic target in Maven (
http://edocs.bea.com/wls/docs92/programming/splitcreate.html).
The only artifact that other modules of the project needs is a EJB Client
Jar.

[2] My antrun call create a target/service-ant-client.jar file.

my pom.xml:
[...]
  <groupId>myproject</groupId>
  <artifactId>service</artifactId>
  <version>1.0</version>
  <packaging>ejb</packaging>
[...]
  <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-ejb-plugin</artifactId>
        <configuration>
        <generateClient>true</generateClient>
        <clientExcludes>
          <clientExclude>**/ejb/*Bean.class</clientExclude>
          </clientExcludes>
        </configuration>
  </plugin>
[...]
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
            <execution>
            <id>antrun_compile</id>
            <phase>compile</phase>
            <configuration>
              <tasks>
                  [...]
                  <!-- weblogic ant call =>    target/service-ant-client.jar-->
                  [...]
              </tasks>
            </configuration>
            <goals><goal>run</goal></goals>
          </execution>
          <execution>
            <id>antrun_package</id>
            <phase>package</phase>
            <configuration>
              <tasks>
                  <echo>Replace the fake
target/service-1.0-client.jargenerated by maven
                        by the service-ant-client.jar generated by weblogic
ant targets.</echo>
                  <delete file="target/service-1.0-client.jar"/>
                  <copy file="target/service-ant-client.jar"  tofile="
service-1.0-client.jar"  />
              </tasks>
            </configuration>
            <goals><goal>run</goal></goals>
          </execution>
        </executions>
     </plugin>
[...]
</project>

Targets :
          target/service-1.0.jar (fake EJB Jar)
          target/service-1.0-client.jar (fake EJB Client Jar)
          target/service-ant-client.jar (generated by weblogic ant targets)



the pom dependency from another module:

    <dependency>
      <groupId>myproject</groupId>
      <artifactId>service</artifactId>
      <version>1.0</version>
      <type>ejb-client</type>
    </dependency>


[3]
mvn -f service\pom.xml clean install
mvn -f othermodule\pom.xml clean install
=> BUILD SUCESSFULL

[4]
parent pom.xml
[...]
   <modules>
      <module>service</module>
      <module>othermodule</module>
   </modules>
[...]

mvn -f pom.xml clean install

Re: [m2] How can we replace the artifact created by Maven by another artifact created by antrun ?

Posted by Gerald Reinhart <ge...@googlemail.com>.
Nobody have this kind of problem?

Regards

Gerald Reinhart

On 24/08/2007, Gerald Reinhart <.....@googlemail.com> wrote:
>
> Hi,
>
> Hypothesis:
> - in a multi-modules project managed by Maven2
> - an specific artifact can't be created by Maven2 [1]
> - this artifact is created by an antrun call [2]
> - another antrun call replace the fake artifact created by Maven by the
> right artifact created antrun [2]
> - the install goal is OK: the right artifact is installed in my repository
> - another module depends of the artifact of the first module
>
> Problem:
> - when I do an install of the first artifact in my repository and a
> compile the other module => BUILD SUCCESSFUL [3]
> - when I do a global build from the parent => BUILD FAILURE [4]
>
> On the first build,  it's OK because maven resolve the dependency by the
> local repository.
> On the second build, it's KO because maven takes the artifact it has
> created during the global build, so the fake artifact....
>
> I don't know what to do with that... an idea ?
>
> Regards
>
> Gerald Reinhart
>
>
> [1] In my context, I have a split weblogic directory, some ant weblogic
> targets generate EJBs, EJBs Client, WebService and an EAR. It would be a
> nightmare to transform those ant weblogic target in Maven (
> http://edocs.bea.com/wls/docs92/programming/splitcreate.html).
> The only artifact that other modules of the project needs is a EJB Client
> Jar.
>
> [2] My antrun call create a target/service-ant-client.jar file.
>
> my pom.xml:
> [...]
>   <groupId>myproject</groupId>
>   <artifactId>service</artifactId>
>   <version>1.0</version>
>   <packaging>ejb</packaging>
> [...]
>   <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-ejb-plugin</artifactId>
>         <configuration>
>         <generateClient>true</generateClient>
>         <clientExcludes>
>           <clientExclude>**/ejb/*Bean.class</clientExclude>
>           </clientExcludes>
>         </configuration>
>   </plugin>
> [...]
>       <plugin>
>         <groupId>org.apache.maven.plugins</groupId>
>         <artifactId>maven-antrun-plugin</artifactId>
>         <executions>
>             <execution>
>             <id>antrun_compile</id>
>             <phase>compile</phase>
>             <configuration>
>               <tasks>
>                   [...]
>                   <!-- weblogic ant call =>    target/service-
> ant-client.jar -->
>                   [...]
>               </tasks>
>             </configuration>
>             <goals><goal>run</goal></goals>
>           </execution>
>           <execution>
>             <id>antrun_package</id>
>             <phase>package</phase>
>             <configuration>
>               <tasks>
>                   <echo>Replace the fake target/service-1.0-client.jargenerated by maven
>                         by the service-ant-client.jar generated by
> weblogic ant targets.</echo>
>                   <delete file="target/service- 1.0-client.jar"/>
>                   <copy file="target/service-ant-client.jar"  tofile="
> service-1.0-client.jar"  />
>               </tasks>
>             </configuration>
>             <goals><goal>run</goal></goals>
>           </execution>
>         </executions>
>      </plugin>
> [...]
> </project>
>
> Targets :
>           target/service- 1.0.jar (fake EJB Jar)
>           target/service-1.0-client.jar (fake EJB Client Jar)
>           target/service-ant-client.jar (generated by weblogic ant
> targets)
>
>
>
> the pom dependency from another module:
>
>     <dependency>
>       <groupId>myproject</groupId>
>       <artifactId>service</artifactId>
>       <version>1.0</version>
>       <type>ejb-client</type>
>     </dependency>
>
>
> [3]
> mvn -f service\pom.xml clean install
> mvn -f othermodule\pom.xml clean install
> => BUILD SUCESSFULL
>
> [4]
> parent pom.xml
> [...]
>    <modules>
>       <module>service</module>
>       <module>othermodule</module>
>    </modules>
> [...]
>
> mvn -f pom.xml clean install
>
>