2016-03-10 34 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。