user373201
user373201

Reputation: 11435

maven run maven install from inside pom

I have some 3rd party jars that is not in repository that I need to install while doing a build. I am trying to use the ant plugin to copy the generated jar and pom from my projects/lib folder to the local repository

my src/main/lib dir contains following folder structure com/oracle/ojdbc14/10.2/ojdbc.jar, ojdbc.pom

<plugin> 
            <groupId>org.apache.maven.plugins</groupId> 
            <artifactId>maven-antrun-plugin</artifactId> 
            <version>1.7</version> 
            <executions> 
                <execution> 
                    <phase>validate</phase> 
                    <goals> 
                        <goal>run</goal> 
                    </goals> 
                    <configuration> 
                        <tasks> 
                            <copy todir="${settings.localRepository}" >  
                                <fileset dir="${basedir}/src/main/lib/" includes="**"/>  
                            </copy>
                        </tasks> 
                    </configuration> 
                </execution> 
            </executions> 
        </plugin> 

But when i run mvn install, it fails with the following msg

Failure to find com.oracle:ojdbc14:jar:10.2.0.3.0

why does the copy command from ant (validate phase) run before any checks is made regarding dependencies

Upvotes: 1

Views: 1340

Answers (2)

Manfred Moser
Manfred Moser

Reputation: 29912

Get a repository manager and install the artifact there. Everything else is an ugly hack that is far more invasive and troublesome than installing and using a repository manager. Look at Nexus, Artifactory or Archiva and get all the benefits from using it like improved build performance, ease of using third party libs and ability to share artifacts internally..

Upvotes: 2

Michał Kalinowski
Michał Kalinowski

Reputation: 17943

Sorry, but this totally sucks. If you really can't deploy this 3rd party stuff to some kind of internal or private Maven repo, the best way of doing such thing I've found so far is to use install:install-file goal with all these jars. We had created 2 shell scripts (for Windows and Linux) for that and share them by SCM within bootstrap directory (or someting like this). Notice that every new developer has to do this once because these artifacts are then resolvable in local Maven repo.

Look at this for details about install:install-file goal: http://maven.apache.org/plugins/maven-install-plugin/install-file-mojo.html

Upvotes: 3

Related Questions