Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-07-23 13:09:48 +0000
committerTom Schindl2015-07-23 13:33:59 +0000
commitd6073ff8acd89d082093bcdd35c0fc54b6784be4 (patch)
tree8dc673394a754dda42763d5aa7d4f82152eb7fdf /releng/cmdtools
parent838f71e604249bc127f3088d397b5e375c2d13e3 (diff)
downloadorg.eclipse.efxclipse-d6073ff8acd89d082093bcdd35c0fc54b6784be4.tar.gz
org.eclipse.efxclipse-d6073ff8acd89d082093bcdd35c0fc54b6784be4.tar.xz
org.eclipse.efxclipse-d6073ff8acd89d082093bcdd35c0fc54b6784be4.zip
Bug 473314 - Add a new language to make it easy to define code editors
Diffstat (limited to 'releng/cmdtools')
-rw-r--r--releng/cmdtools/build.gradle20
-rw-r--r--releng/cmdtools/gradle.properties14
-rw-r--r--releng/cmdtools/settings.gradle127
3 files changed, 161 insertions, 0 deletions
diff --git a/releng/cmdtools/build.gradle b/releng/cmdtools/build.gradle
new file mode 100644
index 000000000..8766dc5ab
--- /dev/null
+++ b/releng/cmdtools/build.gradle
@@ -0,0 +1,20 @@
+/*
+ * Master Gradle build script
+ *
+ * Depends on bndWorkspace and bndURI properties set by settings.gradle.
+ */
+
+/* Add bnd as a script dependency */
+buildscript {
+ dependencies {
+ classpath files(bndURI)
+ }
+}
+
+/* Configure the subprojects */
+subprojects {
+ def bndProject = bndWorkspace.getProject(name)
+ if (bndProject != null) {
+ plugins.apply 'biz.aQute.bnd'
+ }
+}
diff --git a/releng/cmdtools/gradle.properties b/releng/cmdtools/gradle.properties
new file mode 100644
index 000000000..e4644f8ac
--- /dev/null
+++ b/releng/cmdtools/gradle.properties
@@ -0,0 +1,14 @@
+# cnf project name
+bnd_cnf=cnf
+
+# bnd_jar can also be a URL.
+bnd_jar=cnf/gradle/biz.aQute.bnd.gradle.jar
+
+# bnd_build can be set to the name of a "master" project whose dependencies will seed the set of projects to build.
+bnd_build=
+
+# Default gradle task to build
+bnd_defaultTask=build
+
+# This should be false. It only needs to be true in rare cases.
+bnd_preCompileRefresh=false
diff --git a/releng/cmdtools/settings.gradle b/releng/cmdtools/settings.gradle
new file mode 100644
index 000000000..5d64c9936
--- /dev/null
+++ b/releng/cmdtools/settings.gradle
@@ -0,0 +1,127 @@
+/*
+ * Master Gradle initialization script
+ *
+ * Depends on bnd_* values from gradle.properties.
+ */
+
+import aQute.bnd.build.Workspace
+
+/* Add bnd as a script dependency */
+buildscript {
+ dependencies {
+ def bndURI = rootDir.toURI().resolve(bnd_jar)
+ if (bndURI.scheme != 'file') {
+ /* If not a local file, copy to a local file in cnf/cache */
+ def cnfCache = mkdir("${rootDir}/${bnd_cnf}/cache")
+ def bndJarFile = new File(cnfCache, 'biz.aQute.bnd.gradle.jar')
+ if (!bndJarFile.exists()) {
+ println "Downloading ${bndURI} to ${bndJarFile} ..."
+ bndURI.toURL().withInputStream { is ->
+ bndJarFile.withOutputStream { os ->
+ def bos = new BufferedOutputStream( os )
+ bos << is
+ }
+ }
+ }
+ bndURI = bndJarFile.toURI()
+ }
+ classpath files(bndURI)
+
+ /* After the rootProject is created, pass URI to projects */
+ gradle.rootProject { rootProject ->
+ rootProject.ext.bndURI = bndURI
+ }
+ }
+}
+
+/* Initialize the bnd workspace */
+def workspace = Workspace.getWorkspace(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
+}
+
+/* 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
+ if (!projectName.startsWith('.')) {
+ projectNames += projectName
+ }
+ }
+}
+
+/* Add each project and its dependencies to the graph */
+projectNames.each { projectName ->
+ include projectName
+ def project = getBndProject(workspace, projectName)
+ project?.dependson.each {
+ include it.name
+ }
+}
+
+/* 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.warnings.each {
+ println "Warning: ${it}"
+ }
+ project.errors.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")
+}
+
+/* After the rootProject is created, set up some properties. */
+gradle.rootProject { rootProject ->
+ rootProject.ext.bndWorkspace = workspace
+ rootProject.ext.cnf = rootProject.project(bnd_cnf)
+}

Back to the top