Skip to content

Commit 40b8708

Browse files
wiyarmirffgiraldez
authored andcommitted
Add Maven publish configurations (#115)
1 parent 93d92c2 commit 40b8708

6 files changed

+203
-54
lines changed

build.gradle

+18-6
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ buildscript {
2121
// Constants
2222
gradleVersion = '3.5'
2323
gradleVersionsPluginVersion = '0.15.0'
24-
javaVersion = '1.7'
25-
kategoryVersion = '0.3.3-SNAPSHOT'
24+
javaVersion = JavaVersion.VERSION_1_7
2625
kotlinTestVersion = '2.0.3'
2726
kotlinVersion = '1.1.4-dev-600'
2827
kotlinxCollectionsImmutableVersion = '0.1'
@@ -37,23 +36,25 @@ buildscript {
3736
dependencies {
3837
classpath "com.github.ben-manes:gradle-versions-plugin:$gradleVersionsPluginVersion"
3938
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
39+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
4040
}
4141
}
4242

43-
allprojects {
43+
subprojects { project ->
44+
45+
group = GROUP
46+
version = VERSION_NAME
47+
4448
repositories {
4549
jcenter()
4650
maven { url 'https://kotlin.bintray.com/kotlinx' }
4751
maven { url "http://dl.bintray.com/kotlin/kotlin-dev" }
4852
}
4953

5054
apply plugin: 'kotlin'
51-
apply plugin: 'maven'
5255
apply plugin: 'jacoco'
5356

54-
group = 'com.github.finecinnamon'
5557
archivesBaseName = project.name
56-
version = kategoryVersion
5758

5859
jacoco {
5960
toolVersion '0.7.8'
@@ -75,6 +76,17 @@ allprojects {
7576
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
7677
}
7778

79+
apply plugin: 'com.jfrog.bintray'
80+
bintray {
81+
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
82+
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
83+
configurations = ['archives']
84+
pkg {
85+
repo = 'maven'
86+
name = POM_ARTIFACT_ID
87+
userOrg = POM_DEVELOPER_ID
88+
}
89+
}
7890
}
7991

8092
task wrapper(type: Wrapper) {

gradle.properties

+19-31
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
1-
#
2-
# Copyright (C) 2017 The Kategory Authors
3-
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
5-
# you may not use this file except in compliance with the License.
6-
# You may obtain a copy of the License at
7-
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
9-
#
10-
# Unless required by applicable law or agreed to in writing, software
11-
# distributed under the License is distributed on an "AS IS" BASIS,
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
14-
# limitations under the License.
15-
#
1+
# Package definitions
2+
GROUP=io.kategory
3+
VERSION_NAME=0.3.3-SNAPSHOT
164

17-
# Project-wide Gradle settings.
18-
19-
# IDE (e.g. Android Studio) users:
20-
# Gradle settings configured through the IDE *will override*
21-
# any settings specified in this file.
22-
23-
# For more details on how to configure your build environment visit
24-
# http://www.gradle.org/docs/current/userguide/build_environment.html
25-
26-
# Specifies the JVM arguments used for the daemon process.
27-
# The setting is particularly useful for tweaking memory settings.
5+
# Gradle options
286
org.gradle.jvmargs=-Xmx2048m
297

30-
# When configured, Gradle will run in incubating parallel mode.
31-
# This option should only be used with decoupled projects. More details, visit
32-
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
33-
# org.gradle.parallel=true
34-
358
# Kotlin configuration
369
kotlin.coroutines=enable
3710
kotlin.incremental=true
11+
12+
# Pomfile definitions
13+
POM_DESCRIPTION=Functional Datatypes and abstractions for Kotlin inspired by Cats.
14+
15+
POM_URL=https://github.com/kategory/kategory/
16+
POM_SCM_URL=https://github.com/kategory/kategory/
17+
POM_SCM_CONNECTION=scm:git:git://github.com/kategory/kategory.git
18+
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/kategory/kategory.git
19+
20+
POM_LICENCE_NAME=The Apache Software License, Version 2.0
21+
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
22+
POM_LICENCE_DIST=repo
23+
24+
POM_DEVELOPER_ID=kategory
25+
POM_DEVELOPER_NAME=The Kategory Authors

gradle/gradle-mvn-push.gradle

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
/*
2+
* Copyright 2013 Chris Banes
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'maven'
18+
apply plugin: 'signing'
19+
20+
version = VERSION_NAME
21+
group = GROUP
22+
23+
def isReleaseBuild() {
24+
return !VERSION_NAME.contains("SNAPSHOT")
25+
}
26+
27+
def getReleaseRepositoryUrl() {
28+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
29+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
30+
}
31+
32+
def getSnapshotRepositoryUrl() {
33+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
34+
: "https://oss.sonatype.org/content/repositories/snapshots/"
35+
}
36+
37+
def getRepositoryUsername() {
38+
return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : ""
39+
}
40+
41+
def getRepositoryPassword() {
42+
return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : ""
43+
}
44+
45+
afterEvaluate { project ->
46+
uploadArchives {
47+
repositories {
48+
mavenDeployer {
49+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
50+
51+
pom.groupId = GROUP
52+
pom.artifactId = POM_ARTIFACT_ID
53+
pom.version = VERSION_NAME
54+
55+
repository(url: getReleaseRepositoryUrl()) {
56+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
57+
}
58+
snapshotRepository(url: getSnapshotRepositoryUrl()) {
59+
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
60+
}
61+
62+
pom.project {
63+
name POM_NAME
64+
packaging POM_PACKAGING
65+
description POM_DESCRIPTION
66+
url POM_URL
67+
68+
scm {
69+
url POM_SCM_URL
70+
connection POM_SCM_CONNECTION
71+
developerConnection POM_SCM_DEV_CONNECTION
72+
}
73+
74+
licenses {
75+
license {
76+
name POM_LICENCE_NAME
77+
url POM_LICENCE_URL
78+
distribution POM_LICENCE_DIST
79+
}
80+
}
81+
82+
developers {
83+
developer {
84+
id POM_DEVELOPER_ID
85+
name POM_DEVELOPER_NAME
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
93+
if (project.hasProperty("signArchives")) {
94+
signing {
95+
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
96+
sign configurations.archives
97+
}
98+
}
99+
100+
install {
101+
repositories.mavenInstaller {
102+
pom.groupId = GROUP
103+
pom.artifactId = POM_ARTIFACT_ID
104+
pom.version = VERSION_NAME
105+
106+
pom.project {
107+
name POM_NAME
108+
packaging POM_PACKAGING
109+
description POM_DESCRIPTION
110+
url POM_URL
111+
112+
scm {
113+
url POM_SCM_URL
114+
connection POM_SCM_CONNECTION
115+
developerConnection POM_SCM_DEV_CONNECTION
116+
}
117+
118+
licenses {
119+
license {
120+
name POM_LICENCE_NAME
121+
url POM_LICENCE_URL
122+
distribution POM_LICENCE_DIST
123+
}
124+
}
125+
126+
developers {
127+
developer {
128+
id POM_DEVELOPER_ID
129+
name POM_DEVELOPER_NAME
130+
}
131+
}
132+
}
133+
}
134+
}
135+
136+
task sourcesJar(type: Jar, dependsOn: classes) {
137+
classifier = 'sources'
138+
from sourceSets.main.allSource
139+
}
140+
141+
task javadocJar(type: Jar, dependsOn: javadoc) {
142+
classifier = 'javadoc'
143+
from javadoc.destinationDir
144+
}
145+
146+
if (JavaVersion.current().isJava8Compatible()) {
147+
allprojects {
148+
tasks.withType(Javadoc) {
149+
options.addStringOption('Xdoclint:none', '-quiet')
150+
}
151+
}
152+
}
153+
154+
artifacts {
155+
archives sourcesJar
156+
archives javadocJar
157+
}
158+
}

kategory/build.gradle

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright (C) 2017 The Kategory Authors
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
test {
182
testLogging {
193
events "passed", "skipped", "failed", "standardOut", "standardError"
@@ -31,4 +15,6 @@ dependencies {
3115
build.dependsOn ':detekt'
3216

3317
sourceCompatibility = javaVersion
34-
targetCompatibility = javaVersion
18+
targetCompatibility = javaVersion
19+
20+
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')

kategory/gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Maven publishing configuration
2+
POM_NAME=Kategory
3+
POM_ARTIFACT_ID=kategory
4+
POM_PACKAGING=jar

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
*/
1616

1717
include ':kategory'
18+
rootProject.name = 'kategory-parent'

0 commit comments

Comments
 (0)