Issue
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
Solution
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
Answered By - Mark Vieira