-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
144 lines (125 loc) · 4.05 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright 2014-2022 Yusef Badri - All rights reserved.
* grey-slf4j-logstdio is distributed under the terms of the GNU Affero General Public License, Version 3 (AGPLv3).
*/
// To upload to Sonatype staging for Maven Central deployment:
// ./gradlew -PbuildVersion=0.0.1 -PrepoUser=myname -PrepoPassword=mypass -Psigning.gnupg.keyName=key_id -Psigning.gnupg.passphrase="blah blah" build uploadArchives
// Older versions of signing plugin were based on GnuPG2 and required:
// -Psigning.keyId=mykeyid1 -Psigning.password=mykeypass1 -Psigning.secretKeyRingFile=myringpath
// Note that all these properties can go in settings.gradle instead, or in
// $HOME/.gradle/gradle.properties if we want to keep them out of Git.
//
// Nexus repository uploads:
// ./gradlew -PbuildVersion=0.0.1 -PrepoHost=localhost:8081 -PrepoUser=myname -PrepoPassword=mypass publish
// Install in localhost Maven repository:
// ./gradlew publishToMavenLocal
//
// Can explicitly disable signing with: ./gradlew build -x signArchives
// Clear PGP passphrase on Ubuntu: gpg-connect-agent reloadagent /bye
//
// jacocoTestReport task generates HTML report from test.exec binary, which is
// automatically created by the ordinary build task.
plugins {
id 'java-library'
id 'maven' //old Maven publishing plugin, required for uploadArchives
id 'maven-publish' //new Maven publishing plugin, for Nexus uploads
id 'signing'
id 'jacoco'
id 'eclipse'
}
allprojects {
group = "$buildGroup"
version = "$buildVersion"
sourceCompatibility = 1.8
}
ext.repoHost = project.findProperty('repoHost') ?: 'localhost:8081'
ext.repoUser = project.findProperty('repoUser') ?: ''
ext.repoPassword = project.findProperty('repoPassword') ?: ''
ext.isReleaseVersion = !version.endsWith("-SNAPSHOT")
def nexusRepoStem = "http://$repoHost/repository"
def nexusRepoDownloads = "$nexusRepoStem/maven-public/"
def nexusRepoReleases = "$nexusRepoStem/maven-releases/"
def nexusRepoSnapshots = "$nexusRepoStem/maven-snapshots/"
repositories {
maven {
name = "nexusrepo-download"
url "$nexusRepoDownloads"
allowInsecureProtocol = true
}
jcenter()
mavenCentral()
}
dependencies {
api "org.slf4j:slf4j-api:$versionSLF4J"
implementation "com.fasterxml.jackson.core:jackson-databind:$versionJackson"
testImplementation "junit:junit:$versionJUNIT"
testImplementation "org.mockito:mockito-core:$versionMockito"
}
java {
withSourcesJar()
withJavadocJar()
}
artifacts {
archives javadocJar, sourcesJar
}
// This is for the publish task to deploy to a Nexus repository
publishing {
publications {
GreyLibrary(MavenPublication) {
from components.java
}
}
repositories {
maven {
name 'nexusrepo-upload'
url = isReleaseVersion ? nexusRepoReleases : nexusRepoSnapshots
credentials {
username repoUser
password repoPassword
}
}
}
}
// This is for the uploadArchives task to deploy to Maven Central
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: repoUser, password: repoPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: repoUser, password: repoPassword)
}
pom.project {
name 'grey-slf4j-logstdio'
packaging 'jar'
description 'SLF4J logger with environment-driven config'
url 'https://github.com/greysoft/slf4j-stdio'
scm {
connection 'scm:git:git://github.com/greysoft/slf4-stdio.git'
developerConnection 'scm:git:ssh://github.com/greysoft/slf4-stdio.git'
url 'https://github.com/greysoft/slf4j-stdio'
}
licenses {
license {
name 'GNU Affero General Public License v3.0'
url 'https://www.gnu.org/licenses/agpl-3.0.en.html'
}
}
developers {
developer {
name 'Yusef Badri'
}
}
}
}
}
}
signing {
useGpgCmd() //use GnuPG 2
sign configurations.archives
}
tasks.withType(Sign) {
onlyIf { project.findProperty('signing.gnupg.keyName') }
}