From 9634f78025ed2d8f5adc8d014918cdb58228479d Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Fri, 11 Jul 2014 11:12:32 +0200 Subject: [PATCH] Add bucklet based build to plugin archetype If a plugin project is generated with the Maven plugin archetype it should immediately be buildable with Buck, because Buck is our preferred build tool for building plugins. Change-Id: I158dc3df76e4585d9894b0be862aef4d13deb478 Signed-off-by: Edwin Kempin --- .../META-INF/maven/archetype-metadata.xml | 11 +++ .../resources/archetype-resources/.buckconfig | 14 ++++ .../resources/archetype-resources/.gitignore | 4 + .../main/resources/archetype-resources/BUCK | 22 ++++++ .../resources/archetype-resources/VERSION | 5 ++ .../archetype-resources/lib/gerrit/BUCK | 12 +++ .../src/main/resources/Documentation/build.md | 79 +++++++++++++++++++ 7 files changed, 147 insertions(+) create mode 100644 gerrit-plugin-archetype/src/main/resources/archetype-resources/.buckconfig create mode 100644 gerrit-plugin-archetype/src/main/resources/archetype-resources/BUCK create mode 100644 gerrit-plugin-archetype/src/main/resources/archetype-resources/VERSION create mode 100644 gerrit-plugin-archetype/src/main/resources/archetype-resources/lib/gerrit/BUCK create mode 100644 gerrit-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/Documentation/build.md diff --git a/gerrit-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/gerrit-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml index 21f508b87b..681af10adc 100644 --- a/gerrit-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/gerrit-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -58,6 +58,17 @@ limitations under the License. + + + .buckconfig + BUCK + VERSION + lib/gerrit/BUCK + + **/*.java + + + diff --git a/gerrit-plugin-archetype/src/main/resources/archetype-resources/.buckconfig b/gerrit-plugin-archetype/src/main/resources/archetype-resources/.buckconfig new file mode 100644 index 0000000000..1044c124a9 --- /dev/null +++ b/gerrit-plugin-archetype/src/main/resources/archetype-resources/.buckconfig @@ -0,0 +1,14 @@ +[alias] + ${pluginName} = //:${pluginName} + plugin = //:${pluginName} + +[java] + src_roots = java, resources + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache + diff --git a/gerrit-plugin-archetype/src/main/resources/archetype-resources/.gitignore b/gerrit-plugin-archetype/src/main/resources/archetype-resources/.gitignore index 80d62575a1..43838b01c6 100644 --- a/gerrit-plugin-archetype/src/main/resources/archetype-resources/.gitignore +++ b/gerrit-plugin-archetype/src/main/resources/archetype-resources/.gitignore @@ -1,3 +1,7 @@ +/.buckversion +/.buckd +/buck-out +/bucklets /target /.classpath /.project diff --git a/gerrit-plugin-archetype/src/main/resources/archetype-resources/BUCK b/gerrit-plugin-archetype/src/main/resources/archetype-resources/BUCK new file mode 100644 index 0000000000..55a2a4a842 --- /dev/null +++ b/gerrit-plugin-archetype/src/main/resources/archetype-resources/BUCK @@ -0,0 +1,22 @@ +include_defs('//bucklets/gerrit_plugin.bucklet') + +gerrit_plugin( + name = '${pluginName}', + srcs = glob(['src/main/java/**/*.java']), + resources = glob(['src/main/resources/**/*']), + manifest_entries = [ + 'Gerrit-PluginName: ${pluginName}', + 'Gerrit-ApiType: ${gerritApiType}', + 'Gerrit-ApiVersion: ${gerritApiVersion}', + 'Gerrit-Module: ${package}.Module', + 'Gerrit-SshModule: ${package}.SshModule', + 'Gerrit-HttpModule: ${package}.HttpModule', + ], +) + +# this is required for bucklets/tools/eclipse/project.py to work +java_library( + name = 'classpath', + deps = [':${pluginName}__plugin'], +) + diff --git a/gerrit-plugin-archetype/src/main/resources/archetype-resources/VERSION b/gerrit-plugin-archetype/src/main/resources/archetype-resources/VERSION new file mode 100644 index 0000000000..8bbb460c0f --- /dev/null +++ b/gerrit-plugin-archetype/src/main/resources/archetype-resources/VERSION @@ -0,0 +1,5 @@ +# Used by BUCK to include "Implementation-Version" in plugin Manifest. +# If this file doesn't exist the output of 'git describe' is used +# instead. +PLUGIN_VERSION = '${version}' + diff --git a/gerrit-plugin-archetype/src/main/resources/archetype-resources/lib/gerrit/BUCK b/gerrit-plugin-archetype/src/main/resources/archetype-resources/lib/gerrit/BUCK new file mode 100644 index 0000000000..b1648d3498 --- /dev/null +++ b/gerrit-plugin-archetype/src/main/resources/archetype-resources/lib/gerrit/BUCK @@ -0,0 +1,12 @@ +include_defs('//bucklets/maven_jar.bucklet') + +VER = '${gerritApiVersion}' +REPO = MAVEN_LOCAL + +maven_jar( + name = '${gerritApiType}-api', + id = 'com.google.gerrit:gerrit-${gerritApiType}-api:' + VER, + attach_source = False, + repository = REPO, + license = 'Apache2.0', +) diff --git a/gerrit-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/Documentation/build.md b/gerrit-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/Documentation/build.md new file mode 100644 index 0000000000..80f0627da7 --- /dev/null +++ b/gerrit-plugin-archetype/src/main/resources/archetype-resources/src/main/resources/Documentation/build.md @@ -0,0 +1,79 @@ +Build +===== + +This plugin can be built with Buck or Maven. + +Buck +---- + +Two build modes are supported: Standalone and in Gerrit tree. +The standalone build mode is recommended, as this mode doesn't require +the Gerrit tree to exist locally. + + +### Build standalone + +Clone bucklets library: + +``` + git clone https://gerrit.googlesource.com/bucklets + +``` +and link it to @PLUGIN@ plugin directory: + +``` + cd @PLUGIN@ && ln -s ../bucklets . +``` + +Add link to the .buckversion file: + +``` + cd @PLUGIN@ && ln -s bucklets/buckversion .buckversion +``` + +To build the plugin, issue the following command: + + +``` + buck build plugin +``` + +The output is created in + +``` + buck-out/gen/@PLUGIN@.jar +``` + +### Build in Gerrit tree + +Clone or link this plugin to the plugins directory of Gerrit's source +tree, and issue the command: + +``` + buck build plugins/@PLUGIN@ +``` + +The output is created in + +``` + buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar +``` + +This project can be imported into the Eclipse IDE: + +``` + ./tools/eclipse/project.py +``` + +Maven +----- + +Note that the Maven build is provided for compatibility reasons, but +it is considered to be deprecated and will be removed in a future +version of this plugin. + +To build with Maven, run + +``` +mvn clean package +```