如何使用maven-install-plugin为模块安装文件

时间:2016-03-10 11:26:42

标签: maven jar maven-install-plugin

使用此projects structure我无法将sqljdbc4.jar安装到我的本地maven存储库。

这是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>

这是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>

当我跑... Maven安装时,我得到一个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]

如何将jar安装到本地存储库?我已经尝试过http://blog.valdaris.com/post/custom-jar/的建议但没有结果。请帮忙!

1 个答案:

答案 0 :(得分:1)

谢谢,我用过

<phase>clean</phase>

并将lib文件夹移动到我的多模块项目的基础上。