-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgbuild.gradle
More file actions
75 lines (59 loc) · 2.83 KB
/
gbuild.gradle
File metadata and controls
75 lines (59 loc) · 2.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
import java.nio.file.Files
import java.nio.file.StandardCopyOption
def GBUILD_WORKSPACE = "E:/Java/GBuild"
//---[repo]---
project.ext.jitpackRepo = { return project.repositories.maven { name = 'jitpack-repo'; url 'https://jitpack.io' } }
project.ext.spigotmcRepo = { return project.repositories.maven { name = 'spigotmc-repo'; url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } }
project.ext.papermcRepo = { return project.repositories.maven { name = 'papermc-repo'; url = 'https://repo.papermc.io/repository/maven-public/' } }
project.ext.sonatypeRepo = { return project.repositories.maven { name = "sonatype"; url = "https://oss.sonatype.org/content/groups/public/" } }
//dependencies:
project.ext.projectLib = { lib -> return files("${rootDir.getAbsolutePath()}/libraries/${lib}.jar") }
project.ext.localStorage = { lib -> return files("E:/Java/GlobalResources/Libraries/${lib.replace(".", "/")}.jar") }
project.ext.gbuildLib = { lib ->
var gbuild_path = "${GBUILD_WORKSPACE}/Libraries/${lib.replace(":", "/")}.jar"
var local_path = "${rootDir.getAbsolutePath()}/libraries/gbuild/${lib.replace(":", "/")}.jar"
var remote = new File(gbuild_path)
var local = new File(local_path)
var remote_valid = remote.exists()
var local_valid = local.exists()
if (!(remote_valid || local_valid)) {
throw new RuntimeException("failed to resolve gbuild lib: ${lib} , both gbuild global library and project library is not present.")
}
if (!local_valid) {
local.getParentFile().mkdirs()
local.createNewFile()
Files.copy(remote.toPath(), local.toPath(), StandardCopyOption.REPLACE_EXISTING)
print("Downloaded lib ${lib} (${remote.lastModified()} > ${local.lastModified()})")
return files(local_path)
}
if (remote.lastModified() > local.lastModified() || remote.length() != local.length()) {
print("Updating lib ${lib} (${remote.lastModified()} > ${local.lastModified()})")
Files.copy(remote.toPath(), local.toPath(), StandardCopyOption.REPLACE_EXISTING)
}
return files(local_path)
}
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'
project.ext.applyScript = { path ->
println "> Apply script: $path"
apply from: rootDir.getAbsolutePath() + "/script/" + path
}
project.ext.applyGlobalScript = { path ->
println "> Apply script: $path"
apply from: "E:/Java/GradleScripts/" + path
}
project.ext.publish_gbuild = {
project.tasks.register('GBuild Publish', Copy) {
from jar.archiveFile
into file("${GBUILD_WORKSPACE}/Libraries/${project.group}")
}
project.build.dependsOn 'GBuild Publish'
}
jar {
archiveVersion = ""
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from {
(configurations.runtimeClasspath).collect {
it.isDirectory() ? it : zipTree(it)
}
}
}