diff --git a/.gradle-wrapper/gradle-wrapper.jar b/.gradle-wrapper/gradle-wrapper.jar index 941144813..ca78035ef 100644 Binary files a/.gradle-wrapper/gradle-wrapper.jar and b/.gradle-wrapper/gradle-wrapper.jar differ diff --git a/.gradle-wrapper/gradle-wrapper.properties b/.gradle-wrapper/gradle-wrapper.properties index 47db2bb9e..1e77bf15c 100644 --- a/.gradle-wrapper/gradle-wrapper.properties +++ b/.gradle-wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Nov 30 13:27:43 CST 2015 +#Mon May 16 09:48:42 CDT 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip diff --git a/build/bnd.bnd b/build/bnd.bnd index 9db3e5b0c..9bf75508b 100644 --- a/build/bnd.bnd +++ b/build/bnd.bnd @@ -3,11 +3,11 @@ -releaserepo: # Main p2 feature -p2_main = \ +p2 = \ com.liferay.blade.api,\ com.liferay.blade.cli,\ com.liferay.blade.eclipse.provider,\ com.liferay.blade.gradle,\ com.liferay.blade.upgrade.liferay70 --dependson: ${p2_main} +-dependson: ${p2} diff --git a/build/build.gradle b/build/build.gradle index 51f2eb8b6..85dcf24de 100644 --- a/build/build.gradle +++ b/build/build.gradle @@ -19,7 +19,7 @@ configure(rootProject) { } import org.apache.tools.ant.filters.ReplaceTokens - +import aQute.bnd.osgi.Jar /* * Copy the bundle outputs of the specified projects into a directory @@ -27,12 +27,12 @@ import org.apache.tools.ant.filters.ReplaceTokens void copyProjectBundles(String[] projs, String dstDir) { def targetDir = file(dstDir) if ((!targetDir.exists() && !targetDir.mkdirs()) || !targetDir.isDirectory()) { - throw new GradleException("Could not create directory $targetDir") + throw new GradleException("Could not create directory ${targetDir}") } projs.each { def proj = rootProject.findProject(it) if (proj == null) { - throw new GradleException("Could not find project " + it) + throw new GradleException("Could not find project ${it}") } proj.bnd.project.getSubBuilders()*.getBsn().each { bsn -> @@ -58,14 +58,14 @@ ext.bnd_verbose = logger.isEnabled(LogLevel.INFO) void generateP2Repository(String title, String antTarget, String metadataRepository, String categoryDefinition) { def javaArgs = [] if (bnd_verbose) { - javaArgs += "-consoleLog" + javaArgs += '-consoleLog' } - javaArgs += "-application" + javaArgs += '-application' javaArgs += bnd_eclipseAntRunner - javaArgs += "-data" + javaArgs += '-data' javaArgs += buildDir - javaArgs += "-buildfile" - javaArgs += "p2.xml" + javaArgs += '-buildfile' + javaArgs += 'p2.xml' javaArgs += antTarget def result = javaexec { @@ -74,22 +74,22 @@ void generateP2Repository(String title, String antTarget, String metadataReposit args = javaArgs } if (result.exitValue != 0) { - throw new GradleException("Could not publish features and bundles - $title") + throw new GradleException("Could not publish features and bundles - ${title}") } javaArgs = [] if (bnd_verbose) { - javaArgs += "-consoleLog" + javaArgs += '-consoleLog' } - javaArgs += "-application" + javaArgs += '-application' javaArgs += bnd_eclipseCategoryPublisher - javaArgs += "-data" + javaArgs += '-data' javaArgs += buildDir - javaArgs += "-metadataRepository" - javaArgs += "file:$buildDir/$metadataRepository" - javaArgs += "-categoryDefinition" - javaArgs += "file:$buildDir/$categoryDefinition" - javaArgs += "-compress" + javaArgs += '-metadataRepository' + javaArgs += "file://${buildDir}/${metadataRepository}" + javaArgs += '-categoryDefinition' + javaArgs += "file://${buildDir}/${categoryDefinition}" + javaArgs += '-compress' result = javaexec { classpath = files(bnd_eclipseJar) @@ -97,68 +97,71 @@ void generateP2Repository(String title, String antTarget, String metadataReposit args = javaArgs } if (result.exitValue != 0) { - throw new GradleException("Could not categorise repository - $title") + throw new GradleException("Could not categorise repository - ${title}") } /* Clean up the files Eclipse leaves behind */ - fileTree("$bnd_eclipseDirectory").include("configuration/*.log").each { + fileTree(bnd_eclipseDirectory).include('configuration/*.log').each { it.delete() } - delete(file("$bnd_eclipseDirectory/configuration/org.eclipse.core.runtime")) - delete(file("$bnd_eclipseDirectory/configuration/org.eclipse.equinox.app" )) - delete(file("$bnd_eclipseDirectory/configuration/org.eclipse.osgi" )) - delete(file("$bnd_eclipseDirectory/p2" )) + delete(file("${bnd_eclipseDirectory}/configuration/org.eclipse.core.runtime")) + delete(file("${bnd_eclipseDirectory}/configuration/org.eclipse.equinox.app" )) + delete(file("${bnd_eclipseDirectory}/configuration/org.eclipse.osgi" )) + delete(file("${bnd_eclipseDirectory}/p2" )) } - -/* - * Setup tasks (p2 features) - */ -task p2FeaturesTree(type: Copy) { +def generateFeatureXmlTokens() { def masterVersion = String.format('%s.%s-%tY% + tokens["${jar.getBsn()}-version"] = jar.getVersion() + } + } + tokens } - -task p2PluginsMain(type: Copy) { +/* + * Setup tasks (p2 plugins) + */ +task p2Plugins(type: Copy) { dependsOn buildNeeded - from zipTree("$buildDir/${project.name}.main.jar") - into "$buildDir/plugins/main" - include "*.jar" + from zipTree("${buildDir}/${project.name}.main.jar") + into "${buildDir}/plugins" + include '*.jar' doLast { - copyProjectBundles(bnd('p2_main', '').split(/\s*,\s*/), "$buildDir/plugins/main") + copyProjectBundles(bnd('p2', '').split(/\s*,\s*/), "${buildDir}/plugins") } } -task p2Plugins { - dependsOn p2PluginsMain +/* + * Setup tasks (p2 features) + */ +task p2FeatureTree(type: Copy) { + dependsOn p2Plugins + from 'feature' + into "${buildDir}/features" + doFirst { + filter(ReplaceTokens, tokens: generateFeatureXmlTokens() ) + } + include '**/category.xml' + include '**/feature.xml' + inputs.files file("${buildDir}/plugins") +} + +task p2Feature(type: Zip) { + dependsOn p2FeatureTree + destinationDir = file("${buildDir}/features") + archiveName = 'com.liferay.blade.tools.jar' + from "${buildDir}/features/com.liferay.blade.tools" + include 'feature.xml' } /* @@ -167,53 +170,53 @@ task p2Plugins { task p2 { description 'Generate the p2 repositories.' group 'release' - dependsOn p2Features, p2Plugins + dependsOn p2Plugins, p2Feature inputs.files file('p2.xml'), fileTree(buildDir) .include('p2/**') - .include('features/main/category.xml') + .include('features/category.xml') + outputs.dir "${buildDir}/p2" doLast { - generateP2Repository("Main", "p2Main", "p2", "features/main/category.xml") - delete("$buildDir/features") - delete("$buildDir/plugins") + generateP2Repository('Blade', 'p2Blade', 'p2', 'features/category.xml') + //delete("${buildDir}/features") + //delete("${buildDir}/plugins") } } - -task('index') { +task index { description 'Index the p2 repositories.' dependsOn p2 group 'release' /* indexer */ - def repoindexJar = file('../cnf/cache/org.osgi.impl.bundle.repoindex.cli.jar') + def repoindexJar = bnd.project.getBundle('org.osgi.impl.bundle.repoindex.cli', 'latest', null, ['strategy':'highest']).getFile() /* Bundles to index. */ - def p2_index_main_bundles = fileTree("$buildDir/p2/plugins") { + def p2_index_bundles = fileTree("${buildDir}/p2/plugins") { include '**/*.jar' } - inputs.files p2_index_main_bundles + inputs.files p2_index_bundles /* Index files */ - def p2_index_main = new File("$buildDir/p2/index.xml.gz") + def p2_index = new File("${buildDir}/p2/index.xml.gz") - outputs.files p2_index_main + outputs.files p2_index doLast { - /* p2 main */ - def bundlesToIndex = p2_index_main_bundles*.absolutePath + /* p2 */ + def bundlesToIndex = p2_index_bundles*.absolutePath javaexec { main = '-jar' // first arg must be the jar args repoindexJar - args '-r', p2_index_main - args '-d', "$buildDir/p2" + args '-r', p2_index + args '-d', "${buildDir}/p2" args '-n', 'Blade' args bundlesToIndex }.assertNormalExitValue() - logger.info "Generated index ${p2_index_main}." + logger.info 'Generated index {}.', p2_index } } @@ -221,16 +224,12 @@ task('index') { /* * Setup tasks (distribution) */ -task distZipMain(type: Zip) { +task dist(type: Zip) { + description 'Create distribution archives containing p2 repository (including R5 index).' + group 'release' dependsOn index destinationDir = file(buildDir) - archiveName = "blade-tools-latest.zip" - from "$buildDir/p2" - include "**" -} - -task dist { - description 'Create distribution archives containing p2 repositories (including R5 indexes).' - group 'release' - dependsOn index, distZipMain + archiveName = 'blade-tools-latest.zip' + from "${buildDir}/p2" + include '**' } diff --git a/build/feature/main/category.xml b/build/feature/category.xml similarity index 100% rename from build/feature/main/category.xml rename to build/feature/category.xml diff --git a/build/feature/main/com.liferay.blade.tools/feature.xml b/build/feature/com.liferay.blade.tools/feature.xml similarity index 76% rename from build/feature/main/com.liferay.blade.tools/feature.xml rename to build/feature/com.liferay.blade.tools/feature.xml index 4042892bd..4e93e86b5 100644 --- a/build/feature/main/com.liferay.blade.tools/feature.xml +++ b/build/feature/com.liferay.blade.tools/feature.xml @@ -22,42 +22,42 @@ id="biz.aQute.remote.api" download-size="0" install-size="0" - version="0.0.0" + version="@biz.aQute.remote.api-version@" unpack="false"/> diff --git a/build/main.bnd b/build/main.bnd index eeefdcbc3..8104c8873 100644 --- a/build/main.bnd +++ b/build/main.bnd @@ -1,4 +1,4 @@ # Only extra bundles that are needed for the main feature are mentioned here +-resourceonly: true Include-Resource: \ - ${repo;biz.aQute.remote.api;3.1.0},\ - ${repo;biz.aQute.repository;3.1.0} + ${repo;biz.aQute.remote.api;3.2.0} diff --git a/build/p2.xml b/build/p2.xml index 9b866862d..1684861ad 100644 --- a/build/p2.xml +++ b/build/p2.xml @@ -14,16 +14,15 @@ - + - - + + - diff --git a/cnf/build.bnd b/cnf/build.bnd index 569d613e5..4f61d50bd 100644 --- a/cnf/build.bnd +++ b/cnf/build.bnd @@ -1,4 +1,4 @@ -base-version: 1.0.0 +base-version: 1.1.0 base-version-qualifier: DEV Git-Descriptor: ${system-allow-fail;git describe --dirty --always} diff --git a/cnf/ext/repositories.bnd b/cnf/ext/repositories.bnd index 742ba7e09..1385c51fa 100644 --- a/cnf/ext/repositories.bnd +++ b/cnf/ext/repositories.bnd @@ -1,7 +1,4 @@ -bnd-release=https://dl.bintray.com/bnd/dist/3.1.0/ - --pluginpath:\ - ${build}/cache/org.osgi.impl.bundle.repoindex.cli.jar;url=${bnd-release}/org.osgi.impl.bundle.repoindex.cli/org.osgi.impl.bundle.repoindex.cli-latest.jar +-include: ${build}/../gradle.properties -plugin.wrapper: \ aQute.bnd.deployer.repository.wrapper.Plugin; \ @@ -30,7 +27,7 @@ bnd-release=https://dl.bintray.com/bnd/dist/3.1.0/ -plugin.bndrepo = \ aQute.bnd.deployer.repository.FixedIndexedRepo; \ name=bnd.master; \ - locations=${bnd-release}/index.xml.gz + locations=${bnd_repourl}/index.xml.gz -plugin.jpmrepo = \ aQute.bnd.jpm.Repository; \ diff --git a/com.liferay.blade.cli/src/com/liferay/blade/cli/gradle/GradleTooling.java b/com.liferay.blade.cli/src/com/liferay/blade/cli/gradle/GradleTooling.java index 9b0f77bcb..ead7971bb 100644 --- a/com.liferay.blade.cli/src/com/liferay/blade/cli/gradle/GradleTooling.java +++ b/com.liferay.blade.cli/src/com/liferay/blade/cli/gradle/GradleTooling.java @@ -19,16 +19,13 @@ import aQute.bnd.osgi.Jar; import aQute.bnd.osgi.Processor; import aQute.bnd.osgi.Resource; - import aQute.lib.io.IO; import com.liferay.blade.gradle.model.CustomModel; import java.io.File; import java.io.InputStream; - import java.nio.file.Files; - import java.util.Map.Entry; import java.util.Set; @@ -92,6 +89,24 @@ public static Set getOutputFiles(File cacheDir, File buildDir) return model.getOutputFiles(); } + public static Set getPluginClassNames(File cacheDir, File buildDir) + throws Exception { + + final CustomModel model = getModel( + CustomModel.class, cacheDir, buildDir); + + return model.getPluginClassNames(); + } + + public static boolean isLiferayModule(File cacheDir, File buildDir) + throws Exception { + + final CustomModel model = getModel( + CustomModel.class, cacheDir, buildDir); + + return model.isLiferayModule(); + } + private static void copy(InputStream in, File outputDir) throws Exception { try (Jar jar = new Jar("dot", in)) { for (Entry e : jar.getResources().entrySet()) { diff --git a/com.liferay.blade.cli/test/com/liferay/blade/cli/gradle/GradleToolingTest.java b/com.liferay.blade.cli/test/com/liferay/blade/cli/gradle/GradleToolingTest.java index ba0064523..48671e6c4 100644 --- a/com.liferay.blade.cli/test/com/liferay/blade/cli/gradle/GradleToolingTest.java +++ b/com.liferay.blade.cli/test/com/liferay/blade/cli/gradle/GradleToolingTest.java @@ -17,6 +17,7 @@ package com.liferay.blade.cli.gradle; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -85,4 +86,20 @@ public void testGetOutputFiles() throws Exception { assertEquals(17, files.size()); } + @Test + public void testGetPluginClassNames() throws Exception { + Set pluginClassNames = GradleTooling.getPluginClassNames ( + new File("bin_test"), new File(".")); + + assertNotNull(pluginClassNames); + assertTrue(pluginClassNames.contains("aQute.bnd.gradle.BndPlugin")); + } + + @Test + public void testIsLiferayModule() throws Exception { + boolean isModule = GradleTooling.isLiferayModule ( + new File("bin_test"), new File(".")); + + assertFalse(isModule); + } } diff --git a/com.liferay.blade.gradle/model.bnd b/com.liferay.blade.gradle/model.bnd index ba5c507e2..7fa9dedc7 100644 --- a/com.liferay.blade.gradle/model.bnd +++ b/com.liferay.blade.gradle/model.bnd @@ -1,4 +1,4 @@ -Bundle-Version: 1.0.0.${tstamp} +Bundle-Version: 1.1.0.${tstamp} Export-Package: com.liferay.blade.gradle.model diff --git a/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/CustomModel.java b/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/CustomModel.java index 2bdc8121b..45affec85 100644 --- a/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/CustomModel.java +++ b/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/CustomModel.java @@ -17,7 +17,6 @@ package com.liferay.blade.gradle.model; import java.io.File; - import java.util.Set; /** @@ -31,4 +30,6 @@ public interface CustomModel { public boolean hasPlugin(String className); + public boolean isLiferayModule(); + } \ No newline at end of file diff --git a/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/DefaultModel.java b/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/DefaultModel.java index d7d001ed4..557fc3458 100644 --- a/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/DefaultModel.java +++ b/com.liferay.blade.gradle/src/com/liferay/blade/gradle/model/DefaultModel.java @@ -18,14 +18,13 @@ import java.io.File; import java.io.Serializable; - import java.util.Set; /** * @author Gregory Amerson */ @SuppressWarnings("serial") -public class DefaultModel implements Serializable { +public class DefaultModel implements CustomModel, Serializable { public DefaultModel(Set pluginClassNames, Set outputFiles) { _pluginClassNames = pluginClassNames; @@ -44,6 +43,14 @@ public boolean hasPlugin(String pluginClassName) { return _pluginClassNames.contains(pluginClassName); } + public boolean isLiferayModule() { + return + hasPlugin("aQute.bnd.gradle.BndBuilderPlugin") || + hasPlugin("com.liferay.gradle.plugins.LiferayPlugin") || + hasPlugin("com.liferay.gradle.plugins.LiferayOSGiPlugin") || + hasPlugin("com.liferay.gradle.plugins.gulp.GulpPlugin"); + } + private final Set _outputFiles; private final Set _pluginClassNames; diff --git a/gradle.properties b/gradle.properties index 4c7849e03..952c1cc5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,10 +2,10 @@ bnd_cnf=cnf # bnd_plugin is the dependency declaration for the bnd gradle plugin -bnd_plugin=biz.aQute.bnd:biz.aQute.bnd.gradle:latest +bnd_plugin=biz.aQute.bnd:biz.aQute.bnd.gradle:3.2.0-SNAPSHOT # The URL to the repo to load the bnd gradle plugin -bnd_repourl=https://dl.bintray.com/bnd/dist/3.1.0/ +bnd_repourl=https://bndtools.ci.cloudbees.com/job/bnd.master/993/artifact/dist/bundles # bnd_build can be set to the name of a "master" project whose dependencies will seed the set of projects to build. bnd_build= diff --git a/gradlew b/gradlew index 33b4e6a62..a8ac9b94a 100755 --- a/gradlew +++ b/gradlew @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/.gradle-wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then diff --git a/gradlew.bat b/gradlew.bat index e191a7ad9..57e1569e4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,7 +46,7 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args diff --git a/settings.gradle b/settings.gradle index 899123202..13905708b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,12 +9,8 @@ import aQute.bnd.build.Workspace /* Add bnd gradle plugin as a script dependency */ buildscript { repositories { - ivy { /* Configure the repository as an "ivy" repository */ + maven { url bnd_repourl - layout 'pattern', { - artifact '[module]/[artifact]-[revision].[ext]' /* OSGi repo pattern */ - artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier])(.[ext])' /* maven pattern */ - } } } dependencies {