构建包含JDK依赖项解析的RPM

时间:2014-02-10 17:17:42

标签: maven dependencies rpm

我使用来自jdk的zip文件分发的maven和nexus将oracle jdk 1.6构建到rpm中。

完成后,rpm拒绝安装,但没有以下内容:

[root@build]# rpm -ivh oracle-jdk-1.6.0_26-1.noarch.rpm
error: Failed dependencies:
        libXt.so.6()(64bit) is needed by oracle-jdk-1.6.0_26-1.noarch
        libodbc.so()(64bit) is needed by oracle-jdk-1.6.0_26-1.noarch
        libodbcinst.so()(64bit) is needed by oracle-jdk-1.6.0_26-1.noarch

精细。我猜测maven创造了这种依赖。它中的jdk原生拉链形式工作正常。

如何配置我的pom以便maven无法解决这些依赖关系?

我如何配置我的pom以便yum -y install将安装缺少的库?

我问两个人,因为我不知道我会采取哪种方式摇摆。

编辑:我的pom:

<?xml version="1.0"?>
<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.oracle</groupId>
  <artifactId>jdk</artifactId>
  <version>1.6.0_26</version>
  <packaging>pom</packaging>
  <properties>
    <unix.user>root</unix.user>
    <rpm.friendly.name>oracle-jdk</rpm.friendly.name>
    <rpm.install.basedir>/usr/java/jdk/1.6.0_26</rpm.install.basedir>
    <sourcefile.unzip.dir>${project.build.directory}/jdk1.6.0_26</sourcefile.unzip.dir>
    <yum.repo.host>localhost</yum.repo.host>
    <yum.repo.path>/apps/httpd/yumrepo</yum.repo.path>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>jdk</artifactId>
      <version>1.6.0_26</version>
      <type>tar.gz</type>
    </dependency>
  </dependencies>
  <distributionManagement>
    <repository>
      <id>ssh-repository</id>
      <url>scpexe://${yum.repo.host}${yum.repo.path}</url>
    </repository>
  </distributionManagement>
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ssh-external</artifactId>
        <version>1.0-beta-6</version>
      </extension>
    </extensions>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>rpm-maven-plugin</artifactId>
        <version>2.1-alpha-3</version>
        <executions>
          <execution>
            <id>generate-rpm</id>
            <goals>
              <goal>attached-rpm</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <name>${rpm.friendly.name}</name>
          <copyright>2014, JM</copyright>
          <group>Application/Internet</group>
          <packager>JM</packager>
          <needarch>false</needarch>
          <changelogFile>src/changelog</changelogFile>
          <mappings>
            <mapping>
              <directory>${rpm.install.basedir}</directory>
              <username>${unix.user}</username>
              <groupname>${unix.user}</groupname>
              <sources>
                <source>
                  <location>${sourcefile.unzip.dir}</location>
                </source>
              </sources>
            </mapping>
          </mappings>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <repositories>
    <repository>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>thirdparty</id>
      <url>http://myrepo.com:8081/nexus/content/repositories/thirdparty</url>
    </repository>
  </repositories>
</project>

1 个答案:

答案 0 :(得分:3)

基本上我认为在你的包中加入其他二进制文件(比如java)并不是一个好主意 我宁愿依赖它们。

但有时你必须,例如客户已经在他的机器上安装了Java,但是你想运行自己的java版本,从而提供你的软件包。

要做到这一点,你可以简单地告诉maven插件不要自动为这些包添加需求。

像这样

<configuration>  
     ......
     <autoRequires>false</autoRequires>
</configuration>