Skip to content

Commit f31e4d9

Browse files
committed
Extract publishing logic to a new publish.gradle file.
1 parent 2f74368 commit f31e4d9

File tree

2 files changed

+64
-61
lines changed

2 files changed

+64
-61
lines changed

build.gradle

+1-61
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
if (JavaVersion.current().isJava8Compatible()) {
2-
allprojects {
3-
tasks.withType(Javadoc) {
4-
options.addStringOption('Xdoclint:none', '-quiet')
5-
}
6-
}
7-
}
8-
91
apply plugin: 'java'
10-
apply plugin: 'maven'
11-
apply plugin: 'maven-publish'
122

133
repositories {
144
jcenter()
@@ -26,57 +16,7 @@ buildscript {
2616
}
2717
}
2818

29-
apply plugin: 'com.jfrog.bintray'
30-
31-
bintray {
32-
user = project.hasProperty('bintrayUser') ? project.bintrayUser : System.getenv('BINTRAY_USERNAME')
33-
key = project.hasProperty('bintrayKey') ? project.bintrayKey : System.getenv('BINTRAY_KEY')
34-
publications = ['mavenJava']
35-
pkg {
36-
repo = 'maven'
37-
name = "$project.codename"
38-
desc = "$project.description"
39-
websiteUrl = "$project.website"
40-
issueTrackerUrl = "$project.issues"
41-
licenses = ['Apache-2.0']
42-
vcsUrl = "$project.website"
43-
//noinspection GroovyAssignabilityCheck
44-
version {
45-
name = "$project.version"
46-
desc = "$project.description"
47-
released = new Date()
48-
vcsTag = "$project.website"
49-
}
50-
}
51-
}
52-
53-
publishing {
54-
publications {
55-
mavenJava(MavenPublication) {
56-
from components.java
57-
groupId "$project.group"
58-
artifactId "$project.artifact"
59-
//noinspection GroovyAssignabilityCheck
60-
version "$project.version"
61-
}
62-
}
63-
}
64-
65-
task sourcesJar(type: Jar, dependsOn: classes) {
66-
classifier 'sources'
67-
from sourceSets.main.allSource
68-
}
69-
70-
task javadocJar(type: Jar, dependsOn: javadoc) {
71-
classifier 'javadoc'
72-
//noinspection GrUnresolvedAccess
73-
from javadoc.destinationDir
74-
}
75-
76-
artifacts {
77-
archives sourcesJar
78-
archives javadocJar
79-
}
19+
apply from: "publish.gradle"
8020

8121
dependencies {
8222
compile "org.jetbrains:annotations:$project.annotationsVersion"

publish.gradle

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
apply plugin: 'java'
2+
apply plugin: 'maven'
3+
apply plugin: 'maven-publish'
4+
5+
apply plugin: 'com.jfrog.bintray'
6+
7+
if (JavaVersion.current().isJava8Compatible()) {
8+
allprojects {
9+
tasks.withType(Javadoc) {
10+
options.addStringOption('Xdoclint:none', '-quiet')
11+
}
12+
}
13+
}
14+
15+
bintray {
16+
user = project.hasProperty('bintrayUser') ? project.bintrayUser : System.getenv('BINTRAY_USERNAME')
17+
key = project.hasProperty('bintrayKey') ? project.bintrayKey : System.getenv('BINTRAY_KEY')
18+
publications = ['mavenJava']
19+
pkg {
20+
repo = 'maven'
21+
name = "$project.codename"
22+
desc = "$project.description"
23+
websiteUrl = "$project.website"
24+
issueTrackerUrl = "$project.issues"
25+
licenses = ['Apache-2.0']
26+
vcsUrl = "$project.website"
27+
//noinspection GroovyAssignabilityCheck
28+
version {
29+
name = "$project.version"
30+
desc = "$project.description"
31+
released = new Date()
32+
vcsTag = "$project.website"
33+
}
34+
}
35+
}
36+
37+
publishing {
38+
publications {
39+
mavenJava(MavenPublication) {
40+
from components.java
41+
groupId "$project.group"
42+
artifactId "$project.artifact"
43+
//noinspection GroovyAssignabilityCheck
44+
version "$project.version"
45+
}
46+
}
47+
}
48+
49+
task sourcesJar(type: Jar, dependsOn: classes) {
50+
classifier 'sources'
51+
from sourceSets.main.allSource
52+
}
53+
54+
task javadocJar(type: Jar, dependsOn: javadoc) {
55+
classifier 'javadoc'
56+
//noinspection GrUnresolvedAccess
57+
from javadoc.destinationDir
58+
}
59+
60+
artifacts {
61+
archives sourcesJar
62+
archives javadocJar
63+
}

0 commit comments

Comments
 (0)