Maven构建没有找到已安装在本地openshift项目仓库中的自定义jar

时间:2014-03-16 17:32:07

标签: maven repository local openshift

我在尝试构建项目时遇到了一个问题(来自Eclipse Openshift插件)。

1。)我有一个自定义依赖项,首先我按照Open Shift Knowledgebase Article "Using your own jar files..."

上的说明操作

2。)在上面提交和发布时,错误仍然存​​在,因此我更改了this post on the Openshift forums "Resolved custom jar dependency..."

中提到的openshift pre_build操作挂钩

但是,我仍然在提交错误并从eclipse发布。这是控制台的转储

Repository ssh://53211e7...50000f0@testapp0...312-systix.rhcloud.com/~/git/testapp0...312.git/

Stopping RockMongo cartridge
[Sun Mar 16 12:20:37 2014] [warn] module php5_module is already loaded, skipping
httpd (no pid file) not running
MongoDB already stopped
Stopping jbossas cartridge
Repairing links for 1 deployments
Building git ref 'master', commit bb2def3
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /var/lib/openshift/app-root/runtime/repo/shared-helper-data-skychart-0.0.1-SNAPSHOT.jar to /var/lib/openshift/53211e...0f0/.m2/repository/com/systix/shared-helper-data-skychart/0.0.1-SNAPSHOT/shared-helper-data-skychart-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.331s
[INFO] Finished at: Sun Mar 16 12:20:48 EDT 2014
[INFO] Final Memory: 4M/78M
[INFO] ------------------------------------------------------------------------
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /var/lib/openshift/app-root/runtime/repo/shared-models-skychart-0.0.1-SNAPSHOT.jar to /var/lib/openshift/5321......00f0/.m2/repository/com/systix/shared-models-skychart/0.0.1-SNAPSHOT/shared-models-skychart-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.723s
[INFO] Finished at: Sun Mar 16 12:20:53 EDT 2014
[INFO] Final Memory: 4M/78M
[INFO] ------------------------------------------------------------------------
Found pom.xml... attempting to build with 'mvn -e clean package -Popenshift -DskipTests'
Apache Maven 3.0.3 (r1075437; 2011-06-20 13:22:37-0400)
Maven home: /etc/alternatives/maven-3.0
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "2.6.32-431.5.1.el6oso.bz844450.x86_64", arch: "i386", family: "unix"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building testapp0...312 1.0
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.134s
[INFO] Finished at: Sun Mar 16 12:21:04 EDT 2014
[INFO] Final Memory: 5M/111M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project testapp0...0312: Could not resolve dependencies for project testapp0...0312:testapp0...312:war:1.0: Could not find artifact com.systix:shared-helper-data-skychart:jar:0.0.1-SNAPSHOT -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
An error occurred executing 'gear postreceive' (exit code: 1)
Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/5321...00f0/jbossas

For more details about the problem, try running the command again with the '--trace' option.

在回顾上面的内容时,似乎maven能够将依赖jar成功添加到本地repo,但是项目的构建似乎不是。

更新:包括我已标记为要在pre_build文件中安装的两个库中的pom.xml。这两个jar都是构建的,包含在openshift git repo中,并在pre_build脚本中引用,以安装在openshift的maven repo中(pre_build脚本包含在最后)

来自shared-helper-data-skychart的

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>com.systix</groupId>
  <artifactId>shared-helper-data-skychart</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>2.11.4</version>
    </dependency>
    <dependency>
        <groupId>com.systix</groupId>
        <artifactId>shared-models-skychart</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>org.mongodb.morphia</groupId>
        <artifactId>morphia</artifactId>
        <version>0.105</version>
    </dependency>
  </dependencies>
</project>

来自shared-models-skychart的pom.xml(共享模型 - 天空图是pom.xml中对shared-helper-data-skychart的依赖)

<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>com.systix</groupId>
  <artifactId>shared-models-skychart</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>org.mongodb.morphia</groupId>
        <artifactId>morphia</artifactId>
        <version>0.105</version>
    </dependency>
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.7.3</version>
    </dependency>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>2.11.4</version>
    </dependency>
  </dependencies>
</project>

使用pre_build脚本

mvn install:install-file -Dfile=../app-root/runtime/repo/shared-helper-data-skychart-0.0.1-SNAPSHOT.jar -DgroupId=com.systix -DartifactId=shared-helper-data-skychart -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
mvn install:install-file -Dfile=../app-root/runtime/repo/shared-models-skychart-0.0.1-SNAPSHOT.jar -DgroupId=com.systix -DartifactId=shared-models-skychart -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar

更新2:此外,上面的pom.xml是我项目代码文件中的内容。但是,当我ssh intoopenshift服务器并查看本地maven repos时,以下是我所看到的pom.xml

cat ./.m2/repository/com/systix/shared-helper-data-skychart/0.0.1-SNAPSHOT/shared-helper-data-skychart-0.0.1-SNAPSHOT.pom
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.systix</groupId>
  <artifactId>shared-helper-data-skychart</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <description>POM was created from install:install-file</description>
</project>

1 个答案:

答案 0 :(得分:0)

这对我有用:

  1. 我通过SSH连接到OpenShift,如here所述。
  2. 在那里我发现在OpenShift maven repo(在〜/ .m2 / repository /下),jar没有正确安装。 在依赖项目录中有* .jar.lastUpdated文件而不是实际的jar。
  3. 我从maven repo(手动)
  4. 删除了有问题的依赖项的整个目录
  5. 在我的pre_build动作挂钩中,我将mvn install:install -Dfile路径更改为jar的绝对路径(例如/ var / lib / openshift / ___ your__id__here ____ / app-root / runtime / repo / dependencyfile.jar
  6. 我将我的本地更改(pre_build action hook在第4点中更改)推送到git repo。现在一切正常:)