Skip to content

Commit 098ad97

Browse files
committed
Publish jars to Maven Central instead of OSS
1 parent b6032e5 commit 098ad97

6 files changed

Lines changed: 43 additions & 111 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ plugins {
99
id 'java'
1010
id 'jacoco'
1111
id 'com.github.kt3k.coveralls' version '2.12.2'
12+
id "com.vanniktech.maven.publish" version "0.36.0"
1213
}
1314

1415
group='com.codeborne'
15-
archivesBaseName = 'xls-test'
16-
version='1.7.2'
16+
version='1.8.0-SNAPSHOT'
1717

1818
defaultTasks 'test', 'publishToMavenLocal'
1919

gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
org.gradle.jvmargs=-Dfile.encoding=UTF-8
2+
3+
mavenCentralPublishing=true
4+
mavenCentralAutomaticPublishing=true
5+
signAllPublications=true

gradle/compilation.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
[compileJava, compileTestJava]*.options.collect {options -> options.debug = true}
33
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
44

5-
sourceCompatibility = 1.8
6-
targetCompatibility = 1.8
5+
java {
6+
sourceCompatibility = 1.8
7+
targetCompatibility = 1.8
8+
toolchain {
9+
languageVersion = JavaLanguageVersion.of(11)
10+
}
11+
}

gradle/publish.gradle

Lines changed: 29 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,54 @@
1-
apply plugin: 'maven-publish'
2-
31
jar {
42
manifest {
53
attributes(
4+
"Automatic-Module-Name": project.group + '.' + project.name.replace('-', '.'),
65
"Implementation-Title": project.group + '.' + project.name,
7-
"Implementation-Version": version,
8-
"Implementation-Vendor": "Codeborne"
9-
)
6+
"Implementation-Version": archiveVersion,
7+
"Implementation-Vendor": "Codeborne")
108
}
119
}
1210

13-
tasks.register('sourcesJar', Jar) {
14-
dependsOn classes
11+
task sourcesJar(type: Jar) {
1512
archiveClassifier = 'sources'
16-
from sourceSets.main.allSource
13+
from sourceSets.main.allJava
1714
}
1815

19-
tasks.withType(Javadoc).configureEach {
20-
failOnError = false
16+
javadoc {
2117
options.encoding = 'UTF-8'
22-
source = sourceSets.main.allJava
18+
failOnError = false
2319
}
2420

25-
tasks.register('javadocJar', Jar) {
26-
dependsOn javadoc
21+
task javadocJar(type: Jar, dependsOn: javadoc) {
2722
archiveClassifier = 'javadoc'
2823
from javadoc.destinationDir
2924
}
3025

3126
if (project.hasProperty("signing.keyId")) {
32-
apply plugin: 'signing'
33-
34-
signing {
35-
afterEvaluate {
36-
sign publishing.publications.mavenJava
37-
}
38-
}
39-
}
40-
41-
artifacts {
42-
archives jar
43-
archives sourcesJar
44-
archives javadocJar
45-
}
46-
47-
publishing {
48-
if (project.hasProperty("sonatypeUsername")) {
49-
repositories {
50-
maven {
51-
name 'Maven'
52-
url project.version.endsWith("-SNAPSHOT") ?
53-
'https://oss.sonatype.org/content/repositories/snapshots/' :
54-
'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
55-
credentials {
56-
username "$sonatypeUsername"
57-
password "$sonatypePassword"
27+
mavenPublishing {
28+
pom {
29+
name = "xls-test"
30+
description = "XLS Test: Excel testing library"
31+
inceptionYear = "2015"
32+
url = "https://github.com/codeborne/xls-test"
33+
licenses {
34+
license {
35+
name = "MIT"
36+
url = "https://opensource.org/licenses/MIT"
37+
distribution = "https://opensource.org/licenses/MIT"
5838
}
5939
}
60-
}
61-
}
62-
63-
publications {
64-
mavenJava(MavenPublication) {
65-
groupId "${project.group}"
66-
artifactId "${project.name}"
67-
68-
from components.java
69-
artifact(sourcesJar)
70-
artifact(javadocJar)
71-
72-
pom {
73-
name = archivesBaseName
74-
description = 'XLS Test: Excel testing library, created by Codeborne.'
75-
url = 'https://github.com/codeborne/xls-test'
76-
licenses {
77-
license {
78-
name = 'MIT'
79-
url = 'https://opensource.org/licenses/MIT'
80-
}
81-
}
82-
developers {
83-
developer {
84-
id = 'asolntsev'
85-
name = 'Andrei Solntsev'
86-
}
87-
}
88-
scm {
89-
connection = 'scm:git@github.com:codeborne/xls-test.git'
90-
developerConnection = 'scm:git@github.com:codeborne/xls-test.git'
91-
url = 'https://github.com/codeborne/xls-test'
40+
developers {
41+
developer {
42+
id = 'asolntsev'
43+
name = 'Andrei Solntsev'
44+
url = "https://github.com/asolntsev/"
9245
}
9346
}
47+
scm {
48+
url = "https://github.com/codeborne/xls-test"
49+
connection = "scm:git:git://github.com/codeborne/xls-test.git"
50+
developerConnection = "scm:git:ssh://git@github.com/codeborne/xls-test.git"
51+
}
9452
}
9553
}
9654
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'xls-test'

xls-test.iml

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)