java – 使用maven rpm插件生成的RPM文件

前端之家收集整理的这篇文章主要介绍了java – 使用maven rpm插件生成的RPM文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在我的 Windows机器上创建我的maven项目的.rpm文件.

我按照下面链接中给出的步骤来实现它

http://tim-perry.co.uk/blog/2012/11/22/building_rpms_on_windows_with_maven

当我运行命令mvn package rpm:attached-rpm时,它显示构建成功但没有生成rpm文件.
相反,它在目标下创建一个名为“rpm”的目录,并复制此目录下所有需要的文件(如pom中所述).

让我知道我在这里失踪了什么.

下面是我正在使用的pom

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd ">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.org</groupId>
    <artifactId>inv_project</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <name>inv_project</name>
    <url>http://maven.apache.org</url>



    <build>
       <plugins>
           <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <version>2.0-beta-1</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>attached-rpm</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <name>PName</name>
                    <release>1</release>
                    <copyright></copyright>
                    <distribution></distribution>
                    <workarea>target/rpm</workarea>
                    <group></group>
                    <mappings>
                    <mapping>
                            <directory>/bin/</directory>
                            <filemode>755</filemode>
                            <username>user</username>
                            <groupname>sysop</groupname>
                            <sources>
                                <source>
                                    <location>test/</location>
                                    <includes>
                                        <include>*.jar</include>
                                    </includes>
                                </source>
                            </sources>
                        </mapping>
                        <mapping>
                            <directory>/conf/</directory>
                            <filemode>755</filemode>
                            <username>user</username>
                            <groupname>sysop</groupname>
                            <sources>
                                <source>
                                    <location>src/resources</location>
                                    <includes>                                      
                                        <include>*.properties</include>
                                    </includes>
                                </source>
                            </sources>
                        </mapping>
                    </mappings>
                    <postinstallScript />
                </configuration>
            </plugin>
     </plugins>
    </build>

</project>

添加日志

