Does anyone know if a good test coverage tool (preferably Gradle plugin) exists for Kotlin? I've looked into JaCoCo a bit, but it doesn't seem to reliably support Kotlin.
As requested, here is an example build.gradle that uses Kotlin, and incorporates both Jacoco and Sonarqube integration, produces a jar and sources, and ties in Detekt for static analysis.
I had to manually add a couple things as my work build has jacoco applied by an in-house plugin.
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.2.10'
id 'org.jetbrains.kotlin.plugin.spring' version '1.2.10'
id 'org.springframework.boot' version '1.5.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.4.RELEASE'
id 'io.gitlab.arturbosch.detekt' version '1.0.0.RC6'
id "org.sonarqube" version "2.6.2".
}
apply plugin: 'jacoco'
ext {
springBootVersion = '1.5.9.RELEASE'
springCloudVersion = 'Dalston.SR4'
kotlinVersion = '1.2.10'
detektVersion = '1.0.0.RC6'.
}
//======================= Project Info =============================================
group = 'group'
version = '0.14'
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-starter- parent:$springBootVersion")
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion"
}
}
repositories {
jcenter()
}
//======================= Dependencies =============================================
dependencies {
// Version MUST be explicitly set here or else dependent projects will not be able to build as Gradle will not know
// what version to use
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile 'org.springframework.boot:spring-boot-starter-web'
compile('org.springframework.ws:spring-ws-support') {
exclude(module: 'javax.mail')
}
compile 'org.springframework.boot:spring-boot-starter-actuator'
// Spring security
compile 'org.springframework.security:spring-security-web'
compile 'org.springframework.security:spring-security-config'
compile 'javax.servlet:javax.servlet-api'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
compile('org.apache.httpcomponents:httpclient')
compile 'com.nimbusds:nimbus-jose-jwt:4.23'
}
//======================= Tasks =============================================
defaultTasks 'build'
tasks.bootRepackage.enabled = false
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = 1.8
freeCompilerArgs = ["-Xjsr305=strict"]
}
}
compileJava.options.encoding = 'UTF-8'
test.testLogging.exceptionFormat = 'full'
// ********************************
ext.coverageExclusions = [
// Configuration
'com.bns.pm.config.*',
// data classes
'com.bns.pm.domain.*',
// Account Service domain objects
'com.bns.pm.account.domain.*',
// Other items
'com.bns.pm.exceptions.DataPowerFaultException.Companion',
'com.bns.pm.controllers.ServiceExceptionHandler*',
'com.bns.pm.service.callback.DPWebServiceMessageCallback',
'com.bns.pm.service.HealthCheckService',
'com.bns.pm.util.SystemPropertiesUtilKt',
]
check.dependsOn jacocoTestCoverageVerification
jacocoTestCoverageVerification {
violationRules {
rule {
element = 'CLASS'
// White list
excludes = coverageExclusions
limit {
minimum = 0.70
}
}
}
}
jacocoTestReport {
description 'Generates Code coverage report. Fails build if it does not meet minimum coverage.'
reports {
xml.enabled = true //XML required by coveralls and for the below coverage checks
html.enabled = true
csv.enabled = false
}
def reportExclusions = coverageExclusions.collect {
it.replaceAll('\\.', '/') + (it.endsWith('*') ? '' : '*')
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, excludes: reportExclusions)
})
}
}
test.finalizedBy jacocoTestReport
afterEvaluate {
sonarqube {
properties {
property 'sonar.jacoco.reportPath', "${buildDir}/jacoco/test.exec"
property "detekt.sonar.kotlin.config.path", "detekt.yml"
property 'sonar.java.binaries', "$projectDir/build/classes/kotlin"
property 'sonar.coverage.exclusions', coverageExclusions.collect {
'**/' + it.replaceAll('\\.', '/') + (it.endsWith('*') ? '' : '*')
}
}
}
}
// Ensure source code is published to Artifactory
// Have to redefine publishing with new name as Accelerator Plugin already defined mavenJava
task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier 'sources'
}
publishing {
publications {
mavenJava2(MavenPublication) {
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
}
}
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = "${artifactory_projectRepoKey}"
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications('mavenJava2')
}
}
}
artifactoryPublish {
dependsOn jar
}
detekt {
version = detektVersion
profile("main") {
input = "$projectDir/src"
config = "$projectDir/detekt.yml"
filters = ".*/resources/.*,.*/tmp/.*"
output = "$project.buildDir/reports/detekt"
}
}
check.dependsOn detektCheck
Good news: there is a new kotlinx-kover Gradle plugin, compatible with JaCoCo and IntelliJ.
plugins {
id("org.jetbrains.kotlinx.kover") version "0.5.0"
}
Once applied, the plugin can be used out of the box without additional configuration.
Watch its YouTube announcement video and also track its roadmap from this youtrack issue.
As said in the video, it solves the problem with inline functions and more.
Related
When I set an IntelliJ version as described below I have the following error
intellij {
version '2022.3'
}
A problem occurred configuring root project 'brs-plugin'.
Failed to notify project evaluation listener.
Failed to query the value of extension 'intellij' property 'version'.
> The value for the 'intellij.version' property was not specified, see:
https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#intellij-extension-version
But if I add the equal operator have the following
intellij {
version = '2022.3'
}
Caused by: org.gradle.internal.exceptions.DefaultMultiCauseException:
Could not resolve com.jetbrains.intellij.idea:ideaIC:2022.3.
This is my full version of the build.gradle. As you can see I have added several repos, but it's not helped. Full version of the project you can found on this link
How to fix my problem? Regards
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://www.jetbrains.com/intellij-repository/releases"
}
maven {
url "https://www.jetbrains.com/intellij-repository/snapshots"
}
maven {
url "https://cache-redirector.jetbrains.com/intellij-dependencies"
}
}
}
plugins {
id "org.jetbrains.intellij" version "1.11.0"
id "org.jetbrains.grammarkit" version "2020.1"
}
configurations {
configurations.compileOnly.setCanBeResolved(true)
}
group 'com.interfaced'
version = '0.2.7'
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.intellij'
sourceSets {
all {
java.srcDirs += ['src/main/gen']
kotlin.srcDirs += ['src/main/kotlin']
resources.srcDirs = ['src/main/resources']
}
}
intellij {
version = '2022.3'
}
grammarKit {
jflexRelease = '1.7.0-2'
}
repositories {
mavenCentral()
maven {
url "https://cache-redirector.jetbrains.com/intellij-dependencies"
}
}
dependencies {
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: '1.7.22'
implementation files('jars/grammar-kit.jar')
implementation group: 'junit', name: 'junit', version: '4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: '1.6.0'
}
import org.jetbrains.grammarkit.tasks.GenerateLexer
import org.jetbrains.grammarkit.tasks.GenerateParser
def GENERATE_GROUP = 'Generate'
task setConfiguration() {
configurations.compileOnly.setCanBeResolved(true)
}
task generateLexer(type: GenerateLexer) {
source = "src/main/grammar/BrightScript.flex"
targetDir = "src/main/gen/com/interfaced/brs/lang/lexer"
targetClass = "_BrsLexer"
skeleton = "src/main/grammar/idea-flex.skeleton"
purgeOldFiles = true
description = 'Generate Lexer Java sources for BrightScript'
group = GENERATE_GROUP
}
task generateParser(type: GenerateParser) {
source = "src/main/grammar/BrightScript.bnf"
targetRoot = 'src/main/gen'
pathToParser = 'src/main/gen/com/interfaced/brs/lang/BrsParser.java'
pathToPsiRoot = 'src/main/gen/com/interfaced/brs/lang/psi'
purgeOldFiles = true
description = 'Generate Parser Java sources for BrightScript'
group = GENERATE_GROUP
// patch up to date check
outputs.upToDateWhen { false }
}
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
compileKotlin.dependsOn(setConfiguration, generateLexer, generateParser)
I have been trying to run spotbugs plugin on my projects using a global build.gradle setup. The plugin is added and seems that build is running. Build and spotbugsMain both are successful when I run them using
./gradlew :com.myproject.something:build --stacktrace
./gradlew :com.myproject.something:spotbugsMain --stracktrace
But if I understand it correctly, it should generate a report (in spotbugs folder?) under build-gradle folder.
I do not see anything generated. spotbugs folder itself is not showing up.
Here is my build.gradle. Can someone please tell me what I am doing wrong? I am not sure I understand concepts of gradle completely but I have tried to use other references.
Minimal working SpotBugs setup for Android Studio
plugins {
id "com.github.spotbugs" version "4.7.2" apply false
}
group = 'com.myproject'
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'com.github.spotbugs'
buildDir = 'build-gradle'
spotbugs {
toolVersion = '4.3.0'
ignoreFailures = false
showStackTraces = true
showProgress = true
effort = 'max'
reportLevel = 'high'
maxHeapSize = '1g'
reportsDir = file("$buildDir/spotbugs")
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
group 'Verification'
description 'Run Spotbugs on this project.'
dependsOn 'assemble'
reports {
xml.enabled = false
html.enabled = true
}
classDirs = files('$buildDir.absolutePath/build-gradle/classes/java/main')
sourceDirs = files('$buildDir.absolutePath/src/main/java')
}
repositories {
// the order here is important. Repositories are queried in the exact order specified here
mavenLocal()
mavenCentral()
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/snapshots')
allowInsecureProtocol = true
}
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/releases')
allowInsecureProtocol = true
}
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/myproject')
allowInsecureProtocol = true
}
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/thirdparty')
allowInsecureProtocol = true
}
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
test {
filter {
excludeTestsMatching "*IT"
environment 'RESOURCES_PATH', 'build-gradle/resources/test'
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
}
UPDATE : 07/26/2021
I tried to run full build including all the subprojects instead of individual subproject as mentioned above. I used command
./gradlew clean build --stacktrace
This time, it did not work! The full build is throwing an error as below.
Task :com.vmturbo.mediation.applicationserver.jboss:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':com.myproject.something:compileJava'.
Could not resolve all files for configuration ':com.myproject.something:compileClasspath'.
Could not find com.github.spotbugs:spotbugs-annotations:4.7.2.
Searched in the following locations:
- file:/Users/myuser/.m2/repository/com/github/spotbugs/spotbugs-annotations/4.7.2/spotbugs-annotations-4.7.2.pom
- https://repo.maven.apache.org/maven2/com/github/spotbugs/spotbugs-annotations/4.7.2/spotbugs-annotations-4.7.2.pom
- http://build.myproject.com:8081/nexus/content/repositories/snapshots/com/github/spotbugs/spotbugs-annotations/4.7.2/spotbugs-annotations-4.7.2.pom
- http://build.myproject.com:8081/nexus/content/repositories/releases/com/github/spotbugs/spotbugs-annotations/4.7.2/spotbugs-annotations-4.7.2.pom
- http://build.myproject.com:8081/nexus/content/repositories/myproject/com/github/spotbugs/spotbugs-annotations/4.7.2/spotbugs-annotations-4.7.2.pom
- http://build.myproject.com:8081/nexus/content/repositories/thirdparty/com/github/spotbugs/spotbugs-annotations/4.7.2/spotbugs-annotations-4.7.2.pom
Required by:
project :com.myproject.something
Any idea about the problem? It seems full build does not work with above error and if I try to build only 1 subproject com.myproject.something then it runs fine but does not generate anything related to spotbugs.
I found the problem. I am not entirely sure why though. This thread helped.
https://github.com/spotbugs/spotbugs/issues/1027
In my build.gradle I was using this block ->
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
group 'Verification'
description 'Run Spotbugs on this project.'
dependsOn 'assemble'
reports {
xml.enabled = false
html.enabled = true
}
classDirs = files('$buildDir.absolutePath/build-gradle/classes/java/main')
sourceDirs = files('$buildDir.absolutePath/src/main/java')
}
But instead when I changed that to this, all seemed to work and spotbugs folder and under it, report got generated. Apparently, I did not need to provide class and source folders at all.
spotbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}
spotbugsTest {
reports {
xml.enabled = false
html.enabled = true
}
}
FINAL build.gradle file
plugins {
id "com.github.spotbugs" version "4.7.2" apply false
}
group = 'com.myproject'
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'com.github.spotbugs'
buildDir = 'build-gradle'
spotbugs {
toolVersion = '4.3.0'
ignoreFailures = false
showStackTraces = true
showProgress = true
effort = 'max'
reportLevel = 'high'
maxHeapSize = '1g'
reportsDir = file("$buildDir/spotbugs")
}
spotbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}
spotbugsTest {
reports {
xml.enabled = false
html.enabled = true
}
}
repositories {
// the order here is important. Repositories are queried in the exact order specified here
mavenLocal()
mavenCentral()
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/snapshots')
allowInsecureProtocol = true
}
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/releases')
allowInsecureProtocol = true
}
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/myproject')
allowInsecureProtocol = true
}
maven {
url = uri('http://build.myproject.com:8081/nexus/content/repositories/thirdparty')
allowInsecureProtocol = true
}
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
test {
filter {
excludeTestsMatching "*IT"
environment 'RESOURCES_PATH', 'build-gradle/resources/test'
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
}
Ran these commands and they succeeded - meaning that I got spotbugs errors in code and build failed! which is what I was looking for!
./gradlew check and ./gradlew clean build --stacktrace
7 SpotBugs violations were found. See the report at: file:///Users/myuser/com.myproject.something/build-gradle/spotbugs/test.html
You can refer to this answer:
Minimal working SpotBugs setup for Android Studio.
Following which I let my android project run successfully and got the spotbugs check report. The report will be generated in path of {module_name}/build/spotbugsReports/main.html. The running command can be ./gradlew build or ./gradlew spotbugsMain.
In build.gradle of app module:
apply plugin: 'com.github.spotbugs' // <- Add this
spotbugs {
toolVersion = "3.1.3"
ignoreFailures = false
showProgress = true
reportsDir = file("$project.buildDir/spotbugsReports")
effort = "max"
reportLevel = "high"
}
tasks.withType(com.github.spotbugs.SpotBugsTask) {
group 'Verification'
description 'Run Spotbugs on this project.'
// You'll also need to enable the HTML report and disable XML report, to see a human-readable format.
reports {
xml.enabled = false
html.enabled = true
}
dependsOn 'assemble'
classes = files("$projectDir.absolutePath/build/intermediates/javac")
source = fileTree('src/main/java') // Only needed on gradle 4/5
}
// This block is only needed for gradle 4/5 only.
// It's for SpotBugs to create a 'spotbugsMain' gradle task.
sourceSets {
main {
java.srcDirs = []
}
}
android {
...
}
dependencies {
...
}
In build.gradle of root project:
buildscript {
repositories {
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
}
}
allprojects {
repositories {
...
}
}
The Gradle Wrapper Version of my project is gradle-4.10.1-all.zip. Pay attention that when you'are using Gradle v4 - lastest Spotbugs version you could use only 1.6.6. Ref: https://gist.github.com/mik9/fdde79052fef7f03c4325734701a39d7
I'm trying to publish my java library to JitPack using the maven-publish plugin in Gradle. I have done all that the docs have said, and JitPack says publishing was a success, but it seems like I cannot install my library, even if I just copy and paste straight from JitPack's repository.
I tried pushing straight to master on the github repo. I also changed the artifact id to sertain-core and the version to 1.0.0, as that is what is specified in the publish block. I even checked the repository url and downloaded the jar manually, and it worked fine. It seems that the only problem is downloading the jar using it's maven coordinates.
Here's my library's build file (the dependencies block is in another file and works fine):
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val ktlint by configurations.creating
plugins {
kotlin("jvm") version "1.3.50"
`maven-publish`
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(kotlin("reflect", "1.3.50"))
implementation("org.jetbrains.kotlinx", "kotlinx-coroutines-core", "1.3.1")
implementation("org.jetbrains.kotlin", "kotlin-reflect", "1.3.50")
implementation("edu.wpi.first.wpilibj", "wpilibj-java", "2019.4.1")
implementation("edu.wpi.first.hal", "hal-java", "2019.4.1")
implementation("edu.wpi.first.ntcore", "ntcore-java", "2019.4.1")
implementation("com.ctre.phoenix", "api-java", "5.14.1")
ktlint("com.pinterest:ktlint:0.34.2")
}
tasks {
val ktlint by creating(JavaExec::class) {
group = "verification"
description = "Check Kotlin code style."
classpath = configurations["ktlint"]
main = "com.pinterest.ktlint.Main"
args = listOf("src/**/*.kt")
}
"check" {
dependsOn(ktlint)
}
create("ktlintFormat", JavaExec::class) {
group = "formatting"
description = "Fix Kotlin code style deviations."
classpath = configurations["ktlint"]
main = "com.pinterest.ktlint.Main"
args = listOf("-F", "src/**/*.kt")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs += setOf("-Xuse-experimental=kotlin.Experimental")
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = "org.sert2521.sertain"
artifactId = "sertain-core"
version = "1.0.0"
from(components["java"])
artifact("$buildDir/libs/${project.name}.jar")
}
}
}
And here's the build file of the project that should install the library
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.50"
id "edu.wpi.first.GradleRIO" version "2019.4.1"
}
ext.kotlinVersion = "1.3.50"
tasks.whenTaskAdded { task ->
if (task.name == "deploy" || task.name == "deployMain" || task.name == "simulateJava") task.dependsOn "assemble"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "http://first.wpi.edu/FRC/roborio/maven/release" }
maven { url "http://devsite.ctr-electronics.com/maven/release" }
maven { url "https://www.kauailabs.com/maven2" }
maven { url "http://www.revrobotics.com/content/sw/max/sdk/maven/" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1"
compile "com.kauailabs.navx.frc:navx-java:3.1.344"
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
implementation 'com.github.SouthEugeneRoboticsTeam:sertain:publishing-f3bdecc967-1'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
deploy {
targets {
roboRIO("roborio") {
team = frc.getTeamOrDefault(2521)
}
}
artifacts {
frcJavaArtifact("frcJava") {
targets << "roborio"
debug = frc.getDebugOrDefault(false)
}
fileTreeArtifact("frcStaticFileDeploy") {
files = fileTree(dir: "src/main/deploy")
targets << "roborio"
directory = "/home/lvuser/deploy"
}
}
}
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
manifest {
attributes(
"Main-Class": "org.sert2521.example.MainKt"
)
}
}
wrapper {
gradleVersion = "5.0"
}
There are no error messages when publishing the library. When installing the library, there is only the usual error from gradle not being able to find a dependency.
Here's my complete build.gradle
buildscript {
ext.kotlinVersion = '1.3.10'
ext.dokkaVersion = '0.9.17'
repositories { mavenLocal() }
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion"
}
}
plugins {
id 'com.github.hierynomus.license' version '0.15.0'
id 'io.codearte.nexus-staging' version '0.11.0'
id 'maven-publish'
}
group = 'org.jetbrains.xodus'
version = hasProperty('xodusVersion') ? project.xodusVersion : ''
def isSnapshot = version.endsWith('SNAPSHOT')
def isDailyBuild = hasProperty('dailyBuild') ? project.dailyBuild : false
def mavenPublishUrl = hasProperty('mavenPublishUrl') ? project.mavenPublishUrl : ''
def mavenPublishUsername = hasProperty('mavenPublishUsername') ? project.mavenPublishUsername : ''
def mavenPublishPassword = hasProperty('mavenPublishPassword') ? project.mavenPublishPassword : ''
def signingKeyId = hasProperty('signingKeyId') ? project.signingKeyId : ''
def signingPassword = hasProperty('signingPassword') ? project.signingPassword : ''
def signingSecretKeyRingFile = hasProperty('signingSecretKeyRingFile') ? project.signingSecretKeyRingFile : '../key.gpg'
static def shouldDeploy(project) {
return project.version.length() > 0 && !(project.name in ['benchmarks', 'samples'])
}
task wrapper(type: Wrapper) {
gradleVersion = '3.5.1'
}
defaultTasks 'assemble'
// Use nexus-staging-plugin to workaround https://issues.sonatype.org/browse/OSSRH-5454
nexusStaging {
username = mavenPublishUsername
password = mavenPublishPassword
delayBetweenRetriesInMillis = 30000
stagingProfileId = "89ee7caa6631c4"
}
subprojects {
apply plugin: 'license'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'org.jetbrains.dokka'
sourceCompatibility = 1.7
compileJava.options.encoding = 'UTF-8'
group = rootProject.group
version = rootProject.version
archivesBaseName = rootProject.name + '-' + project.name
license {
header rootProject.file('license/copyright.ftl')
strictCheck true
ext.inceptionYear = 2010
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.owner = 'JetBrains s.r.o.'
include "**/*.kt"
include "**/*.java"
mapping {
kt = 'JAVADOC_STYLE'
}
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
}
// tests for most of sub-projects run with database encryption turned on
if (!(project.name in ['benchmarks', 'compress', 'crypto', 'openAPI', 'samples', 'utils'])) {
test {
systemProperty 'exodus.cipherId', 'jetbrains.exodus.crypto.streamciphers.ChaChaStreamCipherProvider'
systemProperty 'exodus.cipherKey', '000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f'
systemProperty 'exodus.cipherBasicIV', '314159262718281828'
// uncomment the following line to run tests in-memory
//systemProperty 'exodus.log.readerWriterProvider', 'jetbrains.exodus.io.inMemory.MemoryDataReaderWriterProvider'
}
dependencies {
testCompile project(':crypto')
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jar {
manifest {
attributes 'Implementation-Title': archivesBaseName, 'Implementation-Version': version
}
}
test {
minHeapSize = '1g'
maxHeapSize = '1g'
//jvmArgs = ['-ea', '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=2808']
//testLogging.showStandardStreams = true
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
duplicatesStrategy 'exclude'
includeEmptyDirs false
from javadoc.destinationDir
}
javadoc.failOnError = false
// work around for Java 8 javadoc which is too strict
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
task sourceJar(type: Jar) {
classifier = 'sources'
duplicatesStrategy 'exclude'
includeEmptyDirs false
from project.sourceSets.main.java
from project.sourceSets.main.kotlin
}
// configuring projects with Kotlin sources
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
compile 'io.github.microutils:kotlin-logging:1.5.4'
}
compileKotlin {
kotlinOptions {
languageVersion = '1.2'
apiVersion = '1.2'
}
}
compileTestKotlin {
kotlinOptions {
languageVersion = '1.2'
apiVersion = '1.2'
}
}
dokka {
jdkVersion = 7
packageOptions {
reportUndocumented = false
}
}
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
outputFormat = 'javadoc'
outputDirectory = "$buildDir/javadoc"
}
javadocJar {
dependsOn dokkaJavadoc
from dokkaJavadoc.outputDirectory
}
artifacts {
archives jar, javadocJar, sourceJar
}
if (!isSnapshot && signingKeyId.length() > 0) {
ext.'signing.keyId' = signingKeyId
ext.'signing.password' = signingPassword
ext.'signing.secretKeyRingFile' = signingSecretKeyRingFile
}
afterEvaluate { project ->
if (shouldDeploy(project)) {
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
if (isDailyBuild) {
repository(url: "https://api.bintray.com/maven/jetbrains/xodus/" + archivesBaseName + "/;publish=1") {
authentication(userName: mavenPublishUsername, password: mavenPublishPassword)
}
} else {
repository(url: mavenPublishUrl) {
authentication(userName: mavenPublishUsername, password: mavenPublishPassword)
}
}
pom.project {
name 'Xodus'
description 'Xodus is pure Java transactional schema-less embedded database'
packaging 'jar'
url 'https://github.com/JetBrains/xodus'
scm {
url 'https://github.com/JetBrains/xodus'
connection 'scm:git:https://github.com/JetBrains/xodus.git'
developerConnection 'scm:git:https://github.com/JetBrains/xodus.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'JetBrains'
name 'JetBrains Team'
organization 'JetBrains s.r.o'
organizationUrl 'http://www.jetbrains.com'
}
}
}
}
}
}
signing {
required { !isSnapshot && signingKeyId.length() > 0 && gradle.taskGraph.hasTask('uploadArchives') }
sign configurations.archives
}
}
}
}
What could be missing in the configuration/setting that is preventing the jars to be copied to the local Maven folder?
The build uses the maven plugin; you should use gradlew install to publish to the local repo. See the gradle.maven.plugin docs.
I tried building the xodus project from github- installing breaks on a "samples" project, probably because no jar is created from it. Anyway that module doesn't need to be installed (it only contains example code). So you can use gradlew clean install -x :samples:install
I have created a Kotlin Vertx web app which runs with Gradle. But When I try to debug it by running Intellij debug configuration, the breakpoints aren't hitting. How can I make those breakpoints work ?
buildscript {
ext {
kotlinVersion = '1.2.60'
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
id 'jacoco'
id 'de.jansauer.printcoverage' version '2.0.0'}
jacoco{
toolVersion = '0.8.2'
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.1
}
}
}
}
jacocoTestReport {
reports {
csv.enabled true
xml.enabled true
html {
enabled true
destination file("$buildDir/reports/jacoco")
}
}
executionData(test)
}
tasks.build.dependsOn(jacocoTestReport)
printcoverage {
coverageType = 'INSTRUCTION'
}
apply plugin: 'kotlin'
ext {
kotlinVersion = '1.2.60'
vertxVersion = '3.6.2'
junitJupiterEngineVersion = '5.2.0'
}
repositories {
mavenLocal()
jcenter()
}
group 'com.joyfulyell'
version '1.0-SNAPSHOT'
sourceCompatibility = '1.8'
mainClassName = 'io.vertx.core.Launcher'
def mainVerticleName = 'io.vertx.starter.MainVerticle'
def watchForChange = 'src/**/*'
def doOnChange = './gradlew classes'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
compile "io.vertx:vertx-core:$vertxVersion"
compile "io.vertx:vertx-web:$vertxVersion"
compile "io.vertx:vertx-lang-kotlin:$vertxVersion"
compile "io.vertx:vertx-mongo-client:$vertxVersion"
implementation 'org.kodein.di:kodein-di-generic-jvm:6.0.1'
compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.+"
compile 'com.beust:klaxon:5.0.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
testImplementation "io.vertx:vertx-junit5:$vertxVersion"
testRuntime("org.junit.jupiter:junit-jupiter-engine:$junitJupiterEngineVersion")
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
shadowJar {
classifier = 'fat'
manifest {
attributes 'Main-Verticle': mainVerticleName
}
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
}
test {
useJUnitPlatform()
testLogging {
events 'PASSED', 'FAILED', 'SKIPPED'
}
reports {
junitXml.enabled = true
html.enabled = true
}
jacoco{
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpDir = file("$buildDir/jacoco/classpathdumps")
}
}
run {
args = ['run', mainVerticleName,
"--redeploy=$watchForChange",
"--launcher-class=$mainClassName",
"--on-redeploy=$doOnChange"
]
}
task wrapper(type: Wrapper) {
gradleVersion = '5.0'
}
You should be able to run debug just fine by configuring Gradle as follows:
And hitting the Debug button. Tested it using your configuration.
Just make sure that you specify the correct verticle name in your build.gradle:
def mainVerticleName = 'io.vertx.starter.MainVerticle'