rom12three
rom12three

Reputation: 21

How to use maven-install-plugin to install-file for module

With this projects structure I cannot install the sqljdbc4.jar to my local maven repository.

This is LiferayBuild/pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>...</groupId>
    <artifactId>LiferayBuild</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>LiferayBuild</name>
    <description>Liferay Aggregator Project (build modules)</description>
    <properties>
        ...
    </properties>
    <modules>
        ...
        <module>../Liferay</module>
    </modules>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <groupId>com.microsoft.sqlserver</groupId>
                    <artifactId>sqljdbc4</artifactId>
                    <version>4.0</version>
                    <file>${basedir}/lib/sqljdbc4-4.0.jar</file>
                    <packaging>jar</packaging>
                    <generatePom>false</generatePom>
                    <pomFile>../Liferay/pom.xml</pomFile>
                </configuration>
                <executions>
                    <execution>
                        <id>inst_sql</id>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <phase>install</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

And this is Liferay/pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>Liferay</artifactId>
<version>1.2.1</version>
<name>Liferay</name>
<description>Liferay Connector</description>
<properties>
    ...
</properties>

<dependencies>
    ...
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>4.0</version>
    </dependency>
    ...
</dependencies>
<!-- Build Settings -->
<build>
    <resources>
        ...
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        ...
    </plugins>
</build>
<pluginRepositories>
    ...
</pluginRepositories>
<profiles>
    <profile>
        ...
    </profile>
</profiles>

When I Run as... Maven install, I get a BUILD FAILURE

[ERROR] Failed to execute goal on project Liferay: Could not resolve dependencies for project com.realsoft:Liferay:jar:1.2.1: Failure to find com.microsoft.sqlserver:sqljdbc4:jar:4.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

What can I do to get the jar installed to my local repository? I have already tried the suggestions from http://blog.valdaris.com/post/custom-jar/ but with no outcome. Please help!

Upvotes: 0

Views: 9440

Answers (1)

rom12three
rom12three

Reputation: 21

Thanks, I have used

<phase>clean</phase>

and moved the lib folder to my basedir of my multi-module project.

Upvotes: 1

Related Questions