-
Notifications
You must be signed in to change notification settings - Fork 159
/
jppm.gradle
134 lines (101 loc) · 3.7 KB
/
jppm.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
def jppmDist(Project project) {
def jarsDir = file(project.buildDir.path + "/jppm/dist/jars")
def sdkDir = file(project.buildDir.path + "/jppm/dist/sdk")
def packageFile = file(project.buildDir.path + "/jppm/dist/package.php.yml")
def version = project.ext.hasProperty('jppmVersion') ? project.ext.jppmVersion : project.version
copy {
from project.configurations.compile
from project.jar.archivePath
into jarsDir
}
copy {
from project.projectDir.path + "/src/main/resources/JPHP-INF/sdk"
into sdkDir
}
copy {
from project.projectDir.path + "/README.md"
into project.buildDir.path + "/jppm/dist/"
}
copy {
from project.projectDir.path + "/api-docs"
into project.buildDir.path + "/jppm/dist/api-docs"
}
copy {
from project.projectDir.path + "/api-docs-extra"
into project.buildDir.path + "/jppm/dist/api-docs-extra"
}
if (new File(rootDir.path, "/package.hub.yml").exists()) {
copy {
from rootProject.rootDir.path + "/package.hub.yml"
into project.buildDir.path + "/jppm/dist/"
}
}
if (packageFile.isFile()) {
packageFile.delete()
}
packageFile.parentFile.mkdirs()
if (new File(project.projectDir.path + "/package.php.yml").isFile()) {
copy {
from project.projectDir.path + "/package.php.yml"
into packageFile.parentFile.path
}
/*def jars = []
jarsDir.listFiles().each { file ->
if (file.name.endsWith(".jar")) {
jars.add(file.name)
}
}
if (!jars.empty) {
packageFile.setText(packageFile.getText('UTF-8') + "\n\njars: ['" + jars.join("', '") + "']\n", 'UTF-8')
}*/
} else {
if (!packageFile.isFile()) {
packageFile.createNewFile()
}
def name = project.name
if (name.startsWith("exts/")) {
name = name.substring(5)
}
def jppmVersion = version.toString().replace("-SNAPSHOT", "+SNAPSHOT");
def text = "name: '$name'\nversion: $jppmVersion\n"
def jars = []
def deps = project.configurations.compile.getAllDependencies().withType(ProjectDependency) + project.configurations.jppmCompile.getAllDependencies().withType(ProjectDependency)
if (!deps.empty) {
text += "deps:\n"
def ver = version.toString().split("\\-")[0];
ver = ver.split("\\+")[0];
deps.each {
text += " ${file(it.name).name}: '>=$ver'\n"
delete "$jarsDir/${file(it.name).name}-${version}.jar"
}
}
//text += "\ndeps:\n" + deps.join(": $project.version\n") + "\n";
/*jarsDir.listFiles().each { file ->
if (file.name.endsWith(".jar")) {
jars.add(file.name)
}
}
if (!jars.empty) {
text += "\njars: ['" + jars.join("', '") + "']\n"
}*/
packageFile.text = text;
}
}
def jppmInstall(project) {
def repoDir = System.getProperty("user.home") + "/.jppm/repo"
def name = file(project.name).name;
def version = project.ext.hasProperty('jppmVersion') ? project.ext.jppmVersion : project.version
version = version.toString().replace("-SNAPSHOT", "+SNAPSHOT");
delete "$repoDir/$name/$version"
delete "$repoDir/$name/${version}.tar.gz"
copy {
from file(project.buildDir.path + "/jppm/dist/")
into "$repoDir/$name/$version"
}
println("Install jppm package to: $repoDir/$name/$version")
return "$repoDir/$name/$version"
}
ext {
jppmDist = this.&jppmDist
jppmInstall = this.&jppmInstall
}