forked from LWJGL/lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
150 lines (132 loc) · 3.78 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
143
144
145
146
147
148
149
150
/*
* Copyright LWJGL. All rights reserved.
* License terms: http://lwjgl.org/license.php
*/
project.buildDir = 'bin/MAVEN'
apply plugin: "maven"
apply plugin: "signing"
project.group = "org.lwjgl"
project.version = lwjglVersion
def PATHS = [
release: 'bin/RELEASE'
]
// Set build variables based on build type (release, continuous integration, development)
enum BuildType {
LOCAL,
SNAPSHOT,
RELEASE
}
class Deployment {
BuildType type
String repo
String user
String password
}
Deployment deployment;
if ( hasProperty("release") ) {
buildRepo.isRelease = true
deployment = new Deployment(
type: BuildType.RELEASE,
repo: "https://oss.sonatype.org/service/local/staging/deploy/maven2/",
user: sonatypeUsername,
password: sonatypePassword
)
println "Performing release build"
} else if ( hasProperty("snapshot") ) {
project.version += "-SNAPSHOT"
deployment = new Deployment(
type: BuildType.SNAPSHOT,
repo: "https://oss.sonatype.org/content/repositories/snapshots/",
user: sonatypeUsername,
password: sonatypePassword
)
println "Performing snapshot build"
} else {
deployment = new Deployment(
type: BuildType.LOCAL,
repo: repositories.mavenLocal().url
)
}
println "${deployment.type.name()} BUILD"
artifacts {
archives file: file("$buildDir/lwjgl.jar"), name: "lwjgl", type: "jar"
archives file: file("$buildDir/src.jar"), name: "lwjgl", type: "jar", classifier: "sources"
archives file: file("$buildDir/javadoc.jar"), name: "lwjgl", type: "jar", classifier: "javadoc"
archives file: file("$buildDir/lwjgl-natives-windows.jar"), name: "lwjgl-platform", type: "jar", classifier: "natives-windows"
archives file: file("$buildDir/lwjgl-natives-macosx.jar"), name: "lwjgl-platform", type: "jar", classifier: "natives-osx"
archives file: file("$buildDir/lwjgl-natives-linux.jar"), name: "lwjgl-platform", type: "jar", classifier: "natives-linux"
}
if ( deployment.type == BuildType.RELEASE ) {
signing {
sign configurations.archives
}
} else {
task signArchives {
// do nothing
}
}
def lwjglPOM = { String projectName, String packagingMethod ->
return {
project {
name projectName
packaging packagingMethod
description 'LWJGL'
url 'http://www.lwjgl.org'
scm {
url 'scm:[email protected]:LWJGL/lwjgl3.git'
connection 'scm:[email protected]:LWJGL/lwjgl3.git'
developerConnection 'scm:[email protected]:LWJGL/lwjgl3.git'
}
licenses {
license {
name 'BSD'
url 'http://www.lwjgl.org/license'
distribution 'repo'
}
}
developers {
developer {
id "spasi"
name "Ioannis Tsakpinis"
}
}
}
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: deployment.repo) {
authentication(userName: deployment.user, password: deployment.password)
}
if ( deployment.type == BuildType.RELEASE ) {
beforeDeployment { signing.signPom(it) }
}
addFilter("lwjgl") { artifact, file -> artifact.name == "lwjgl" }
addFilter("lwjgl-platform") { artifact, file -> artifact.name == "lwjgl-platform" }
pom("lwjgl", lwjglPOM("LWJGL", "jar"))
pom("lwjgl-platform", lwjglPOM("LWJGL Platform", "pom"))
}
}
}
task copyArchives(type: Copy) {
from "$PATHS.release/jar/lwjgl.jar", "$PATHS.release/src.zip", "$PATHS.release/doc/javadoc.zip"
destinationDir file(buildDir)
rename { it.replace(".zip", ".jar") }
}
signArchives.mustRunAfter copyArchives
uploadArchives.dependsOn copyArchives
[
[include: "*.dll", name: "Windows"],
[include: "*.so", name: "Linux"],
[include: "*.dylib", name: "MacOSX"]
].each { archive ->
def zipNatives = task("zipNatives$archive.name", type: Zip) {
from "$PATHS.release/native"
include archive.include
archiveName "lwjgl-natives-${archive.name.toLowerCase()}.jar"
destinationDir file(buildDir)
}
signArchives.mustRunAfter zipNatives
uploadArchives.dependsOn zipNatives
}