forked from Zarzelcow/legacy-lwjgl3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
115 lines (97 loc) · 2.9 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
plugins {
id "maven-publish"
id "java"
}
version = project.lib_version
group = project.maven_group
ext {
lwjglModules = [
"lwjgl",
"lwjgl-glfw",
"lwjgl-opengl",
"lwjgl-openal"
]
lwjglPlatform = getCurrentPlatform()
}
base {
archivesName = project.archives_base_name
}
repositories {
maven {
name = "Jitpack"
url = "https://jitpack.io"
}
maven {
name = "LWJGL3"
url = "https://oss.sonatype.org/content/repositories/releases/"
}
}
dependencies {
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation platform("org.lwjgl:lwjgl-bom:$project.lwjgl_version")
// Add LWJGL modules and native libs for current OS
lwjglModules.each {
implementation "org.lwjgl:$it"
runtimeOnly "org.lwjgl:$it::natives-$lwjglPlatform"
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
}
java {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
// For information on how to set up publishing,
// see https://docs.gradle.org/current/userguide/publishing_maven.html
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact,
// not for retrieving dependencies.
}
}
import org.gradle.nativeplatform.internal.DefaultTargetMachineFactory
/**
* Returns the current platform string ("os-arch"), blank arch implies x86_64.
* Suitable for retrieval of LWJGL natives.
*/
def getCurrentPlatform() {
def host = new DefaultTargetMachineFactory(project.objects).host()
def os = host.operatingSystemFamily
switch (os) {
case OperatingSystemFamily.WINDOWS:
break
case OperatingSystemFamily.LINUX:
break
case OperatingSystemFamily.MACOS:
break
default:
throw new GradleException("Unsupported OS: " + os)
}
def arch = host.architecture
switch (arch) {
case MachineArchitecture.X86:
if (os.isWindows())
return os.name + "-x86"
break
case MachineArchitecture.X86_64:
return os.name
case MachineArchitecture.ARM64:
return os.name + "-arm64"
}
throw new GradleException("Unsupported Architecture: " + arch)
}