-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.gradle
204 lines (165 loc) · 4.99 KB
/
settings.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* Master Gradle initialization script
*
* Depends on bnd_* values from gradle.properties.
*
* settings.gradle - Initializes the projects to be included in the Gradle build for the workspace
*/
import aQute.bnd.build.Workspace
import aQute.bnd.osgi.Constants
/* Add bnd gradle plugin as a script dependency */
buildscript {
repositories {
jcenter()
mavenCentral()
//mavenLocal()
maven {
url "https://repository.apache.org/content/groups/snapshots/"
name "Apache Snapshots"
}
maven {
url "https://oss.sonatype.org/content/groups/osgi"
name "OSGi public binaries"
}
}
/* maven {
url "https://nexus.repository-pert.ismb.it/repository/maven-releases/"
credentials {
username "${System.env.NEXUS_USER ?: NexusUser }"
password "${System.env.NEXUS_PASSWORD ?: NexusPassword }"
}
}
maven {
url "https://nexus.repository-pert.ismb.it/repository/maven-snapshots/"
credentials {
username "${System.env.NEXUS_USER ?: NexusUser }"
password "${System.env.NEXUS_PASSWORD ?: NexusPassword }"
}
}
*/
/* https://docs.gradle.org/current/userguide/declaring_repositories.html
repositories {
jcenter()
maven {
url "https://maven.springframework.org/release"
}
maven {
url "https://maven.restlet.com"
}
}
plugins {
id 'java' #旧版本 apply plugin: 'java' 应用插件, use id // apply plugin: JavaPlugin use plugin type
}
*/
/*uploadArchives {
repositories {
mavenDeployer {
repository(url: "https://nexus.repository-pert.ismb.it/repository/maven-snapshots/"){
authentication(userName: ${env.NEXUS_USER}, password: ${env.NEXUS_PASSWORD})
}
}
}
}*/
dependencies {
classpath bnd_plugin
}
/* Pass bnd gradle plugin classpath to rootProject once created */
def bndPlugin = files(configurations.classpath.files)
gradle.rootProject {
rootProject -> rootProject.ext.bndPlugin = bndPlugin
}
/*plugins {
id 'maven'
}*/
}
/* Initialize the bnd workspace */
Workspace.setDriver(Constants.BNDDRIVER_GRADLE)
Workspace.addGestalt(Constants.GESTALT_BATCH, null)
def workspace = new Workspace(rootDir, bnd_cnf)
if (workspace == null) {
throw new GradleException("Unable to load workspace ${rootDir}/${bnd_cnf}")
}
/* Add cnf project to the graph */
include bnd_cnf
/* Start with the declared build project name */
def defaultProjectName = bnd_build
/* If in a subproject, use the subproject name */
for (def currentDir = startParameter.currentDir; currentDir != rootDir; currentDir = currentDir.parentFile) {
defaultProjectName = currentDir.name
//println defaultProjectName
}
/* Build a set of project names we need to include from the specified tasks */
def projectNames = startParameter.taskNames.collect { taskName ->
def elements = taskName.split(':')
switch (elements.length) {
case 1:
return defaultProjectName
case 2:
return elements[0].empty ? bnd_build : elements[0]
default:
return elements[0].empty ? elements[1] : elements[0]
}
}.toSet()
/* Include the default project name if in a subproject or no tasks specified */
if ((startParameter.currentDir != rootDir) || projectNames.empty) {
projectNames += defaultProjectName
}
/* If bnd_build used but declared empty, add all non-private folders of rootDir */
if (projectNames.remove('')) {
rootDir.eachDir {
def projectName = it.name
//println projectName
if (!projectName.startsWith('.')) {
projectNames += projectName
}
}
}
/* Add each project and its dependencies to the graph
projectNames.each { projectName ->
include projectName
def project = getBndProject(workspace, projectName)
//println project
project?.getDependson()*.getName().each {
include it
//println projectName
}
}*/
/* Add each project and its dependencies to the graph */
projectNames.each { projectName ->
include projectName
def project = getBndProject(workspace, projectName)
project?.getDependson()*.getName().each {
include it
//println projectName
}
}
/* Get the bnd project for the specified project name */
def getBndProject(Workspace workspace, String projectName) {
def project = workspace.getProject(projectName)
if (project == null) {
return null
}
project.prepare()
if (project.isValid()) {
return project
}
project.getInfo(workspace, "${rootDir} :")
def errorCount = 0
project.getWarnings().each {
println "Warning: ${it}"
}
project.getErrors().each {
println "Error : ${it}"
errorCount++
}
if (!project.isOk()) {
def str = 'even though no errors were reported'
if (errorCount == 1) {
str = 'one error was reported'
} else if (errorCount > 1) {
str = "${errorCount} errors were reported"
}
throw new GradleException("Project ${rootDir}/${projectName} is invalid, ${str}")
}
throw new GradleException("Project ${rootDir}/${projectName} is not a valid bnd project")
}