Skip to content

Commit d9d71a6

Browse files
committed
updated build file to be able to upload artifact(s) to maven central
1 parent 89bf672 commit d9d71a6

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

build.gradle

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import org.apache.tools.ant.filters.*
33
apply plugin: 'java'
44
apply plugin: 'jacoco'
55
apply plugin: 'findbugs'
6+
apply plugin: 'maven'
7+
apply plugin: 'signing'
68
apply plugin: 'pmd'
79
apply plugin: 'application'
810
apply from: 'eclipse.gradle'
911

1012
sourceCompatibility = 1.7
1113
targetCompatibility = 1.7
14+
group = 'gov.loc'
1215

1316
if(project.version == "unspecified"){
1417
project.version = "4.11-SNAPSHOT"
@@ -100,3 +103,70 @@ tasks.withType(Pmd) {
100103
html.enabled = true
101104
}
102105
}
106+
107+
//javadocs and sources required for uploading to maven central
108+
task javadocJar(type: Jar) {
109+
classifier = 'javadoc'
110+
from javadoc
111+
}
112+
113+
task sourcesJar(type: Jar) {
114+
classifier = 'sources'
115+
from sourceSets.main.allSource
116+
}
117+
118+
artifacts {
119+
archives javadocJar
120+
archives sourcesJar
121+
}
122+
123+
//artifacts need to be signed in order to upload them to maven central
124+
signing {
125+
// required { !version.endsWith("SNAPSHOT") } //only sign an actual release
126+
sign configurations.archives
127+
}
128+
129+
uploadArchives {
130+
repositories {
131+
mavenDeployer {
132+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
133+
134+
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
135+
authentication(userName: ossrhUsername, password: ossrhPassword)
136+
}
137+
138+
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
139+
authentication(userName: ossrhUsername, password: ossrhPassword)
140+
}
141+
142+
pom.project {
143+
name 'bagit-java'
144+
packaging 'jar'
145+
// optionally artifactId can be defined here
146+
description 'The BAGIT LIBRARY is a software library intended to support the creation, manipulation, and validation of bags. Its current version is 0.97. It is version aware with the earliest supported version being 0.93.'
147+
url 'https://github.com/LibraryOfCongress/bagit-java'
148+
149+
scm {
150+
connection 'scm:git:https://github.com/LibraryOfCongress/bagit-java'
151+
developerConnection 'scm:git:ssh://github.com/LibraryOfCongress/bagit-java'
152+
url 'https://github.com/LibraryOfCongress/bagit-java'
153+
}
154+
155+
licenses {
156+
license {
157+
name 'No Copyright'
158+
url 'https://github.com/LibraryOfCongress/bagit-java/blob/master/LICENSE.txt'
159+
}
160+
}
161+
162+
developers {
163+
developer {
164+
id 'johnscancella'
165+
name 'John Scancella'
166+
167+
}
168+
}
169+
}
170+
}
171+
}
172+
}

0 commit comments

Comments
 (0)