New version of library synchronized with jcenter - bintray

I have a library in Bintray synchronized with JCenter. https://bintray.com/bmsolution/Android/RestManager/0.2
But when I uploaded new version by gradle plugin - it is on Bintray (link) but it isn't on jcenter (link)
Do you have to wait for synchronization so long or do I do something wrong?
Fragment of my gradle file responsible for upload:
def libVersion = "0.2"
ext {
PUBLISH_GROUP_ID = 'pl.bms'
PUBLISH_ARTIFACT_ID = 'network'
PUBLISH_VERSION = libVersion
}
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
publishing {
publications {
MyPublication(MavenPublication) {
artifact sourcesJar
artifact("$buildDir/outputs/aar/network-release.aar")
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.implementation.allDependencies.each {
// Ensure dependencies such as fileTree are not included in the pom.
if (it.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
publish = true
publications = ['MyPublication']
override = true
pkg {
repo = "Android"
name = "RestManager"
userOrg = 'bmsolution'
licenses = ['Apache-2.0']
vcsUrl = "https://bitbucket.org/libandroid/rest-manager"
issueTrackerUrl = "https://bitbucket.org/libandroid/rest-manager/issues"
version {
name = libVersion
released = new Date()
vcsTag = libVersion
}
}
}

If you didn't change any group/artifactId, then based on this post I'd recommend to wait ~24 hours for it to syncronize and then contact support#jfrog.com.
If you changed your group/artifactId then you to relink bintray and jcenter which could also be done with a mail to support or by republishing.

Related

Getting newly published package from JitPack fails

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.

Gradle publishToMavenLocal not copying jars to local Maven repository

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

Gradle does not copy jars to Maven .m2 folder

What could be missing in this build.gradle file that prevents the publishToMavenLocal not to copy files to the .m2 folder?
The script does have the 'maven-publish' plugin.
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
}
}
}
}
Your build does not configure any publications, hence the publishToMavenLocal task is a noop:
$ ./gradlew --console=verbose publishToMavenLocal
> Task :publishToMavenLocal UP-TO-DATE
BUILD SUCCESSFUL in 0s
When you configure a publication as in this example …
task buildMyArtifact(type: Zip) {
// TODO using the build script as a sample file here; use whatever makes
// sense for your project
from 'build.gradle'
archiveBaseName = 'whateverNameInBuildDir'
destinationDirectory = buildDir
}
publishing {
publications {
myPublication(MavenPublication) {
artifact buildMyArtifact
groupId 'com.example'
artifactId 'my-module'
version '1.0.0'
}
}
}
… then the publishToMavenLocal task installs the publication into the local Maven repository:
$ ./gradlew --console=verbose publishToMavenLocal
> Task :buildMyArtifact
> Task :generatePomFileForMyPublicationPublication
> Task :publishMyPublicationPublicationToMavenLocal
> Task :publishToMavenLocal
BUILD SUCCESSFUL in 1s
3 actionable tasks: 3 executed
$ tree ~/.m2/repository/com/example/my-module/
/home/chriki/.m2/repository/com/example/my-module/
├── 1.0.0
│   ├── my-module-1.0.0.pom
│   └── my-module-1.0.0.zip
└── maven-metadata-local.xml
1 directory, 3 files

com.jfrog.artifactory gradle plugin 401 Unauthorised

I have previously successfully set up bintray and artifactory accounts to publish snapshot versions to the OSS JFrog Artifactory repository, but after setting up a GitHub/Bintray/Artifactory organisation under the same user, I am unable to publish snapshots.
When attempting to run
./gradlew artifactoryPublish -Dsnapshot=true -DbintrayUser=myBintrayUser -DbintrayKey=myBintrayApiKey -DbuildNumber=#
I get the following error:
java.io.IOException: Failed to deploy file. Status code: 401 Response message: Artifactory returned the following errors:
Unauthorized Status code: 401
I've tried using both bintray users (my personal and the organisation) but get the same response. I've also tried regenerating a new API key at https://bintray.com/profile/edit, but has not worked (and now also seems to be out of sync with the key at https://oss.jfrog.org/artifactory/webapp/#/profile) which I can't edit.
The build.gradle file is:
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
}
plugins {
id 'java-library'
id 'maven'
id 'maven-publish'
// Automatic SEMVER
// ./gradlew release
id 'net.vivin.gradle-semantic-build-versioning' version '4.0.0' apply false
// SNAPSHOT publishing to oss-jfrog-artifactory
// ./gradlew artifactoryPublish -Dsnapshot=true -DbintrayUser=<YOUR_USER_NAME> -DbintrayKey=<YOUR_API_KEY> -DbuildNumber=NNN
id 'com.jfrog.artifactory' version '4.6.2'
// RELEASE publishing to bintray
// ./gradlew bintrayUpload -DbintrayUser=<YOUR_USER_NAME> -DbintrayKey=<YOUR_API_KEY>
id 'com.jfrog.bintray' version '1.8.1'
}
wrapper.gradleVersion = '4.5.1'
def groupName = 'noxtech'
group = 'uk.co.noxtech'
archivesBaseName = 'noxtech-java-utils'
description = 'Assorted Java 8 utilities'
def projectUrl = "https://github.com/noxtech/noxtech-java-utils"
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
api 'joda-time:joda-time:2.9.9'
implementation 'org.projectlombok:lombok:1.16.20'
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc.failOnError = false
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
scm {
url projectUrl
}
}
publishing {
publications {
mavenPublication(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
groupId = project.group
artifactId = project.archivesBaseName
version = project.version.toString()
pom.withXml {
def root = asNode()
root.appendNode('description', project.description)
root.appendNode('name', project.name)
root.appendNode('url', projectUrl)
root.children().last() + pomConfig
}
}
}
repositories {
maven {
// change to point to your repo, e.g. http://my.org/repo
url "$buildDir/repo"
}
}
}
bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : System.getenv('BINTRAY_KEY')
publications = ['mavenPublication']
pkg {
repo = "maven"
name = project.archivesBaseName
userOrg = groupName
licenses = ['Apache-2.0']
websiteUrl = projectUrl
vcsUrl = projectUrl + '.git'
issueTrackerUrl = projectUrl + '/issues'
version {
name = project.version.toString()
desc = project.description
vcsTag = project.version.toString()
released = new Date()
}
}
}
artifactory {
contextUrl = 'http://oss.jfrog.org'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
password = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : System.getenv('BINTRAY_KEY')
}
defaults {
publications('mavenPublication')
publishArtifacts = true
publishPom = true
}
}
resolve {
repoKey = 'jcenter'
}
clientConfig.info.setBuildNumber(project.hasProperty('buildNumber') ? project.property('buildNumber') : System.getenv('BUILD_NUMBER'))
}
This turned out to be a simple solution. When moving over to use the organisation from the personal account on CircleCI, the environment variables were lost.

Kotlin Test Coverage

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.

Resources