-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.gradle
More file actions
78 lines (66 loc) · 1.83 KB
/
publish.gradle
File metadata and controls
78 lines (66 loc) · 1.83 KB
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
apply plugin: 'maven-publish'
// Versions and IDs
def pubVersion = '0.0.4'
def artifactGroupId = 'com.2702rebels'
def baseArtifactId = 'canduitlib'
def templateVendorFile = "CANduitLib.json"
// Folders
def outputsFolder = file("$buildDir/outputs")
def releasesRepoUrl = "maven"
// 1. Task to generate the version file
task outputVersions() {
doFirst {
outputsFolder.mkdirs()
}
doLast {
file("$outputsFolder/version.txt").write pubVersion
}
}
// 2. Standard Java Artifacts
task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
// 3. VendorDep JSON Task
task vendordepJson(type: Copy) {
from templateVendorFile
into "maven/"
expand(version: pubVersion,
groupId: artifactGroupId,
artifactId: baseArtifactId)
}
task vendordepJsonZip(type: Zip, dependsOn: vendordepJson) {
destinationDirectory = outputsFolder
archiveBaseName = "CANduitLib"
from "maven/$templateVendorFile"
}
// 4. Publishing Configuration
publishing {
publications {
java(MavenPublication) {
groupId = artifactGroupId
artifactId = "${baseArtifactId}-java"
version = pubVersion
from components.java
artifact sourcesJar
artifact javadocJar
}
vendordep(MavenPublication) {
groupId = artifactGroupId
artifactId = "${baseArtifactId}-vendordep"
version = pubVersion
artifact vendordepJsonZip
}
}
repositories {
maven {
url = releasesRepoUrl
}
}
}
// Hook everything into the build
build.dependsOn outputVersions, vendordepJsonZip, sourcesJar, javadocJar