[INFO] --- rpm-maven-plugin:2.0-beta-2:attached-rpm (attach-rpm) @ mvi_cmpipe ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0,ConflictMarker.markTime=0,ConflictMarker.nodeCount=30,ConflictIdSorter.graphTime=0,ConflictIdSorter.topsortTime=0,ConflictIdSorter.conflictIdCount=13,ConflictIdSorter.conflictIdCycleCount=0,ConflictResolver.totalTime=1,ConflictResolver.conflictItemCount=27,DefaultDependencyCollector.collectTime=14,DefaultDependencyCollector.transformTime=2}
[DEBUG] org.codehaus.mojo:rpm-maven-plugin:jar:2.0-beta-2:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0:compile
[DEBUG]    org.codehaus.plexus:plexus-archiver:jar:1.0-alpha-5:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:compile
[DEBUG]          junit:junit:jar:3.8.2:test
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.5.7:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.0:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0:compile
[DEBUG]          org.apache.maven:maven-repository-Metadata:jar:2.0:compile
[DEBUG]    org.apache.maven:maven-model:jar:2.0:compile
[DEBUG] Created new class realm plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2
[DEBUG] Importing foreign packages into class realm plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2
[DEBUG]   Imported:  < project>com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:1.0-SNAPSHOT
[DEBUG] Populating class realm plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2
[DEBUG]   Included: org.codehaus.mojo:rpm-maven-plugin:jar:2.0-beta-2
[DEBUG]   Included: org.codehaus.plexus:plexus-archiver:jar:1.0-alpha-5
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:1.5.7
[DEBUG]   Excluded: org.apache.maven:maven-plugin-api:jar:2.0
[DEBUG]   Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   Excluded: junit:junit:jar:3.8.2
[DEBUG]   Excluded: classworlds:classworlds:jar:1.1-alpha-2
[DEBUG]   Excluded: org.apache.maven:maven-artifact:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-project:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-profile:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-artifact-manager:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-repository-Metadata:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-model:jar:2.0
[DEBUG] Configuring mojo org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2:attached-rpm from plugin realm ClassRealm[plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2,parent: sun.misc.Launcher$AppClassLoader@33d626a4]
[DEBUG] Configuring mojo 'org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2:attached-rpm' with basic configurator -->
[DEBUG]   (f) artifact = com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:pom:1.0-SNAPSHOT
[DEBUG]   (f) attachedArtifacts = []
[DEBUG]   (f) copyright = 2010,Org Siemens Networks
[DEBUG]   (f) distribution = NAC
[DEBUG]   (f) group = NAC
[DEBUG]   (s) directory = /bin/
[DEBUG]   (s) filemode = 755
[DEBUG]   (s) username = omc
[DEBUG]   (s) groupname = sysop
[DEBUG]   (s) location = D:\INV-project\test
[DEBUG]   (s) includes = [*.jar]
[DEBUG]   (s) sources = [{"D:\INV-project\test" incl:[*.jar]}]
[DEBUG]   (s) directory = /conf/
[DEBUG]   (s) filemode = 755
[DEBUG]   (s) username = omc
[DEBUG]   (s) groupname = sysop
[DEBUG]   (s) location = D:\INV-project\src\resources
[DEBUG]   (s) includes = [*.properties]
[DEBUG]   (s) sources = [{"D:\INV-project\src\resources" incl:[*.properties]}]
[DEBUG]   (f) mappings = [["/bin/" {%attr(755,omc,sysop)} from [{"D:\INV-project\test" incl:[*.jar]}]],["/conf/" {%attr(755,sysop)} from [{"D:\INV-project\src\resources" incl:[*.properties]}]]]
[DEBUG]   (f) name = ORG-generic_mediations
[DEBUG]   (f) project = MavenProject: com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:1.0-SNAPSHOT @ D:\INV-project\pom.xml
[DEBUG]   (f) projversion = 1.0-SNAPSHOT
[DEBUG]   (f) release = 1
[DEBUG]   (f) summary = mvi_cmpipe
[DEBUG]   (f) workarea = D:\INV-project\target\rpm
[DEBUG] -- end configuration --
[DEBUG] project version = 1.0-SNAPSHOT
[WARNING] Version string truncated to 1.0
[DEBUG] targetArch = noarch
[INFO] Creating directory D:\INV-project\target\rpm
[INFO] Creating directory D:\INV-project\target\rpm\BUILD
[INFO] Creating directory D:\INV-project\target\rpm\RPMS
[INFO] Creating directory D:\INV-project\target\rpm\SOURCES
[INFO] Creating directory D:\INV-project\target\rpm\SPECS
[INFO] Creating directory D:\INV-project\target\rpm\SRPMS
[INFO] Creating directory D:\INV-project\target\rpm\buildroot
[INFO] Copying 1 files to D:\INV-project\target\rpm\buildroot\bin
[INFO] Copying 1 files to D:\INV-project\target\rpm\buildroot\conf
[INFO] Creating spec file D:\INV-project\target\rpm\SPECS\ORG-generic_mediations.spec
[DEBUG] writing attriute string for directory: /bin/
[DEBUG] writing attriute string for directory: /conf/
[DEBUG] About to execute 'cmd.exe /X /C "rpmbuild -bb --buildroot D:\INV-project\target\rpm\buildroot --define "_topdir D:\INV-project\target\rpm" --target noarch ORG-generic_mediations.spec"'
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SETLOCAL
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>PUSHD .
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Update buildroot path
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>FOR /F "tokens=*" %i in ('cygpath D:\INV-project\target\rpm\buildroot') do SET NEW_BUILDROOT=%i
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET NEW_BUILDROOT=/cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm/buildroot
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Update topdir path
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET TOPDIR="_topdir D:\INV-project\target\rpm"
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET TOPDIR=D:\INV-project\target\rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>FOR /F "tokens=*" %i in ('cygpath "D:\INV-project\target\rpm"') do SET NEW_TOPDIR=%i
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET NEW_TOPDIR=/cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Replace path in spec-file
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET OLD_PATH=D:\\ORG\\Project\\MVI\\PM\\INV\\Eric3g_LTE\\trunk\\INV\\Install\\inv-project\\target\\rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET NEW_PATH=\/cygdrive\/d\/ORG\/Project\/MVI\/PM\/INV\/Eric3g_LTE\/trunk\/INV\/Install\/inv-project\/target\/rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>sed -s -i -e s/D:\\ORG\\Project\\MVI\\PM\\INV\\Eric3g_LTE\\trunk\\INV\\Install\\inv-project\\target\\rpm\\/\/cygdrive\/d\/ORG\/Project\/MVI\/PM\/INV\/Eric3g_LTE\/trunk\/INV\/Install\/inv-project\/target\/rpm\//g ORG-generic_mediations.spec
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Execute rpmbuild
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>bash -c "rpmb -bb --buildroot /cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm/buildroot --define ""_topdir /cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm"" --target "noarch" --define ""_build_name_fmt %{ARCH}/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm"" ORG-generic_mediations.spec"
[INFO] Building target platforms: noarch
[INFO] Building for target noarch
[INFO] Processing files: ORG-generic_mediations-1.0-1.noarch
[INFO]
[WARNING] error: No file attributes configured
[WARNING]     No file attributes configured
[INFO]
[INFO] RPM build errors:
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>POPD
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>ENDLOCAL
[INFO]
[INFO] --- rpm-maven-plugin:2.0-beta-2:attached-rpm (default-cli) @ mvi_cmpipe ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0,ConflictIdSorter.graphTime=1,DefaultDependencyCollector.collectTime=10,DefaultDependencyCollector.transformTime=2}
[DEBUG] org.codehaus.mojo:rpm-maven-plugin:jar:2.0-beta-2:
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0:compile
[DEBUG]    org.codehaus.plexus:plexus-archiver:jar:1.0-alpha-5:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8:compile
[DEBUG]          junit:junit:jar:3.8.2:test
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:1.5.7:compile
[DEBUG]    org.apache.maven:maven-artifact:jar:2.0:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.0:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.0:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.0:compile
[DEBUG]          org.apache.maven:maven-repository-Metadata:jar:2.0:compile
[DEBUG]    org.apache.maven:maven-model:jar:2.0:compile
[DEBUG] Created new class realm plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2--650166454
[DEBUG] Importing foreign packages into class realm plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2--650166454
[DEBUG]   Imported:  < project>com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:1.0-SNAPSHOT
[DEBUG] Populating class realm plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2--650166454
[DEBUG]   Included: org.codehaus.mojo:rpm-maven-plugin:jar:2.0-beta-2
[DEBUG]   Included: org.codehaus.plexus:plexus-archiver:jar:1.0-alpha-5
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:1.5.7
[DEBUG]   Excluded: org.apache.maven:maven-plugin-api:jar:2.0
[DEBUG]   Excluded: org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
[DEBUG]   Excluded: junit:junit:jar:3.8.2
[DEBUG]   Excluded: classworlds:classworlds:jar:1.1-alpha-2
[DEBUG]   Excluded: org.apache.maven:maven-artifact:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-project:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-profile:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-artifact-manager:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-repository-Metadata:jar:2.0
[DEBUG]   Excluded: org.apache.maven:maven-model:jar:2.0
[DEBUG] Configuring mojo org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2:attached-rpm from plugin realm ClassRealm[plugin>org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2--650166454,parent: sun.misc.Launcher$AppClassLoader@33d626a4]
[DEBUG] Configuring mojo 'org.codehaus.mojo:rpm-maven-plugin:2.0-beta-2:attached-rpm' with basic configurator -->
[DEBUG]   (f) artifact = com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:pom:1.0-SNAPSHOT
[DEBUG]   (f) attachedArtifacts = [com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:rpm:rpm:1.0-SNAPSHOT]
[DEBUG]   (f) copyright = 2010,sysop)} from [{"D:\INV-project\src\resources" incl:[*.properties]}]]]
[DEBUG]   (f) name = ORG-generic_mediations
[DEBUG]   (f) project = MavenProject: com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:1.0-SNAPSHOT @ D:\INV-project\pom.xml
[DEBUG]   (f) projversion = 1.0-SNAPSHOT
[DEBUG]   (f) release = 1
[DEBUG]   (f) summary = mvi_cmpipe
[DEBUG]   (f) workarea = D:\INV-project\target\rpm
[DEBUG] -- end configuration --
[DEBUG] project version = 1.0-SNAPSHOT
[WARNING] Version string truncated to 1.0
[DEBUG] targetArch = noarch
[INFO] Copying 1 files to D:\INV-project\target\rpm\buildroot\bin
[INFO] Copying 1 files to D:\INV-project\target\rpm\buildroot\conf
[INFO] Creating spec file D:\INV-project\target\rpm\SPECS\ORG-generic_mediations.spec
[DEBUG] writing attriute string for directory: /bin/
[DEBUG] writing attriute string for directory: /conf/
[DEBUG] About to execute 'cmd.exe /X /C "rpmbuild -bb --buildroot D:\INV-project\target\rpm\buildroot --define "_topdir D:\INV-project\target\rpm" --target noarch ORG-generic_mediations.spec"'
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SETLOCAL
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>PUSHD .
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Update buildroot path
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>FOR /F "tokens=*" %i in ('cygpath D:\INV-project\target\rpm\buildroot') do SET NEW_BUILDROOT=%i
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET NEW_BUILDROOT=/cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm/buildroot
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Update topdir path
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET TOPDIR="_topdir D:\INV-project\target\rpm"
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET TOPDIR=D:\INV-project\target\rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>FOR /F "tokens=*" %i in ('cygpath "D:\INV-project\target\rpm"') do SET NEW_TOPDIR=%i
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET NEW_TOPDIR=/cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Replace path in spec-file
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET OLD_PATH=D:\\ORG\\Project\\MVI\\PM\\INV\\Eric3g_LTE\\trunk\\INV\\Install\\inv-project\\target\\rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>SET NEW_PATH=\/cygdrive\/d\/ORG\/Project\/MVI\/PM\/INV\/Eric3g_LTE\/trunk\/INV\/Install\/inv-project\/target\/rpm
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>sed -s -i -e s/D:\\ORG\\Project\\MVI\\PM\\INV\\Eric3g_LTE\\trunk\\INV\\Install\\inv-project\\target\\rpm\\/\/cygdrive\/d\/ORG\/Project\/MVI\/PM\/INV\/Eric3g_LTE\/trunk\/INV\/Install\/inv-project\/target\/rpm\//g ORG-generic_mediations.spec
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>REM Execute rpmbuild
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>bash -c "rpmb -bb --buildroot /cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm/buildroot --define ""_topdir /cygdrive/d/ORG/Project/MVI/PM/INV/Eric3g_LTE/trunk/INV/Install/inv-project/target/rpm"" --target "noarch" --define ""_build_name_fmt %{ARCH}/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm"" ORG-generic_mediations.spec"
[INFO] Building target platforms: noarch
[INFO] Building for target noarch
[INFO] Processing files: ORG-generic_mediations-1.0-1.noarch
[INFO]
[INFO]
[WARNING] error: No file attributes configured
[INFO] RPM build errors:
[WARNING]     No file attributes configured
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>POPD
[INFO]
[INFO] D:\INV-project\target\rpm\SPECS>ENDLOCAL
[DEBUG] Replacing attached artifact com.Org.oss.INV.cmpipe.routes:mvi_cmpipe:rpm:rpm:1.0-SNAPSHOT. Old path D:\INV-project\target\rpm\RPMS\noarch\ORG-generic_mediations-1.0-1.noarch.rpm,new path D:\INV-project\target\rpm\RPMS\noarch\ORG-generic_mediations-1.0-1.noarch.rpm.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.025 s
[INFO] Finished at: 2014-10-09T19:45:00+05:30
[INFO] Final Memory: 6M/62M

解决方法

您是否已验证可以通过命令行直接构建RPM(即在Maven之外)?

如果没有,那么这整个讨论都没有实际意义,所以我将假设如此.

在这种情况下,只需将该命令传递到@L_502_2@:

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.3.2</version>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>rpmbuild</executable>
          <workingDirectory>${basedir}</workingDirectory>
          <arguments>
            <argument>--test</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

它将完美地模仿您在命令行上所做的任何事情.

希望有所帮助.

原文链接:https://www.f2er.com/java/129460.html

猜你在找的Java相关文章