Skip to content

Commit 6e9f8cd

Browse files
committed
Add maven publish task
1 parent a718d74 commit 6e9f8cd

File tree

3 files changed

+96
-2
lines changed

3 files changed

+96
-2
lines changed

gradle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
org.gradle.daemon=true
22
org.gradle.jvmargs=-Xmx1024M
3+
4+
systemProp.org.gradle.internal.http.socketTimeout=120000
5+
systemProp.org.gradle.internal.http.connectionTimeout=60000
6+
7+
# FIXME: Workaround gradle publish issue: https://github.com/gradle/gradle/issues/11308
8+
systemProp.org.gradle.internal.publish.checksums.insecure=true

jsr381/build.gradle

+90-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
plugins {
22
id "java-library"
3+
id "maven-publish"
4+
id "signing"
35
}
46

57
group "ai.djl.jsr381"
6-
version "0.3.0"
8+
boolean isRelease = project.hasProperty("release") || project.hasProperty("staging")
9+
version = "0.3.0" + (isRelease ? "" : "-SNAPSHOT")
710

811
dependencies {
912
api "javax.visrec:visrec-api:1.0-SNAPSHOT"
@@ -21,9 +24,95 @@ dependencies {
2124
}
2225
}
2326

27+
java {
28+
withJavadocJar()
29+
withSourcesJar()
30+
}
31+
2432
test {
2533
// Use TestNG for unit tests
2634
useTestNG()
2735
}
2836

2937
apply from: file("${rootProject.projectDir}/tools/gradle/formatter.gradle")
38+
39+
project.tasks.withType(GenerateModuleMetadata) {
40+
enabled = false
41+
}
42+
43+
signing {
44+
required(project.hasProperty("staging") || project.hasProperty("snapshot"))
45+
def signingKey = findProperty("signingKey")
46+
def signingPassword = findProperty("signingPassword")
47+
useInMemoryPgpKeys(signingKey, signingPassword)
48+
sign publishing.publications
49+
}
50+
51+
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
52+
if (gradle.startParameter.taskNames.contains("publish")) {
53+
throw new GradleException("JDK 1.8 is required to run publish task.")
54+
}
55+
return
56+
}
57+
58+
publishing {
59+
publications {
60+
maven(MavenPublication) {
61+
from components.java
62+
artifacts = [jar, javadocJar, sourcesJar]
63+
pom {
64+
name = "Deep Java Library implementation of JSR-381"
65+
description = "Deep Java Library implementation of JSR-381"
66+
url = "http://www.djl.ai/"
67+
68+
packaging = "jar"
69+
70+
licenses {
71+
license {
72+
name = 'The Apache License, Version 2.0'
73+
url = 'https://www.apache.org/licenses/LICENSE-2.0'
74+
}
75+
}
76+
77+
scm {
78+
connection = "scm:git:[email protected]:awslabs/djl.git"
79+
developerConnection = "scm:git:[email protected]:awslabs/djl.git"
80+
url = "https://github.com/awslabs/djl"
81+
tag = "HEAD"
82+
}
83+
84+
developers {
85+
developer {
86+
name = "DJL.AI Team"
87+
88+
organization = "Amazon AI"
89+
organizationUrl = "https://amazon.com"
90+
}
91+
}
92+
}
93+
}
94+
}
95+
96+
repositories {
97+
maven {
98+
if (project.hasProperty("snapshot")) {
99+
name = "snapshot"
100+
url = "https://oss.sonatype.org/content/repositories/snapshots/"
101+
credentials {
102+
username = findProperty("ossrhUsername")
103+
password = findProperty("ossrhPassword")
104+
}
105+
} else if (project.hasProperty("staging")) {
106+
name = "staging"
107+
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
108+
credentials {
109+
username = findProperty("ossrhUsername")
110+
password = findProperty("ossrhPassword")
111+
}
112+
} else {
113+
name = "local"
114+
url = "build/repo"
115+
}
116+
}
117+
}
118+
}

settings.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
rootProject.name = "visrec"
21
include "jsr381", "examples"

0 commit comments

Comments
 (0)