-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
142 lines (127 loc) · 4.17 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
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
}
group = 'org.polypheny'
def majorVersion = 0
def minorVersion = 0
if (hasProperty('version') ) {
if ( version == "unspecified" ) {
version = 'SNAPSHOT'
} else {
// Split version into major and minor components
def versionComponents = version.split("\\.")
majorVersion = versionComponents[0].toInteger()
minorVersion = versionComponents[1].toInteger()
}
}
repositories {
mavenCentral()
}
dependencies {
// Add your dependencies here if needed
}
// Set the temporary folder path for version properties
def tempPropertiesFolder = file("${buildDir}/tmp")
def versionPropertiesFile = new File(tempPropertiesFolder, 'prism-api-version.properties')
task generateVersionProperties {
outputs.file versionPropertiesFile
doLast {
// Ensure the temp directory exists
tempPropertiesFolder.mkdirs()
// Define the properties content
def propertiesContent = "version=${version}\n" + "majorVersion=${majorVersion}\n" + "minorVersion=${minorVersion}"
// Write to the properties file
versionPropertiesFile.write(propertiesContent)
}
}
task packageProto(type: Jar, dependsOn: generateVersionProperties) {
// Copy the proto files to the desired package structure in the JAR
from(fileTree('org/polypheny/prism').matching {
include '**/*.proto'
}) {
into 'org/polypheny/prism'
}
// Include the properties file in the same package structure within the JAR
from(versionPropertiesFile) {
into ''
}
archiveFileName = "prism-${version}.jar"
}
artifacts {
archives packageProto
}
jar {
manifest {
attributes 'Manifest-Version': '1.0'
attributes 'Copyright': 'The Polypheny Project'
attributes 'Group': project.group
attributes 'Name': project.name
attributes 'Version': project.version
}
}
publishing {
publications {
packageProtoPublication(MavenPublication) {
artifact tasks.packageProto
pom {
name = 'Prism API'
description = 'The API definition files of the Polypheny Prism query interface.'
url = 'https://polypheny.org/'
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0'
}
}
scm {
url = 'https://github.com/polypheny/Polypheny-Prism-API'
}
developers {
developer {
id = 'polypheny'
name = 'Polypheny'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
name = "OSSRH"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/polypheny/polypheny-prism-api"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
signing {
required { gradle.taskGraph.hasTask("publish") }
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.packageProtoPublication
}
tasks.named("publish") {
dependsOn(tasks.named("jar"))
}
tasks.named("publishPackageProtoPublicationPublicationToMavenLocal") {
dependsOn(tasks.named("jar"))
}
tasks.named("signPackageProtoPublicationPublication") {
dependsOn(tasks.named("jar"))
}