无法使用 gradle 创建 RPM

can not create RPM using gradle

我是 java/gradle 安装程序的新手,能够使用 here 提供的示例构建 jar 文件。还实现了 Jacoco 代码覆盖工具。
但是 运行 进入以下问题

我的build.gradle文件如下

plugins {
  id "nebula.ospackage" version "3.2.0"
} 

apply plugin: 'nebula.ospackage'
apply plugin: 'java'
apply plugin: "jacoco"

repositories {
   mavenCentral()
   jcenter()
}

dependencies {
  testCompile 'org.testng:testng:6.8'
  compile 'log4j:log4j:1.2.17'
}

sourceSets {
     main {
        java {       srcDir 'src/main/java/'      }
        resources {  srcDir 'src/main/resources'  }
     }

   test {
        java {       srcDir 'src/test/java/'      }
        resources {  srcDir 'src/test/resources'  }
    }
}

test {
    // explicitly include or exclude tests
    include 'src/test/java/**'

    useTestNG{
        useDefaultListeners = true
    }

    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
        classDumpFile = file("$buildDir/jacoco/classpathdumps")
    }
    finalizedBy jacocoTestReport
}


jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.enabled true
        html.destination "${buildDir}/jacocoHtml"
    }
}

jar {
    baseName = 'smith'
    version = '1.0'
    manifest {
              attributes 'Main-Class': 'src.main.java.HelloWorld '}
}

ospackage {
    packageName = 'foo'
        version = '1.2.3'
        release = '1'
        arch = I386
        os = LINUX
}

// buildRpm and buildDeb are implicitly created, but can still be configured if needed

buildRpm {
    arch = I386
}

标准输出如下

project]$ /opt/gradle/bin/gradle  build
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava
:processTestResources
:testClasses
:test
:jacocoTestReport
:check
:build

BUILD SUCCESSFUL

Total time: 11.258 secs

This build could be faster, please consider using the Gradle Daemon:     https://docs.gradle.org/2.9/userguide/gradle_daemon.html

对于我在上面忽略的任何内容的任何指示都将不胜感激。 如果有任何 standard/convention 未被遵循

,也请随时告诉我

谢谢

您需要运行 buildRpm 任务。

gradle buildRpm

如果您希望此任务在 运行ning gradle build 时 运行 只需在 build.gradle 文件中配置依赖项

build.dependsOn buildRpm

此外,您可以在 rpm 任务中添加以下变量,使您的 RPM 更标准 requires('package name') //required package to 运行 你的RPM要预装,如果不是的话会失败。 preInstall('path_to_file') //安装RPM之前执行的脚本 preUninstall('path_to_file') //卸载RPM之前要执行的脚本 postInstall('path_to_file') //安装RPM后执行的脚本 preUninstall('path_to_file') // 卸载RPM后执行的脚本</p> <pre><code>archiveName //the name you want to give to your RPM. epoch //Epoch, defaults to 0 user //Default user to permission files to permissionGroupdisplay packageGroup buildHost summary packageDescription license packager distribution vendor url type //type e.g. binary //below three variables are used for signing of the RPM signingKeyId signingKeyPassphrase signingKeyRingFile sourcePackage //if you want to include some files in your rpm def fileToInclude = fileTree(dir:"pathToFile", include : "file" ) from (fileToInclude) { fileMode 0500 // file level permission into "installation Location" //locationToPlaceTheFile }

了解更多详情,例如参考 this link