-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
133 lines (113 loc) · 3.47 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
// Настройки для всех проектов
import org.apache.tools.ant.filters.ReplaceTokens
import proguard.gradle.ProGuardTask
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
compileOnly 'org.jetbrains:annotations:16.0.2'
}
group = 'ru.spliterash'
version = '3.0.6'
sourceCompatibility = 1.8
targetCompatibility = 1.8
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
}
subprojects {
jar {
from {
def projectClasses = configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
def subProject = subprojects.collect { p ->
p.jar.outputs.files.getFiles().collect {
it.isDirectory() ? it : zipTree(it)
}
}
return projectClasses + subProject
}.exclude('META-INF', 'META-INF/**')
}
}
dependencies {
compile project(":http:shared")
compileOnly 'com.google.code.gson:gson:2.8.0'
}
String jarName = 'VkChat'
File jarFolder = file("$rootDir/jars/")
task createFatJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
dependsOn allprojects.build
destinationDirectory = jarFolder
archiveFileName = jarName + ".jar"
from {
return allprojects.collect { p ->
p.jar.outputs.files.getFiles().collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
exclude('META-INF', 'META-INF/**')
with jar
}
build {
dependsOn ":http:jdk11:build"
dependsOn ":http:jdk8:build"
}
//Следующий код идёт после инициализации сабмодулей
evaluationDependsOnChildren()
buildscript {
repositories {
flatDir dirs: "$System.env.PROGUARD_HOME/lib"
}
dependencies {
classpath ':proguard:'
}
}
List<File> getProGuardDependencies() {
File libFolder = new File(rootProject.getProjectDir(), "libs")
delete libFolder
Set<ResolvedArtifact> compileOnly = new HashSet<>()
Set<ResolvedArtifact> runTime = new HashSet<>()
allprojects.each { pro ->
pro.configurations.compileOnly.resolvedConfiguration.resolvedArtifacts.each {
compileOnly.add(it)
}
pro.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each {
runTime.add(it)
}
}
compileOnly.removeIf({ a ->
if (a.id.componentIdentifier.displayName.contains("project :")) {
return true
} else {
return runTime
.stream()
.anyMatch({ rA ->
a.name == rA.name
})
}
})
return compileOnly.collect { a ->
a.getFile()
}
}
task copyDependencyes(type: Copy) {
from(getProGuardDependencies()) into new File(rootDir, 'dependencies')
}
task proguard(type: ProGuardTask, dependsOn: createFatJar) {
def libs = getProGuardDependencies()
println(libs)
configuration("conf.pro")
libraryjars libs
injars new File(jarFolder, jarName + ".jar")
outjars new File(jarFolder, jarName + "-minifed.jar")
}