-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
init.gradle
117 lines (85 loc) · 3.05 KB
/
init.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
import com.liferay.gradle.util.hash.HashUtil
import com.liferay.gradle.util.hash.HashValue
import java.util.concurrent.ConcurrentHashMap
if (System.properties["http.proxyHost"] == "squid.lax.liferay.com") {
logger.lifecycle "Using proxy {}:{}.", System.properties["http.proxyHost"], System.properties["http.proxyPort"]
System.setProperty "repository.url", "http://repository-cdn.liferay.com/nexus/content/groups/public"
}
initscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.util", version: "1.0.49"
}
repositories {
if (!Boolean.getBoolean("maven.local.ignore")) {
mavenLocal()
File tmpMavenRepositoryDir = null
if (hasProperty("tmp.maven.repository.dir")) {
tmpMavenRepositoryDir = file(properties["tmp.maven.repository.dir"])
}
else {
tmpMavenRepositoryDir = file("../.m2-tmp")
}
if (tmpMavenRepositoryDir.exists()) {
maven {
url tmpMavenRepositoryDir
}
}
}
maven {
url System.properties["repository.url"] ?: "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
}
}
gradle.buildFinished {
if (System.getenv("JENKINS_HOME")) {
Date date = new Date()
logger.lifecycle "Gradle build finished at {}.", date.format("yyyy-MM-dd HH:mm:ss.SSS", TimeZone.getTimeZone("UTC"))
}
ByteArrayOutputStream errorByteArrayOutputStream = new ByteArrayOutputStream()
ByteArrayOutputStream outputByteArrayOutputStream = new ByteArrayOutputStream()
exec {
commandLine "git", "ls-files", "--exclude-standard", "--others"
ignoreExitValue = true
errorOutput = errorByteArrayOutputStream
standardOutput = outputByteArrayOutputStream
workingDir = gradle.gradleUserHomeDir
}
String errorString = errorByteArrayOutputStream.toString()
if (!errorString.contains("Not a git repository")) {
logger.error errorString
}
String output = outputByteArrayOutputStream.toString()
List<String> fileNames = output.readLines()
fileNames.retainAll {
it.endsWith ".pom"
}
fileNames.each {
String pomFileName ->
File pomFile = new File(gradle.gradleUserHomeDir, pomFileName)
rootProject.ant.fixcrlf encoding: "UTF-8", eol: "lf", file: pomFile, fixlast: false
HashValue hashValue = HashUtil.sha1(pomFile)
String hash = hashValue.asHexString()
File hashDir = pomFile.parentFile
if (hashDir.name != hash) {
boolean success = hashDir.renameTo new File(hashDir.parentFile, hash)
if (!success) {
delete hashDir
}
}
}
}
if (Boolean.getBoolean("build.performance.logger.enabled")) {
gradle.taskGraph.addTaskExecutionListener(
new TaskExecutionListener() {
void afterExecute(Task task, TaskState taskState) {
long endTime = System.currentTimeMillis()
long startTime = _taskStartTimes.remove(task)
long duration = endTime - startTime
logger.lifecycle "${task.path} started at ${startTime} and ended at ${endTime}, taking ${duration} ms."
}
void beforeExecute(Task task) {
_taskStartTimes.put task, System.currentTimeMillis()
}
private final ConcurrentHashMap<Task, Long> _taskStartTimes = new ConcurrentHashMap<Task, Long>()
})
}