2016-03-10 32 views
0

使用此projects structure我无法将sqljdbc4.jar安装到我的本地maven存储库。如何使用maven-install-plugin安装文件模块

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

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

+0

你为什么这样做?不要绑定“安装文件”执行。只需使用'mvn install'? – Tunaki

+0

将你需要的jar安装到版本库管理器中,就是这样...从你的Maven项目中删除了lib文件夹。 – khmarbaise

回答

0

谢谢,我已经使用

<phase>clean</phase> 

和移动的lib文件夹到我的我的多模块项目的BASEDIR。