简体   繁体   中英

can not create RPM using gradle

I am new to java/gradle setup and was able to build a jar file using example provided here . Also implemented Jacoco code coverage tool on same.
But running into following issue

  • Unable to build an RPM, Tried ospackage-plugin but its just doesnt generates anything ( used example provided on plugin's github page )
  • Jacoco not generating highlighted source code html files ? Its generating till method breakdown like this but not able to generate individual source code files

My build.gradle file is as below

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
}

The STDOUT is as following

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

Any pointers on whatever i am overlooking above will be highly appreciated. Also feel free to let me know in case any standard/convention is not followed

Thanks

You need to run the buildRpm task.

gradle buildRpm

If you want this task to run when running gradle build just configure a dependency in your build.gradle file

build.dependsOn buildRpm

In addition you can add below variables in your rpm task to make your RPM more standard requires('package name') //required package to run your RPM to be pre installed, will fail if it is not. preInstall('path_to_file') //script to be executed before installing RPM preUninstall('path_to_file') //script to be executed before uninstalling RPM postInstall('path_to_file') //script to be executed after installing RPM preUninstall('path_to_file') // script to be executed after uninstalling RPM requires('package name') //required package to run your RPM to be pre installed, will fail if it is not. preInstall('path_to_file') //script to be executed before installing RPM preUninstall('path_to_file') //script to be executed before uninstalling RPM postInstall('path_to_file') //script to be executed after installing RPM preUninstall('path_to_file') // script to be executed after uninstalling RPM

 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 eg 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 } 

for more details and eg refer this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM