-
Notifications
You must be signed in to change notification settings - Fork 10
/
maven-push-java.gradle
149 lines (126 loc) · 4.92 KB
/
maven-push-java.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
145
146
147
148
149
// maven publish configuration of a java (non-android) library
// see https://docs.gradle.org/current/userguide/publishing_maven.html
// see https://docs.gradle.org/current/userguide/publishing_setup.html#sec:basic_publishing
// see https://docs.gradle.org/current/userguide/publishing_customization.html#sec:publishing_custom_artifacts_to_maven
//apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'maven-publish'
def isReleaseBuild() {
return !VERSION_NAME.contains("SNAPSHOT")
}
def getOutputDir() {
if (isReleaseBuild()) {
return "${project.buildDir}/releases"
} else {
return "${project.buildDir}/snapshots"
}
}
// used onlu if developing to s3: currently unused
def getDestUrl() {
if (isReleaseBuild()) {
return "s3://plensee-maven/android/releases"
} else {
return "s3://plensee-maven/android/snapshots"
}
}
task sourcesJar(type: Jar, dependsOn:classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
//task javadocJar(type: Jar, dependsOn:javadoc) {
// archiveClassifier.set('javadoc')
// from "$buildDir/javadoc"
// }
artifacts {
archives javadocJar
archives sourcesJar
}
afterEvaluate { project ->
publishing {
publications {
maven(MavenPublication) {
from components.java
groupId GROUP_MAVEN_PUSH
artifactId POM_ARTIFACT_ID
version VERSION_NAME
artifact sourcesJar
artifact javadocJar
pom {
name = POM_NAME
description = POM_DESCRIPTION
// url = 'http://www.example.com/library'
// properties = [
// myProp: "value",
// "prop.with.dots": "anotherValue"
// ]
// licenses {
// license {
// name = 'The Apache License, Version 2.0'
// url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
// }
// }
// developers {
// developer {
// id = 'johnd'
// name = 'John Doe'
// email = 'john.doe@example.com'
// }
// }
// scm {
// connection = 'scm:git:git://example.com/my-library.git'
// developerConnection = 'scm:git:ssh://example.com/my-library.git'
// url = 'http://example.com/my-library/'
// }
// def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
// def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
// url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
repositories {
// configuration to publish to github packages:
// see https://docs.github.com/en/actions/publishing-packages/publishing-java-packages-with-gradle#publishing-packages-to-github-packages
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/beyondeye/reduks")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
name = 'myRepo'
// url = "file:///" + getOutputDir() ////can also be used to copy to local file
// url = getDestUrl() //for copying directly to S3
def releasesRepoUrl = layout.buildDirectory.dir('repos/releases')
def snapshotsRepoUrl = layout.buildDirectory.dir('repos/snapshots')
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}
/*
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file:///" + getOutputDir()) //can also be used to copy to local file
//repository(url: getDestUrl()) // for copying directly to S3
pom.groupId = GROUP_MAVEN_PUSH
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
}
}
}
}
*/
task copyToS3(type: Exec) {
commandLine 'aws', 's3', 'cp', '--recursive', getOutputDir(), getDestUrl()
}
copyToS3.dependsOn publish
}