Merge branch 'stable-2.14' into stable-2.15 * stable-2.14: Update maven build to 2.14.20 Remove Buck based build Update bazlets to latest stable-2.14 Update bazlets to Gerrit API 2.14.20 Change-Id: I5a2034080f072a807b87a66692ea18b46535e3fd
diff --git a/.gitignore b/.gitignore index d9bb257..ab5a64f 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,6 +1,5 @@ bazel-bin bazel-example* -bazel-genfiles bazel-out bazel-testlogs *.idea
diff --git a/BUILD b/BUILD index a399a21..4901d67 100644 --- a/BUILD +++ b/BUILD
@@ -4,15 +4,19 @@ "//example-adminSshCommand", "//example-changeHasOperator", "//example-changeOperator", + "//example-changeQueryAttributes", "//example-commitValidator", "//example-consoleMetricReporter", "//example-deployedOnIncludedInExtension", + "//example-restApiCommandOption", "//example-restApiGetRevision", "//example-restApiPostProject", "//example-restApiPostRevision", "//example-servlet", "//example-simpleSshCommand", + "//example-sshAndRestCommandOptionBeanParseListener", "//example-sshCommandAlias", + "//example-sshCommandOption", "//example-topMenu", "//example-usageDataLogger", "//example-validationListenerAssignee", @@ -30,6 +34,7 @@ "//example-wuiChangeScreenHeader", "//example-wuiChangeScreenHeaderRightOfButtons", "//example-wuiChangeScreenHeaderRightOfPopDowns", + "//example-wuiPluginScreen", "//example-wuiPreferenceScreenBottom", "//example-wuiProfileExtensionBottom", "//example-wuiSettingsScreen",
diff --git a/README b/README index b268063..c1e573b 100644 --- a/README +++ b/README
@@ -16,7 +16,7 @@ The output for all the example plugins is created in - bazel-genfiles/all.zip + bazel-bin/all.zip To build a specific example plugin, issue one of the following commands: @@ -33,14 +33,14 @@ the output for the example is created in - bazel-genfiles/example-<example>/example-<example>.jar + bazel-bin/example-<example>/example-<example>.jar If the build command is run from inside a specific example directory, the output for the example is created in - example-<example>/bazel-genfiles/example-<example>.jar + example-<example>/bazel-bin/example-<example>.jar
diff --git a/WORKSPACE b/WORKSPACE index ef91a0b..d9e1dd3 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-adminSshCommand/WORKSPACE b/example-adminSshCommand/WORKSPACE index 0bef1e6..c2c98fa 100644 --- a/example-adminSshCommand/WORKSPACE +++ b/example-adminSshCommand/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-adminSshCommand/pom.xml b/example-adminSshCommand/pom.xml index f685780..9a87157 100644 --- a/example-adminSshCommand/pom.xml +++ b/example-adminSshCommand/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-adminSshCommand</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java b/example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java index 61a8514..3c31b6b 100644 --- a/example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java +++ b/example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
@@ -17,13 +17,26 @@ import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; +import org.kohsuke.args4j.Option; @RequiresCapability(AdminExampleCapability.ADMIN_EXAMPLE) @CommandMetaData(name = "admin", description = "Administrate the example") public final class AdminExampleCommand extends SshCommand { + private int count = 1; + + @Option( + name = "--count", + aliases = {"-c"}, + metaVar = "COUNT", + usage = "Number of times to greet the administrator") + public void setCount(int count) { + this.count = count; + } @Override protected void run() { - stdout.print("Hello, example administrator\n"); + while (count-- > 0) { + stdout.print("Hello, example administrator\n"); + } } }
diff --git a/example-changeHasOperator/WORKSPACE b/example-changeHasOperator/WORKSPACE index bc95d16..5b753b6 100644 --- a/example-changeHasOperator/WORKSPACE +++ b/example-changeHasOperator/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-changeHasOperator/pom.xml b/example-changeHasOperator/pom.xml index 54ca1ac..c020e06 100644 --- a/example-changeHasOperator/pom.xml +++ b/example-changeHasOperator/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-changeHasOperator</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/Module.java b/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/Module.java index 2b97a40..485727d 100644 --- a/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/Module.java +++ b/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/Module.java
@@ -21,8 +21,8 @@ public class Module extends AbstractModule { @Override protected void configure() { - bind(ChangeHasOperandFactory.class) - .annotatedWith(Exports.named("odd")) - .to(SampleHasOperand.class); + bind(ChangeHasOperandFactory.class) + .annotatedWith(Exports.named("odd")) + .to(SampleHasOperand.class); } }
diff --git a/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/SampleHasOperand.java b/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/SampleHasOperand.java index a3664fd..cb1c08a 100644 --- a/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/SampleHasOperand.java +++ b/example-changeHasOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changehasoperator/SampleHasOperand.java
@@ -14,16 +14,15 @@ package com.googlesource.gerrit.plugins.examples.changehasoperator; -import com.google.gerrit.server.query.Predicate; -import com.google.gerrit.server.query.QueryParseException; +import com.google.gerrit.index.query.Predicate; +import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeOperatorPredicate; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.inject.Singleton; @Singleton -public class SampleHasOperand - implements ChangeQueryBuilder.ChangeHasOperandFactory { +public class SampleHasOperand implements ChangeQueryBuilder.ChangeHasOperandFactory { public static class MyOddPredicate extends ChangeOperatorPredicate { MyOddPredicate() { @@ -42,8 +41,7 @@ } @Override - public Predicate<ChangeData> create(ChangeQueryBuilder builder) - throws QueryParseException { + public Predicate<ChangeData> create(ChangeQueryBuilder builder) throws QueryParseException { return new MyOddPredicate(); } }
diff --git a/example-changeOperator/WORKSPACE b/example-changeOperator/WORKSPACE index 3a23330..0cc951a 100644 --- a/example-changeOperator/WORKSPACE +++ b/example-changeOperator/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-changeOperator/pom.xml b/example-changeOperator/pom.xml index 0db38f3..a276628 100644 --- a/example-changeOperator/pom.xml +++ b/example-changeOperator/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-changeOperator</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java b/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java index 7049b65..940babc 100644 --- a/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java +++ b/example-changeOperator/src/main/java/com/googlesource/gerrit/plugins/examples/changeoperator/SampleOperator.java
@@ -14,17 +14,16 @@ package com.googlesource.gerrit.plugins.examples.changeoperator; +import com.google.gerrit.index.query.Predicate; +import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.server.query.Predicate; -import com.google.gerrit.server.query.QueryParseException; import com.google.gerrit.server.query.change.ChangeData; import com.google.gerrit.server.query.change.ChangeOperatorPredicate; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.inject.Singleton; @Singleton -public class SampleOperator - implements ChangeQueryBuilder.ChangeOperatorFactory { +public class SampleOperator implements ChangeQueryBuilder.ChangeOperatorFactory { public static class MyPredicate extends ChangeOperatorPredicate { private final Change.Id id;
diff --git a/example-changeQueryAttributes/.bazelrc b/example-changeQueryAttributes/.bazelrc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/example-changeQueryAttributes/.bazelrc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/example-changeQueryAttributes/.buckconfig b/example-changeQueryAttributes/.buckconfig new file mode 100644 index 0000000..4a12d85 --- /dev/null +++ b/example-changeQueryAttributes/.buckconfig
@@ -0,0 +1,15 @@ +[alias] + plugin = //:example-changeQueryAttributes + +[java] + src_roots = java, resources + source_level = 8 + target_level = 8 + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/example-changeQueryAttributes/BUILD b/example-changeQueryAttributes/BUILD new file mode 100644 index 0000000..df13ae5 --- /dev/null +++ b/example-changeQueryAttributes/BUILD
@@ -0,0 +1,12 @@ +load("//tools/bzl:plugin.bzl", "gerrit_plugin") + +gerrit_plugin( + name = "example-changeQueryAttributes", + srcs = glob(["src/main/java/**/*.java"]), + manifest_entries = [ + "Gerrit-PluginName: example-changeQueryAttributes", + "Gerrit-Module: com.googlesource.gerrit.plugins.examples.changequeryattributes.Module", + "Implementation-Title: Example Simple Change Query Attribute", + ], + resources = glob(["src/main/resources/**/*"]), +)
diff --git a/example-changeQueryAttributes/LICENSE b/example-changeQueryAttributes/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/example-changeQueryAttributes/LICENSE
@@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
diff --git a/example-changeQueryAttributes/WORKSPACE b/example-changeQueryAttributes/WORKSPACE new file mode 100644 index 0000000..cdf72ac --- /dev/null +++ b/example-changeQueryAttributes/WORKSPACE
@@ -0,0 +1,26 @@ +workspace(name = "changeQueryAttributes") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", + # local_path = "/home/<user>/projects/bazlets", +) + +# Release Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", + "gerrit_api", +) + +# Snapshot Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", +# "gerrit_api_maven_local", +#) + +# Load release Plugin API +gerrit_api() + +# Load snapshot Plugin API +#gerrit_api_maven_local()
diff --git a/example-changeQueryAttributes/bazlets.bzl b/example-changeQueryAttributes/bazlets.bzl new file mode 100644 index 0000000..6c4fffc --- /dev/null +++ b/example-changeQueryAttributes/bazlets.bzl
@@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/example-changeQueryAttributes/pom.xml b/example-changeQueryAttributes/pom.xml new file mode 100644 index 0000000..8421d33 --- /dev/null +++ b/example-changeQueryAttributes/pom.xml
@@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2013 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.googlesource.gerrit.plugins</groupId> + <artifactId>example-changeQueryAttributes</artifactId> + <packaging>jar</packaging> + <version>2.15-SNAPSHOT</version> + <properties> + <Gerrit-ApiType>plugin</Gerrit-ApiType> + <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <Gerrit-PluginName>example-changeQueryAttributes</Gerrit-PluginName> + <Gerrit-Module>com.googlesource.gerrit.plugins.examples.changequeryattributes.Module</Gerrit-Module> + + <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> + <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/examples</Implementation-URL> + + <Implementation-Title>Example Simple Change Query Attribute</Implementation-Title> + <Implementation-Version>${project.version}</Implementation-Version> + + <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> + <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + </plugins> + + </build> + + <dependencies> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>maven.org</id> + <url>http://repo1.maven.org/maven2</url> + </repository> + </repositories> +</project>
diff --git a/example-changeQueryAttributes/src/main/java/com/googlesource/gerrit/plugins/examples/changequeryattributes/AttributeFactory.java b/example-changeQueryAttributes/src/main/java/com/googlesource/gerrit/plugins/examples/changequeryattributes/AttributeFactory.java new file mode 100644 index 0000000..dbf4e43 --- /dev/null +++ b/example-changeQueryAttributes/src/main/java/com/googlesource/gerrit/plugins/examples/changequeryattributes/AttributeFactory.java
@@ -0,0 +1,38 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.changequeryattributes; + +import com.google.gerrit.extensions.common.PluginDefinedInfo; +import com.google.gerrit.server.query.change.ChangeData; +import com.google.gerrit.server.query.change.ChangeQueryProcessor; +import com.google.gerrit.server.query.change.ChangeQueryProcessor.ChangeAttributeFactory; + +public class AttributeFactory implements ChangeAttributeFactory { + + public class PluginAttribute extends PluginDefinedInfo { + public String exampleName; + public String changeValue; + + public PluginAttribute(ChangeData c) { + this.exampleName = "Plugin Defined Attribute Example"; + this.changeValue = Integer.toString(c.getId().get()); + } + } + + @Override + public PluginDefinedInfo create(ChangeData c, ChangeQueryProcessor qp, String plugin) { + return new PluginAttribute(c); + } +}
diff --git a/example-changeQueryAttributes/src/main/java/com/googlesource/gerrit/plugins/examples/changequeryattributes/Module.java b/example-changeQueryAttributes/src/main/java/com/googlesource/gerrit/plugins/examples/changequeryattributes/Module.java new file mode 100644 index 0000000..f01989d --- /dev/null +++ b/example-changeQueryAttributes/src/main/java/com/googlesource/gerrit/plugins/examples/changequeryattributes/Module.java
@@ -0,0 +1,28 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.changequeryattributes; + +import com.google.gerrit.extensions.annotations.Exports; +import com.google.gerrit.server.query.change.ChangeQueryProcessor.ChangeAttributeFactory; +import com.google.inject.AbstractModule; + +public class Module extends AbstractModule { + @Override + protected void configure() { + bind(ChangeAttributeFactory.class) + .annotatedWith(Exports.named("example-changeQueryAttributes")) + .to(AttributeFactory.class); + } +}
diff --git a/example-changeQueryAttributes/src/main/resources/Documentation/about.md b/example-changeQueryAttributes/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..b73a741 --- /dev/null +++ b/example-changeQueryAttributes/src/main/resources/Documentation/about.md
@@ -0,0 +1 @@ +Sample plugin to demonstrate the ability to add plugin-defined attributes to Gerrit's change query via plugin.
diff --git a/example-changeQueryAttributes/tools/bzl/BUILD b/example-changeQueryAttributes/tools/bzl/BUILD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example-changeQueryAttributes/tools/bzl/BUILD
diff --git a/example-changeQueryAttributes/tools/bzl/plugin.bzl b/example-changeQueryAttributes/tools/bzl/plugin.bzl new file mode 100644 index 0000000..89a1643 --- /dev/null +++ b/example-changeQueryAttributes/tools/bzl/plugin.bzl
@@ -0,0 +1,8 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + _gerrit_plugin = "gerrit_plugin", + _plugin_deps = "PLUGIN_DEPS", +) + +gerrit_plugin = _gerrit_plugin +PLUGIN_DEPS = _plugin_deps
diff --git a/example-changeQueryAttributes/tools/workspace-status.sh b/example-changeQueryAttributes/tools/workspace-status.sh new file mode 100755 index 0000000..0149867 --- /dev/null +++ b/example-changeQueryAttributes/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + git describe --always --match "v[0-9].*" --dirty +} + +echo STABLE_BUILD_EXAMPLE-CHANGEQUERYATTRIBUTES_LABEL $(rev)
diff --git a/example-commitValidator/WORKSPACE b/example-commitValidator/WORKSPACE index 9187dac..1630fce 100644 --- a/example-commitValidator/WORKSPACE +++ b/example-commitValidator/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-commitValidator/pom.xml b/example-commitValidator/pom.xml index a515785..9577610 100644 --- a/example-commitValidator/pom.xml +++ b/example-commitValidator/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-commitValidator</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-commitValidator/src/main/java/com/googlesource/gerrit/plugins/examples/commitvalidator/Module.java b/example-commitValidator/src/main/java/com/googlesource/gerrit/plugins/examples/commitvalidator/Module.java index 5869752..a7ad31f 100644 --- a/example-commitValidator/src/main/java/com/googlesource/gerrit/plugins/examples/commitvalidator/Module.java +++ b/example-commitValidator/src/main/java/com/googlesource/gerrit/plugins/examples/commitvalidator/Module.java
@@ -14,14 +14,13 @@ package com.googlesource.gerrit.plugins.examples.commitvalidator; -import com.google.inject.AbstractModule; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.server.git.validators.CommitValidationListener; +import com.google.inject.AbstractModule; public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), - CommitValidationListener.class).to(CommitValidator.class); + DynamicSet.bind(binder(), CommitValidationListener.class).to(CommitValidator.class); } }
diff --git a/example-consoleMetricReporter/WORKSPACE b/example-consoleMetricReporter/WORKSPACE index 6428e67..8f95ba9 100644 --- a/example-consoleMetricReporter/WORKSPACE +++ b/example-consoleMetricReporter/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-consoleMetricReporter/pom.xml b/example-consoleMetricReporter/pom.xml index b8c4e1a..a97f5ba 100644 --- a/example-consoleMetricReporter/pom.xml +++ b/example-consoleMetricReporter/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-consoleMetricReporter</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/ConsoleMetricReporter.java b/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/ConsoleMetricReporter.java index d3b8c5d..eb9fe0d 100644 --- a/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/ConsoleMetricReporter.java +++ b/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/ConsoleMetricReporter.java
@@ -13,36 +13,33 @@ // limitations under the License. package com.googlesource.gerrit.plugins.examples.consolemetricreporter; +import com.codahale.metrics.ConsoleReporter; +import com.codahale.metrics.MetricRegistry; import com.google.gerrit.extensions.annotations.Listen; import com.google.gerrit.extensions.annotations.PluginName; import com.google.gerrit.extensions.events.LifecycleListener; import com.google.gerrit.server.config.PluginConfigFactory; import com.google.inject.Inject; import com.google.inject.Singleton; - -import com.codahale.metrics.ConsoleReporter; -import com.codahale.metrics.MetricRegistry; - +import java.util.concurrent.TimeUnit; import org.eclipse.jgit.lib.Config; -import java.util.concurrent.TimeUnit; - /** - * Demonstration of how to add a new Dropwizard Metrics Reporter using - * Gerrit's plug-in API. + * Demonstration of how to add a new Dropwizard Metrics Reporter using Gerrit's plug-in API. * - * @see <a href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-jmx">here</a> - * @see <a href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-http">here</a> - * @see <a href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#other-reporting">here</a> - * - * Also shows how to fetch plug-in specific configuration values. - * <@see com.google.gerrit.server.config.PluginConfigFactory> - * - * Enable by adding the file etc/example-consoleMetricReporter.config: - * + * @see <a + * href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-jmx">here</a> + * @see <a + * href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#reporting-via-http">here</a> + * @see <a + * href="https://dropwizard.github.io/metrics/3.1.0/getting-started/#other-reporting">here</a> + * <p>Also shows how to fetch plug-in specific configuration values. <@see + * com.google.gerrit.server.config.PluginConfigFactory> + * <p>Enable by adding the file etc/example-consoleMetricReporter.config: + * <pre> * [console-metrics] * enabled = true - * + * </pre> */ @Listen @Singleton @@ -51,17 +48,18 @@ private boolean enabled; @Inject - public ConsoleMetricReporter(MetricRegistry registry, - PluginConfigFactory configFactory, - @PluginName String pluginName) { + public ConsoleMetricReporter( + MetricRegistry registry, PluginConfigFactory configFactory, @PluginName String pluginName) { Config config = configFactory.getGlobalPluginConfig(pluginName); enabled = config.getBoolean("console-metrics", "enabled", false); if (!enabled) { return; } this.consoleReporter = - ConsoleReporter.forRegistry(registry).convertRatesTo(TimeUnit.SECONDS) - .convertDurationsTo(TimeUnit.MILLISECONDS).build(); + ConsoleReporter.forRegistry(registry) + .convertRatesTo(TimeUnit.SECONDS) + .convertDurationsTo(TimeUnit.MILLISECONDS) + .build(); } @Override
diff --git a/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/Module.java b/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/Module.java index c1e1deb..d0a4879 100644 --- a/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/Module.java +++ b/example-consoleMetricReporter/src/main/java/com/googlesource/gerrit/plugins/examples/consolemetricreporter/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), LifecycleListener.class) - .to(ConsoleMetricReporter.class); + DynamicSet.bind(binder(), LifecycleListener.class).to(ConsoleMetricReporter.class); } }
diff --git a/example-deployedOnIncludedInExtension/WORKSPACE b/example-deployedOnIncludedInExtension/WORKSPACE index 20218a5..5ad59a2 100644 --- a/example-deployedOnIncludedInExtension/WORKSPACE +++ b/example-deployedOnIncludedInExtension/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-deployedOnIncludedInExtension/pom.xml b/example-deployedOnIncludedInExtension/pom.xml index 885b65e..a1c867c 100644 --- a/example-deployedOnIncludedInExtension/pom.xml +++ b/example-deployedOnIncludedInExtension/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-deployedOnIncludedInExtension</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-deployedOnIncludedInExtension/src/main/java/com/googlesource/gerrit/plugins/examples/deployedonincludedinextension/Module.java b/example-deployedOnIncludedInExtension/src/main/java/com/googlesource/gerrit/plugins/examples/deployedonincludedinextension/Module.java index 9015ea2..3ad59f7 100644 --- a/example-deployedOnIncludedInExtension/src/main/java/com/googlesource/gerrit/plugins/examples/deployedonincludedinextension/Module.java +++ b/example-deployedOnIncludedInExtension/src/main/java/com/googlesource/gerrit/plugins/examples/deployedonincludedinextension/Module.java
@@ -14,14 +14,13 @@ package com.googlesource.gerrit.plugins.examples.deployedonincludedinextension; -import com.google.inject.AbstractModule; -import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.config.ExternalIncludedIn; +import com.google.gerrit.extensions.registration.DynamicSet; +import com.google.inject.AbstractModule; public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), - ExternalIncludedIn.class).to(DeployedOnIncludedInExtension.class); + DynamicSet.bind(binder(), ExternalIncludedIn.class).to(DeployedOnIncludedInExtension.class); } }
diff --git a/example-restApiCommandOption/.bazelrc b/example-restApiCommandOption/.bazelrc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/example-restApiCommandOption/.bazelrc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/example-restApiCommandOption/.buckconfig b/example-restApiCommandOption/.buckconfig new file mode 100644 index 0000000..6a98b68 --- /dev/null +++ b/example-restApiCommandOption/.buckconfig
@@ -0,0 +1,15 @@ +[alias] + plugin = //:example-restApiCommandOption + +[java] + src_roots = java, resources + source_level = 8 + target_level = 8 + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/example-restApiCommandOption/BUILD b/example-restApiCommandOption/BUILD new file mode 100644 index 0000000..18c2ec7 --- /dev/null +++ b/example-restApiCommandOption/BUILD
@@ -0,0 +1,12 @@ +load("//tools/bzl:plugin.bzl", "gerrit_plugin") + +gerrit_plugin( + name = "example-restApiCommandOption", + srcs = glob(["src/main/java/**/*.java"]), + manifest_entries = [ + "Gerrit-PluginName: example-restApiCommandOption", + "Gerrit-HttpModule: com.googlesource.gerrit.plugins.examples.restapicommandoption.HttpModule", + "Implementation-Title: Example Simple REST Command Option", + ], + resources = glob(["src/main/resources/**/*"]), +)
diff --git a/example-restApiCommandOption/LICENSE b/example-restApiCommandOption/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/example-restApiCommandOption/LICENSE
@@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
diff --git a/example-restApiCommandOption/WORKSPACE b/example-restApiCommandOption/WORKSPACE new file mode 100644 index 0000000..de49eb5 --- /dev/null +++ b/example-restApiCommandOption/WORKSPACE
@@ -0,0 +1,26 @@ +workspace(name = "restApiCommandOption") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", + # local_path = "/home/<user>/projects/bazlets", +) + +# Release Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", + "gerrit_api", +) + +# Snapshot Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", +# "gerrit_api_maven_local", +#) + +# Load release Plugin API +gerrit_api() + +# Load snapshot Plugin API +#gerrit_api_maven_local()
diff --git a/example-restApiCommandOption/bazlets.bzl b/example-restApiCommandOption/bazlets.bzl new file mode 100644 index 0000000..6c4fffc --- /dev/null +++ b/example-restApiCommandOption/bazlets.bzl
@@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/example-restApiCommandOption/pom.xml b/example-restApiCommandOption/pom.xml new file mode 100644 index 0000000..276c47d --- /dev/null +++ b/example-restApiCommandOption/pom.xml
@@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2013 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.googlesource.gerrit.plugins</groupId> + <artifactId>example-restApiCommandOption</artifactId> + <packaging>jar</packaging> + <version>2.15-SNAPSHOT</version> + <properties> + <Gerrit-ApiType>plugin</Gerrit-ApiType> + <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <Gerrit-PluginName>example-restApiCommandOption</Gerrit-PluginName> + <Gerrit-HttpModule>com.googlesource.gerrit.plugins.examples.restapicommandoption.HttpModule</Gerrit-HttpModule> + + <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> + <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/examples</Implementation-URL> + + <Implementation-Title>Example Simple REST Command Option</Implementation-Title> + <Implementation-Version>${project.version}</Implementation-Version> + + <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> + <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + </plugins> + + </build> + + <dependencies> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>maven.org</id> + <url>http://repo1.maven.org/maven2</url> + </repository> + </repositories> +</project>
diff --git a/example-restApiCommandOption/src/main/java/com/googlesource/gerrit/plugins/examples/restapicommandoption/HttpModule.java b/example-restApiCommandOption/src/main/java/com/googlesource/gerrit/plugins/examples/restapicommandoption/HttpModule.java new file mode 100644 index 0000000..afcc105 --- /dev/null +++ b/example-restApiCommandOption/src/main/java/com/googlesource/gerrit/plugins/examples/restapicommandoption/HttpModule.java
@@ -0,0 +1,44 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.restapicommandoption; + +import com.google.gerrit.extensions.annotations.Exports; +import com.google.gerrit.httpd.plugins.HttpPluginModule; +import com.google.gerrit.server.DynamicOptions; +import com.google.gerrit.server.query.change.QueryChanges; +import org.kohsuke.args4j.Option; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HttpModule extends HttpPluginModule { + private static final Logger log = LoggerFactory.getLogger(HttpModule.class); + + @Override + protected void configureServlets() { + bind(DynamicOptions.DynamicBean.class) + .annotatedWith(Exports.named(QueryChanges.class)) + .to(MyOptions.class); + } + + public static class MyOptions implements DynamicOptions.DynamicBean { + @Option( + name = "--log", + aliases = {"-l"}, + usage = "Say Hello in the Log") + private void parse(String arg) { + log.error("Say Hello in the Log " + arg); + } + } +}
diff --git a/example-restApiCommandOption/src/main/resources/Documentation/about.md b/example-restApiCommandOption/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..9387be0 --- /dev/null +++ b/example-restApiCommandOption/src/main/resources/Documentation/about.md
@@ -0,0 +1 @@ +Sample plugin to demonstrate the ability to register options to REST Commands in Gerrit via plugin.
diff --git a/example-restApiCommandOption/src/main/resources/Documentation/rest-api-GET.md b/example-restApiCommandOption/src/main/resources/Documentation/rest-api-GET.md new file mode 100644 index 0000000..d6f6746 --- /dev/null +++ b/example-restApiCommandOption/src/main/resources/Documentation/rest-api-GET.md
@@ -0,0 +1,39 @@ +@PLUGIN@ +========== + +NAME +---- +@PLUGIN@ - Say Hello in the Log + +SYNOPSIS +-------- + GET /changes/?--@PLUGIN@--log + +DESCRIPTION +----------- +Prints "Say Hello in the Log" in the Log. + + +ACCESS +------ +Any authenticated user. + +EXAMPLES +-------- + +Have the server say Hello to the user + +> curl -X GET --digest --user joe:secret http://host:port/a/changes/?--@PLUGIN@--log + +LOG: +> [HTTP-69] ERROR com.googlesource.gerrit.plugins.examples.restapicommandoption.HttpModule : Say Hello in the Log + +SEE ALSO +-------- + +* [Plugin Development](../../../Documentation/dev-plugins.html) +* [REST API Development](../../../Documentation/dev-rest-api.html) + +GERRIT +------ +Part of [Gerrit Code Review](../../../Documentation/index.html)
diff --git a/example-restApiCommandOption/tools/bzl/BUILD b/example-restApiCommandOption/tools/bzl/BUILD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example-restApiCommandOption/tools/bzl/BUILD
diff --git a/example-restApiCommandOption/tools/bzl/plugin.bzl b/example-restApiCommandOption/tools/bzl/plugin.bzl new file mode 100644 index 0000000..89a1643 --- /dev/null +++ b/example-restApiCommandOption/tools/bzl/plugin.bzl
@@ -0,0 +1,8 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + _gerrit_plugin = "gerrit_plugin", + _plugin_deps = "PLUGIN_DEPS", +) + +gerrit_plugin = _gerrit_plugin +PLUGIN_DEPS = _plugin_deps
diff --git a/example-restApiCommandOption/tools/workspace-status.sh b/example-restApiCommandOption/tools/workspace-status.sh new file mode 100755 index 0000000..60218ed --- /dev/null +++ b/example-restApiCommandOption/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + git describe --always --match "v[0-9].*" --dirty +} + +echo STABLE_BUILD_EXAMPLE-RESTAPICOMMANDOPTION_LABEL $(rev)
diff --git a/example-restApiGetRevision/WORKSPACE b/example-restApiGetRevision/WORKSPACE index ca5d299..30e793b 100644 --- a/example-restApiGetRevision/WORKSPACE +++ b/example-restApiGetRevision/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-restApiGetRevision/pom.xml b/example-restApiGetRevision/pom.xml index 0557870..cfc4047 100644 --- a/example-restApiGetRevision/pom.xml +++ b/example-restApiGetRevision/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-restApiGetRevision</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Greetings.java b/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Greetings.java index 0ba04c1..31314b4 100644 --- a/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Greetings.java +++ b/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Greetings.java
@@ -17,7 +17,6 @@ import com.google.gerrit.extensions.restapi.Response; import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.server.change.RevisionResource; - import java.util.ArrayList; import java.util.Collection; @@ -26,12 +25,9 @@ @Override public Response<Collection<GreetInfo>> apply(RevisionResource rev) { Collection<GreetInfo> l = new ArrayList<>(3); - l.add(new GreetInfo("Bonjour", "France", - "http://en.wikipedia.org/wiki/France")); - l.add(new GreetInfo("Hallo", "Germany", - "http://en.wikipedia.org/wiki/Germany")); - l.add(new GreetInfo("Hello", "USA", - "http://en.wikipedia.org/wiki/USA")); + l.add(new GreetInfo("Bonjour", "France", "http://en.wikipedia.org/wiki/France")); + l.add(new GreetInfo("Hallo", "Germany", "http://en.wikipedia.org/wiki/Germany")); + l.add(new GreetInfo("Hello", "USA", "http://en.wikipedia.org/wiki/USA")); return Response.ok(l); }
diff --git a/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Module.java b/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Module.java index bf23094..b325c96 100644 --- a/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Module.java +++ b/example-restApiGetRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapigetrevision/Module.java
@@ -22,11 +22,12 @@ public class Module extends AbstractModule { @Override protected void configure() { - install(new RestApiModule() { - @Override - protected void configure() { - get(REVISION_KIND, "greetings").to(Greetings.class); - } - }); + install( + new RestApiModule() { + @Override + protected void configure() { + get(REVISION_KIND, "greetings").to(Greetings.class); + } + }); } }
diff --git a/example-restApiPostProject/WORKSPACE b/example-restApiPostProject/WORKSPACE index 3d3d575..afae0d9 100644 --- a/example-restApiPostProject/WORKSPACE +++ b/example-restApiPostProject/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-restApiPostProject/pom.xml b/example-restApiPostProject/pom.xml index 13005ba..57f5a9c 100644 --- a/example-restApiPostProject/pom.xml +++ b/example-restApiPostProject/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-restApiPostProject</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-restApiPostProject/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostproject/Module.java b/example-restApiPostProject/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostproject/Module.java index d39b4c6..e2dd834 100644 --- a/example-restApiPostProject/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostproject/Module.java +++ b/example-restApiPostProject/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostproject/Module.java
@@ -22,11 +22,12 @@ public class Module extends AbstractModule { @Override protected void configure() { - install(new RestApiModule() { - @Override - protected void configure() { - post(PROJECT_KIND, "hello-project").to(HelloProjectAction.class); - } - }); + install( + new RestApiModule() { + @Override + protected void configure() { + post(PROJECT_KIND, "hello-project").to(HelloProjectAction.class); + } + }); } }
diff --git a/example-restApiPostProject/tools/workspace-status.sh b/example-restApiPostProject/tools/workspace-status.sh index 010cdfa..7cd3b5a 100755 --- a/example-restApiPostProject/tools/workspace-status.sh +++ b/example-restApiPostProject/tools/workspace-status.sh
@@ -14,4 +14,4 @@ git describe --always --match "v[0-9].*" --dirty } -echo STABLE_BUILD_EXAMPLE-RESTAPIPOSTPROJECTIAS_LABEL $(rev) +echo STABLE_BUILD_EXAMPLE-RESTAPIPOSTPROJECT_LABEL $(rev)
diff --git a/example-restApiPostRevision/WORKSPACE b/example-restApiPostRevision/WORKSPACE index 15d0789..089645c 100644 --- a/example-restApiPostRevision/WORKSPACE +++ b/example-restApiPostRevision/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-restApiPostRevision/pom.xml b/example-restApiPostRevision/pom.xml index e3f5242..f46a8bb 100644 --- a/example-restApiPostRevision/pom.xml +++ b/example-restApiPostRevision/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-restApiPostRevision</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/HelloRevisionAction.java b/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/HelloRevisionAction.java index 474750e..eecaf03 100644 --- a/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/HelloRevisionAction.java +++ b/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/HelloRevisionAction.java
@@ -24,8 +24,9 @@ import com.google.inject.Inject; import com.google.inject.Provider; -class HelloRevisionAction implements UiAction<RevisionResource>, - RestModifyView<RevisionResource, HelloRevisionAction.Input> { +class HelloRevisionAction + implements UiAction<RevisionResource>, + RestModifyView<RevisionResource, HelloRevisionAction.Input> { private Provider<CurrentUser> user; @@ -41,10 +42,9 @@ @Override public String apply(RevisionResource rev, Input input) { - final String greeting = input.french - ? "Bonjour" - : "Hello"; - return String.format("%s %s from change %s, patch set %d!", + final String greeting = input.french ? "Bonjour" : "Hello"; + return String.format( + "%s %s from change %s, patch set %d!", greeting, Strings.isNullOrEmpty(input.message) ? MoreObjects.firstNonNull(user.get().getUserName(), "world") @@ -54,8 +54,7 @@ } @Override - public Description getDescription( - RevisionResource resource) { + public Description getDescription(RevisionResource resource) { return new Description() .setLabel("Say hello") .setTitle("Say hello in different languages")
diff --git a/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/Module.java b/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/Module.java index 252e68b..80a7ce6 100644 --- a/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/Module.java +++ b/example-restApiPostRevision/src/main/java/com/googlesource/gerrit/plugins/examples/restapipostrevision/Module.java
@@ -22,11 +22,12 @@ public class Module extends AbstractModule { @Override protected void configure() { - install(new RestApiModule() { - @Override - protected void configure() { - post(REVISION_KIND, "hello-revision").to(HelloRevisionAction.class); - } - }); + install( + new RestApiModule() { + @Override + protected void configure() { + post(REVISION_KIND, "hello-revision").to(HelloRevisionAction.class); + } + }); } }
diff --git a/example-servlet/WORKSPACE b/example-servlet/WORKSPACE index 48ed1f7..1c5061e 100644 --- a/example-servlet/WORKSPACE +++ b/example-servlet/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-servlet/pom.xml b/example-servlet/pom.xml index 428341c..282cc59 100644 --- a/example-servlet/pom.xml +++ b/example-servlet/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-servlet</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-servlet/src/main/java/com/googlesource/gerrit/plugins/examples/servlet/HelloWorldServlet.java b/example-servlet/src/main/java/com/googlesource/gerrit/plugins/examples/servlet/HelloWorldServlet.java index af718bf..9a8fa9d 100644 --- a/example-servlet/src/main/java/com/googlesource/gerrit/plugins/examples/servlet/HelloWorldServlet.java +++ b/example-servlet/src/main/java/com/googlesource/gerrit/plugins/examples/servlet/HelloWorldServlet.java
@@ -18,17 +18,14 @@ import com.google.gerrit.extensions.annotations.PluginName; import com.google.inject.Inject; import com.google.inject.Singleton; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.io.Writer; - import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Singleton class HelloWorldServlet extends HttpServlet { @@ -36,14 +33,13 @@ private static final Logger log = LoggerFactory.getLogger(HelloWorldServlet.class); @Inject - HelloWorldServlet(@PluginName String pluginName, - @PluginCanonicalWebUrl String url) { + HelloWorldServlet(@PluginName String pluginName, @PluginCanonicalWebUrl String url) { log.info(String.format("Cookbook Plugin '%s' at url %s", pluginName, url)); } @Override - protected void doGet(final HttpServletRequest req, - final HttpServletResponse rsp) throws IOException, ServletException { + protected void doGet(final HttpServletRequest req, final HttpServletResponse rsp) + throws IOException, ServletException { rsp.setContentType("text/html"); rsp.setCharacterEncoding("UTF-8"); try (Writer out = rsp.getWriter()) {
diff --git a/example-simpleSshCommand/WORKSPACE b/example-simpleSshCommand/WORKSPACE index f1ef565..db61ebc 100644 --- a/example-simpleSshCommand/WORKSPACE +++ b/example-simpleSshCommand/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-simpleSshCommand/pom.xml b/example-simpleSshCommand/pom.xml index f858a06..4ed1a30 100644 --- a/example-simpleSshCommand/pom.xml +++ b/example-simpleSshCommand/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-simpleSshCommand</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-simpleSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/simplesshcommand/PrintHelloWorldCommand.java b/example-simpleSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/simplesshcommand/PrintHelloWorldCommand.java index 3d6f704..d7279ae 100644 --- a/example-simpleSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/simplesshcommand/PrintHelloWorldCommand.java +++ b/example-simpleSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/simplesshcommand/PrintHelloWorldCommand.java
@@ -16,7 +16,6 @@ import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; - import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option;
diff --git a/example-sshAndRestCommandOptionBeanParseListener/.bazelrc b/example-sshAndRestCommandOptionBeanParseListener/.bazelrc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/.bazelrc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/example-sshAndRestCommandOptionBeanParseListener/.buckconfig b/example-sshAndRestCommandOptionBeanParseListener/.buckconfig new file mode 100644 index 0000000..27bcd93 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/.buckconfig
@@ -0,0 +1,15 @@ +[alias] + plugin = //:example-sshCommandOptionBeanParseListner + +[java] + src_roots = java, resources + source_level = 8 + target_level = 8 + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/example-sshAndRestCommandOptionBeanParseListener/.gitignore b/example-sshAndRestCommandOptionBeanParseListener/.gitignore new file mode 100644 index 0000000..ef47a02 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/.gitignore
@@ -0,0 +1,9 @@ +/target +/.classpath +/.settings +/.project +/.buckd +/buck-cache +/buck-out +*.iml +/bazel-example-sshCommandOptionBeanParseListener
diff --git a/example-sshAndRestCommandOptionBeanParseListener/BUILD b/example-sshAndRestCommandOptionBeanParseListener/BUILD new file mode 100644 index 0000000..39beb91 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/BUILD
@@ -0,0 +1,13 @@ +load("//tools/bzl:plugin.bzl", "gerrit_plugin") + +gerrit_plugin( + name = "example-sshAndRestCommandOptionBeanParseListener", + srcs = glob(["src/main/java/**/*.java"]), + manifest_entries = [ + "Gerrit-PluginName: example-sshAndRestCommandOptionBeanParseListener", + "Gerrit-SshModule: com.googlesource.gerrit.plugins.examples.sshandrestcommandoptionbeanparselistener.Modules$SshModule", + "Gerrit-HttpModule: com.googlesource.gerrit.plugins.examples.sshandrestcommandoptionbeanparselistener.Modules$HttpModule", + "Implementation-Title: Example Simple SSH and REST Command Option Bean Parse Listener", + ], + resources = glob(["src/main/resources/**/*"]), +)
diff --git a/example-sshAndRestCommandOptionBeanParseListener/LICENSE b/example-sshAndRestCommandOptionBeanParseListener/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/LICENSE
@@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
diff --git a/example-sshAndRestCommandOptionBeanParseListener/WORKSPACE b/example-sshAndRestCommandOptionBeanParseListener/WORKSPACE new file mode 100644 index 0000000..88c548a --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/WORKSPACE
@@ -0,0 +1,26 @@ +workspace(name = "sshCommandOptionBeanParseListener") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", + # local_path = "/home/<user>/projects/bazlets", +) + +# Release Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", + "gerrit_api", +) + +# Snapshot Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", +# "gerrit_api_maven_local", +#) + +# Load release Plugin API +gerrit_api() + +# Load snapshot Plugin API +#gerrit_api_maven_local()
diff --git a/example-sshAndRestCommandOptionBeanParseListener/bazlets.bzl b/example-sshAndRestCommandOptionBeanParseListener/bazlets.bzl new file mode 100644 index 0000000..6c4fffc --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/bazlets.bzl
@@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/example-sshAndRestCommandOptionBeanParseListener/pom.xml b/example-sshAndRestCommandOptionBeanParseListener/pom.xml new file mode 100644 index 0000000..f0b45c9 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/pom.xml
@@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2013 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.googlesource.gerrit.plugins</groupId> + <artifactId>example-sshAndRestCommandOptionBeanParseListener</artifactId> + <packaging>jar</packaging> + <version>2.15-SNAPSHOT</version> + <properties> + <Gerrit-ApiType>plugin</Gerrit-ApiType> + <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <Gerrit-PluginName>example-sshAndRestCommandOptionBeanParseListener</Gerrit-PluginName> + <Gerrit-SshModule>com.googlesource.gerrit.plugins.examples.sshandrestcommandoptionbeanparselistener.Modules$SshModule</Gerrit-SshModule> + <Gerrit-HttpModule>com.googlesource.gerrit.plugins.examples.sshandrestcommandoptionbeanparselistener.Modules$HttpModule</Gerrit-HttpModule> + + <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> + <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/examples</Implementation-URL> + + <Implementation-Title>Example Simple SSH and REST Command Option Bean Parse Listener</Implementation-Title> + <Implementation-Version>${project.version}</Implementation-Version> + + <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> + <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + </plugins> + + </build> + + <dependencies> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>maven.org</id> + <url>http://repo1.maven.org/maven2</url> + </repository> + </repositories> +</project>
diff --git a/example-sshAndRestCommandOptionBeanParseListener/src/main/java/com/googlesource/gerrit/plugins/examples/sshandrestcommandoptionbeanparselistener/Modules.java b/example-sshAndRestCommandOptionBeanParseListener/src/main/java/com/googlesource/gerrit/plugins/examples/sshandrestcommandoptionbeanparselistener/Modules.java new file mode 100644 index 0000000..b91c5cb --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/src/main/java/com/googlesource/gerrit/plugins/examples/sshandrestcommandoptionbeanparselistener/Modules.java
@@ -0,0 +1,78 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.sshandrestcommandoptionbeanparselistener; + +import com.google.gerrit.extensions.annotations.Exports; +import com.google.gerrit.httpd.plugins.HttpPluginModule; +import com.google.gerrit.server.DynamicOptions; +import com.google.gerrit.server.query.change.QueryChanges; +import com.google.gerrit.sshd.commands.Query; +import com.google.inject.AbstractModule; +import org.kohsuke.args4j.Option; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Modules { + + public static class HttpModule extends HttpPluginModule { + @Override + protected void configureServlets() { + bind(DynamicOptions.DynamicBean.class) + .annotatedWith(Exports.named(QueryChanges.class)) + .to(QueryOptions.class); + } + } + + public static class SshModule extends AbstractModule { + @Override + protected void configure() { + bind(DynamicOptions.DynamicBean.class) + .annotatedWith(Exports.named(Query.class)) + .to(QueryOptions.class); + } + } + + public static class QueryOptions + implements DynamicOptions.DynamicBean, DynamicOptions.BeanParseListener { + private static final Logger log = LoggerFactory.getLogger(QueryOptions.class); + + private Object bean; + + @Option( + name = "--log", + aliases = {"-l"}, + usage = "Say Hello in the Log a few times") + private void parse(String arg) { + String msg = "Hellow unknown api query user: " + arg; + if (bean instanceof Query) { + msg = "Hello ssh api query user: " + arg; + } else if (bean instanceof QueryChanges) { + msg = "Hello rest api query user: " + arg; + } + log.error(msg); + } + + @Override + public void onBeanParseStart(String plugin, Object bean) { + this.bean = bean; + log.error("hello - parse start"); + } + + @Override + public void onBeanParseEnd(String plugin, Object bean) { + log.error("hello - parse end"); + } + } +}
diff --git a/example-sshAndRestCommandOptionBeanParseListener/src/main/resources/Documentation/about.md b/example-sshAndRestCommandOptionBeanParseListener/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..ee7e683 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/src/main/resources/Documentation/about.md
@@ -0,0 +1,3 @@ +Sample plugin to demonstrate the ability to register options to REST and SSH Commands in +Gerrit via plugin and to hook in to the bean parse listener to be called before and after +option parsing.
diff --git a/example-sshAndRestCommandOptionBeanParseListener/tools/bzl/BUILD b/example-sshAndRestCommandOptionBeanParseListener/tools/bzl/BUILD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/tools/bzl/BUILD
diff --git a/example-sshAndRestCommandOptionBeanParseListener/tools/bzl/plugin.bzl b/example-sshAndRestCommandOptionBeanParseListener/tools/bzl/plugin.bzl new file mode 100644 index 0000000..89a1643 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/tools/bzl/plugin.bzl
@@ -0,0 +1,8 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + _gerrit_plugin = "gerrit_plugin", + _plugin_deps = "PLUGIN_DEPS", +) + +gerrit_plugin = _gerrit_plugin +PLUGIN_DEPS = _plugin_deps
diff --git a/example-sshAndRestCommandOptionBeanParseListener/tools/workspace-status.sh b/example-sshAndRestCommandOptionBeanParseListener/tools/workspace-status.sh new file mode 100755 index 0000000..6147a57 --- /dev/null +++ b/example-sshAndRestCommandOptionBeanParseListener/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + git describe --always --match "v[0-9].*" --dirty +} + +echo STABLE_BUILD_EXAMPLE-SSHANDRESTCOMMANDOPTIONBEANPARSELISTENER_LABEL $(rev)
diff --git a/example-sshCommandAlias/WORKSPACE b/example-sshCommandAlias/WORKSPACE index f1ef565..db61ebc 100644 --- a/example-sshCommandAlias/WORKSPACE +++ b/example-sshCommandAlias/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-sshCommandAlias/pom.xml b/example-sshCommandAlias/pom.xml index 0b5ce04..67ed518 100644 --- a/example-sshCommandAlias/pom.xml +++ b/example-sshCommandAlias/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-sshCommandAlias</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-sshCommandAlias/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandalias/PrintHelloWorldCommand.java b/example-sshCommandAlias/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandalias/PrintHelloWorldCommand.java index dd41852..968a7e6 100644 --- a/example-sshCommandAlias/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandalias/PrintHelloWorldCommand.java +++ b/example-sshCommandAlias/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandalias/PrintHelloWorldCommand.java
@@ -16,7 +16,6 @@ import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; - import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option;
diff --git a/example-sshCommandDelegateDynamicBean/.bazelrc b/example-sshCommandDelegateDynamicBean/.bazelrc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/.bazelrc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/example-sshCommandDelegateDynamicBean/.buckconfig b/example-sshCommandDelegateDynamicBean/.buckconfig new file mode 100644 index 0000000..3c82f1c --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/.buckconfig
@@ -0,0 +1,15 @@ +[alias] + plugin = //:example-sshCommandDelegateDynamicBean + +[java] + src_roots = java, resources + source_level = 8 + target_level = 8 + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/example-sshCommandDelegateDynamicBean/.gitignore b/example-sshCommandDelegateDynamicBean/.gitignore new file mode 100644 index 0000000..ef5f901 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/.gitignore
@@ -0,0 +1,9 @@ +/target +/.classpath +/.settings +/.project +/.buckd +/buck-cache +/buck-out +*.iml +/bazel-example-sshCommandDelegateDynamicBean
diff --git a/example-sshCommandDelegateDynamicBean/BUILD b/example-sshCommandDelegateDynamicBean/BUILD new file mode 100644 index 0000000..9beda34 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/BUILD
@@ -0,0 +1,12 @@ +load("//tools/bzl:plugin.bzl", "gerrit_plugin") + +gerrit_plugin( + name = "example-sshCommandDelegateDynamicBean", + srcs = glob(["src/main/java/**/*.java"]), + manifest_entries = [ + "Gerrit-PluginName: example-sshCommandDelegateDynamicBean", + "Gerrit-SshModule: com.googlesource.gerrit.plugins.examples.sshcommanddelegatedynamicbean.SshModule", + "Implementation-Title: Example SSH Command Delegate Dynamic Bean", + ], + resources = glob(["src/main/resources/**/*"]), +)
diff --git a/example-sshCommandDelegateDynamicBean/LICENSE b/example-sshCommandDelegateDynamicBean/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/LICENSE
@@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
diff --git a/example-sshCommandDelegateDynamicBean/WORKSPACE b/example-sshCommandDelegateDynamicBean/WORKSPACE new file mode 100644 index 0000000..33f61ba --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/WORKSPACE
@@ -0,0 +1,26 @@ +workspace(name = "sshCommandDelegateDynamicBean") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", + # local_path = "/home/<user>/projects/bazlets", +) + +# Release Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", + "gerrit_api", +) + +# Snapshot Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", +# "gerrit_api_maven_local", +#) + +# Load release Plugin API +gerrit_api() + +# Load snapshot Plugin API +#gerrit_api_maven_local()
diff --git a/example-sshCommandDelegateDynamicBean/bazlets.bzl b/example-sshCommandDelegateDynamicBean/bazlets.bzl new file mode 100644 index 0000000..6c4fffc --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/bazlets.bzl
@@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/example-sshCommandDelegateDynamicBean/pom.xml b/example-sshCommandDelegateDynamicBean/pom.xml new file mode 100644 index 0000000..956c157 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/pom.xml
@@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2013 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.googlesource.gerrit.plugins</groupId> + <artifactId>example-sshCommandDelegateDynamicBean</artifactId> + <packaging>jar</packaging> + <version>2.15-SNAPSHOT</version> + <properties> + <Gerrit-ApiType>plugin</Gerrit-ApiType> + <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <Gerrit-PluginName>example-sshCommandDelegateDynamicBean</Gerrit-PluginName> + <Gerrit-SshModule>com.googlesource.gerrit.plugins.examples.sshcommanddelegatedynamicbean.SshModule</Gerrit-SshModule> + + <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> + <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/examples</Implementation-URL> + + <Implementation-Title>Example SSH Command Delegate Dynamic Bean</Implementation-Title> + <Implementation-Version>${project.version}</Implementation-Version> + + <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> + <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + </plugins> + + </build> + + <dependencies> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>maven.org</id> + <url>http://repo1.maven.org/maven2</url> + </repository> + </repositories> +</project>
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java new file mode 120000 index 0000000..89edecb --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java
@@ -0,0 +1 @@ +../../../../../../../../../../example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCapability.java \ No newline at end of file
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java new file mode 120000 index 0000000..0b87e21 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java
@@ -0,0 +1 @@ +../../../../../../../../../../example-adminSshCommand/src/main/java/com/googlesource/gerrit/plugins/examples/adminsshcommand/AdminExampleCommand.java \ No newline at end of file
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/AdminExampleCapability.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/AdminExampleCapability.java new file mode 100644 index 0000000..b4f5b93 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/AdminExampleCapability.java
@@ -0,0 +1,26 @@ +// Copyright (C) 2014 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.sshcommanddelegatedynamicbean; + +import com.google.gerrit.extensions.config.CapabilityDefinition; + +class AdminExampleCapability extends CapabilityDefinition { + static final String ADMIN_EXAMPLE = "adminExample"; + + @Override + public String getDescription() { + return "Administrate Example"; + } +}
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/AdminExampleOptions.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/AdminExampleOptions.java new file mode 100644 index 0000000..b35891f --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/AdminExampleOptions.java
@@ -0,0 +1,49 @@ +// Copyright (C) 2013 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.sshcommanddelegatedynamicbean; + +import com.google.gerrit.server.DynamicOptions; +import com.googlesource.gerrit.plugins.examples.adminsshcommand.AdminExampleCommand; +import org.kohsuke.args4j.Option; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdminExampleOptions + implements DynamicOptions.DynamicBean, DynamicOptions.BeanParseListener { + private final Logger log = LoggerFactory.getLogger(AdminExampleOptions.class); + + private int count = 0; + private boolean countSet = false; + + @Option( + name = "--repeat", + aliases = {"-r"}, + usage = "Run the command multiple times") + private void parse(String arg) { + count = Integer.parseInt(arg); + countSet = true; + } + + @Override + public void onBeanParseStart(String plugin, Object bean) {} + + @Override + public void onBeanParseEnd(String plugin, Object bean) { + AdminExampleCommand cmd = (AdminExampleCommand) bean; + if (countSet) { + cmd.setCount(count); + } + } +}
diff --git a/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/SshModule.java b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/SshModule.java new file mode 100644 index 0000000..fcb3699 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommanddelegatedynamicbean/SshModule.java
@@ -0,0 +1,29 @@ +// Copyright (C) 2013 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.sshcommanddelegatedynamicbean; + +import com.google.gerrit.extensions.annotations.Exports; +import com.google.gerrit.server.DynamicOptions; +import com.google.inject.AbstractModule; +import com.googlesource.gerrit.plugins.examples.adminsshcommand.AdminExampleCommand; + +public class SshModule extends AbstractModule { + @Override + protected void configure() { + bind(DynamicOptions.DynamicBean.class) + .annotatedWith(Exports.named(AdminExampleCommand.class)) + .to(AdminExampleOptions.class); + } +}
diff --git a/example-sshCommandDelegateDynamicBean/src/main/resources/Documentation/about.md b/example-sshCommandDelegateDynamicBean/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..432e58c --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/src/main/resources/Documentation/about.md
@@ -0,0 +1 @@ +Sample plugin that shows how to extend a command from another plugin by adding a repeat option to the admin command from the example-adminSshCommand plugin.
diff --git a/example-sshCommandDelegateDynamicBean/tools/bzl/BUILD b/example-sshCommandDelegateDynamicBean/tools/bzl/BUILD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/tools/bzl/BUILD
diff --git a/example-sshCommandDelegateDynamicBean/tools/bzl/plugin.bzl b/example-sshCommandDelegateDynamicBean/tools/bzl/plugin.bzl new file mode 100644 index 0000000..89a1643 --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/tools/bzl/plugin.bzl
@@ -0,0 +1,8 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + _gerrit_plugin = "gerrit_plugin", + _plugin_deps = "PLUGIN_DEPS", +) + +gerrit_plugin = _gerrit_plugin +PLUGIN_DEPS = _plugin_deps
diff --git a/example-sshCommandDelegateDynamicBean/tools/workspace-status.sh b/example-sshCommandDelegateDynamicBean/tools/workspace-status.sh new file mode 100755 index 0000000..f31812c --- /dev/null +++ b/example-sshCommandDelegateDynamicBean/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + git describe --always --match "v[0-9].*" --dirty +} + +echo STABLE_BUILD_EXAMPLE-SSHCOMMANDDELEGATEDYNAMICBEAN_LABEL $(rev)
diff --git a/example-sshCommandOption/.bazelrc b/example-sshCommandOption/.bazelrc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/example-sshCommandOption/.bazelrc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/example-sshCommandOption/.buckconfig b/example-sshCommandOption/.buckconfig new file mode 100644 index 0000000..13bf94a --- /dev/null +++ b/example-sshCommandOption/.buckconfig
@@ -0,0 +1,15 @@ +[alias] + plugin = //:example-sshCommandOption + +[java] + src_roots = java, resources + source_level = 8 + target_level = 8 + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/example-sshCommandOption/.gitignore b/example-sshCommandOption/.gitignore new file mode 100644 index 0000000..db1c934 --- /dev/null +++ b/example-sshCommandOption/.gitignore
@@ -0,0 +1,8 @@ +/target +/.classpath +/.settings +/.project +/.buckd +/buck-cache +/buck-out +*.iml
diff --git a/example-sshCommandOption/BUILD b/example-sshCommandOption/BUILD new file mode 100644 index 0000000..10cc093 --- /dev/null +++ b/example-sshCommandOption/BUILD
@@ -0,0 +1,12 @@ +load("//tools/bzl:plugin.bzl", "gerrit_plugin") + +gerrit_plugin( + name = "example-sshCommandOption", + srcs = glob(["src/main/java/**/*.java"]), + manifest_entries = [ + "Gerrit-PluginName: example-sshCommandOption", + "Gerrit-SshModule: com.googlesource.gerrit.plugins.examples.sshcommandoption.SshModule", + "Implementation-Title: Example Simple SSH Command Option", + ], + resources = glob(["src/main/resources/**/*"]), +)
diff --git a/example-sshCommandOption/LICENSE b/example-sshCommandOption/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/example-sshCommandOption/LICENSE
@@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
diff --git a/example-sshCommandOption/WORKSPACE b/example-sshCommandOption/WORKSPACE new file mode 100644 index 0000000..af4fc17 --- /dev/null +++ b/example-sshCommandOption/WORKSPACE
@@ -0,0 +1,26 @@ +workspace(name = "sshCommandOption") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", + # local_path = "/home/<user>/projects/bazlets", +) + +# Release Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", + "gerrit_api", +) + +# Snapshot Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", +# "gerrit_api_maven_local", +#) + +# Load release Plugin API +gerrit_api() + +# Load snapshot Plugin API +#gerrit_api_maven_local()
diff --git a/example-sshCommandOption/bazlets.bzl b/example-sshCommandOption/bazlets.bzl new file mode 100644 index 0000000..6c4fffc --- /dev/null +++ b/example-sshCommandOption/bazlets.bzl
@@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/example-sshCommandOption/pom.xml b/example-sshCommandOption/pom.xml new file mode 100644 index 0000000..8f59842 --- /dev/null +++ b/example-sshCommandOption/pom.xml
@@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2013 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.googlesource.gerrit.plugins</groupId> + <artifactId>example-sshCommandOption</artifactId> + <packaging>jar</packaging> + <version>2.15-SNAPSHOT</version> + <properties> + <Gerrit-ApiType>plugin</Gerrit-ApiType> + <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <Gerrit-PluginName>example-sshCommandOption</Gerrit-PluginName> + <Gerrit-SshModule>com.googlesource.gerrit.plugins.examples.sshcommandoption.SshModule</Gerrit-SshModule> + + <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> + <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/examples</Implementation-URL> + + <Implementation-Title>Example Simple SSH Command Option</Implementation-Title> + <Implementation-Version>${project.version}</Implementation-Version> + + <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> + <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + </plugins> + + </build> + + <dependencies> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>maven.org</id> + <url>http://repo1.maven.org/maven2</url> + </repository> + </repositories> +</project>
diff --git a/example-sshCommandOption/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandoption/SshModule.java b/example-sshCommandOption/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandoption/SshModule.java new file mode 100644 index 0000000..aa49779 --- /dev/null +++ b/example-sshCommandOption/src/main/java/com/googlesource/gerrit/plugins/examples/sshcommandoption/SshModule.java
@@ -0,0 +1,44 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.sshcommandoption; + +import com.google.gerrit.extensions.annotations.Exports; +import com.google.gerrit.server.DynamicOptions; +import com.google.gerrit.sshd.commands.BanCommitCommand; +import com.google.inject.AbstractModule; +import org.kohsuke.args4j.Option; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SshModule extends AbstractModule { + private static final Logger log = LoggerFactory.getLogger(SshModule.class); + + @Override + protected void configure() { + bind(DynamicOptions.DynamicBean.class) + .annotatedWith(Exports.named(BanCommitCommand.class)) + .to(BanOptions.class); + } + + public static class BanOptions implements DynamicOptions.DynamicBean { + @Option( + name = "--log", + aliases = {"-l"}, + usage = "Say Hello in the Log") + private void parse(String arg) { + log.error("Say Hello in the Log " + arg); + } + } +}
diff --git a/example-sshCommandOption/src/main/resources/Documentation/about.md b/example-sshCommandOption/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..ff889d4 --- /dev/null +++ b/example-sshCommandOption/src/main/resources/Documentation/about.md
@@ -0,0 +1 @@ +Sample plugin to demonstrate the ability to register options to SSH Commands in Gerrit via plugin.
diff --git a/example-sshCommandOption/src/main/resources/Documentation/cmd-gerrit-ban-commit.md b/example-sshCommandOption/src/main/resources/Documentation/cmd-gerrit-ban-commit.md new file mode 100644 index 0000000..325e1cb --- /dev/null +++ b/example-sshCommandOption/src/main/resources/Documentation/cmd-gerrit-ban-commit.md
@@ -0,0 +1,51 @@ +@PLUGIN@ +========= + +NAME +---- +@PLUGIN@ - Logs a message when running the Gerrit SSH Command Ban-Commit + +SYNOPSIS +-------- +> ssh -p <port> <host> gerrit ban-commit <PROJECT> <COMMIT> --@PLUGIN@--log <VAL> + + +DESCRIPTION +----------- +Output in Server Log (ERROR): "Say Hello in the Log test". + +OPTIONS +------- + +\-\-@PLUGIN@\-\-log +> Say Hello in the Log. + +ACCESS +------ +Any user who has configured an SSH key. + +SCRIPTING +--------- +This command is intended for test purposes. + +EXAMPLES +-------- + +Have the server say hi to the world. + +> $ ssh -p 29418 review.example.com gerrit ban-commit +> tools/test/project0 +> 8b0b75b90ea7b363410a5c5100aace55adfa3b7e +> --example-sshCommandOption--log test + +LOG: +> ERROR com.googlesource.gerrit.plugins.examples.sshcommandoption.SshModule : Say Hello in the Log test + +SEE ALSO +-------- + +* [Plugin Development](../../../Documentation/dev-plugins.html) + +GERRIT +------ +Part of [Gerrit Code Review](../../../Documentation/index.html)
diff --git a/example-sshCommandOption/tools/bzl/BUILD b/example-sshCommandOption/tools/bzl/BUILD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example-sshCommandOption/tools/bzl/BUILD
diff --git a/example-sshCommandOption/tools/bzl/plugin.bzl b/example-sshCommandOption/tools/bzl/plugin.bzl new file mode 100644 index 0000000..89a1643 --- /dev/null +++ b/example-sshCommandOption/tools/bzl/plugin.bzl
@@ -0,0 +1,8 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + _gerrit_plugin = "gerrit_plugin", + _plugin_deps = "PLUGIN_DEPS", +) + +gerrit_plugin = _gerrit_plugin +PLUGIN_DEPS = _plugin_deps
diff --git a/example-sshCommandOption/tools/workspace-status.sh b/example-sshCommandOption/tools/workspace-status.sh new file mode 100755 index 0000000..8180891 --- /dev/null +++ b/example-sshCommandOption/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + git describe --always --match "v[0-9].*" --dirty +} + +echo STABLE_BUILD_EXAMPLE-SSHCOMMANDOPTION_LABEL $(rev)
diff --git a/example-topMenu/WORKSPACE b/example-topMenu/WORKSPACE index f1ef565..db61ebc 100644 --- a/example-topMenu/WORKSPACE +++ b/example-topMenu/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-topMenu/pom.xml b/example-topMenu/pom.xml index 748fea6..be789bc 100644 --- a/example-topMenu/pom.xml +++ b/example-topMenu/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-topMenu</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/HelloTopMenu.java b/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/HelloTopMenu.java index c2cb559..bf29ee4 100644 --- a/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/HelloTopMenu.java +++ b/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/HelloTopMenu.java
@@ -19,7 +19,6 @@ import com.google.gerrit.extensions.client.MenuItem; import com.google.gerrit.extensions.webui.TopMenu; import com.google.inject.Inject; - import java.util.List; public class HelloTopMenu implements TopMenu { @@ -33,12 +32,15 @@ menuItems.add(new MenuItem("Documentation", baseUrl)); menuEntries = Lists.newArrayListWithCapacity(2); menuEntries.add(new MenuEntry("Cookbook", menuItems)); - menuEntries.add(new MenuEntry("Projects", Lists.newArrayList( - new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/")))); + menuEntries.add( + new MenuEntry( + "Projects", + Lists.newArrayList( + new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/")))); } @Override public List<MenuEntry> getEntries() { - return menuEntries; + return menuEntries; } -} \ No newline at end of file +}
diff --git a/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/Module.java b/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/Module.java index 5da922b..e0932aa 100644 --- a/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/Module.java +++ b/example-topMenu/src/main/java/com/googlesource/gerrit/plugins/examples/topmenu/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), TopMenu.class) - .to(HelloTopMenu.class); + DynamicSet.bind(binder(), TopMenu.class).to(HelloTopMenu.class); } }
diff --git a/example-usageDataLogger/WORKSPACE b/example-usageDataLogger/WORKSPACE index bdadc24..0bcc176 100644 --- a/example-usageDataLogger/WORKSPACE +++ b/example-usageDataLogger/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-usageDataLogger/pom.xml b/example-usageDataLogger/pom.xml index a8bc287..7011a0c 100644 --- a/example-usageDataLogger/pom.xml +++ b/example-usageDataLogger/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-usageDataLogger</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/Module.java b/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/Module.java index 25c0200..24c13f6 100644 --- a/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/Module.java +++ b/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), UsageDataPublishedListener.class) - .to(UsageDataLogger.class); + DynamicSet.bind(binder(), UsageDataPublishedListener.class).to(UsageDataLogger.class); } }
diff --git a/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/UsageDataLogger.java b/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/UsageDataLogger.java index 02f0305..abbefbe 100644 --- a/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/UsageDataLogger.java +++ b/example-usageDataLogger/src/main/java/com/googlesource/gerrit/plugins/examples/usagedatalogger/UsageDataLogger.java
@@ -15,7 +15,6 @@ package com.googlesource.gerrit.plugins.examples.usagedatalogger; import com.google.gerrit.extensions.events.UsageDataPublishedListener; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,13 +25,14 @@ @Override public void onUsageDataPublished(Event event) { if (log.isInfoEnabled()) { - log.info(String.format("Usage data for " - + "%s at %s", event.getMetaData().getDescription(), event.getInstant())); + log.info( + String.format( + "Usage data for " + "%s at %s", + event.getMetaData().getDescription(), event.getInstant())); log.info(String.format("project name - %s", event.getMetaData().getName())); String unitSymbol = event.getMetaData().getUnitSymbol(); for (Data data : event.getData()) { - log.info(String.format("%s - %d %s", data.getProjectName(), data.getValue(), - unitSymbol)); + log.info(String.format("%s - %d %s", data.getProjectName(), data.getValue(), unitSymbol)); } log.info(""); }
diff --git a/example-validationListenerAssignee/WORKSPACE b/example-validationListenerAssignee/WORKSPACE index f967a89..22727f5 100644 --- a/example-validationListenerAssignee/WORKSPACE +++ b/example-validationListenerAssignee/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerAssignee/pom.xml b/example-validationListenerAssignee/pom.xml index 433c656..f8c7bc1 100644 --- a/example-validationListenerAssignee/pom.xml +++ b/example-validationListenerAssignee/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerAssignee</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java b/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java index 63359ca..5de9af0 100644 --- a/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java +++ b/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/AssigneeValidator.java
@@ -14,42 +14,41 @@ package com.googlesource.gerrit.plugins.examples.validationlistenerassignee; +import com.google.gerrit.index.query.QueryParseException; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; -import com.google.gerrit.server.query.QueryParseException; import com.google.gerrit.server.query.change.ChangeQueryBuilder; import com.google.gerrit.server.query.change.ChangeQueryProcessor; import com.google.gerrit.server.validators.AssigneeValidationListener; import com.google.gerrit.server.validators.ValidationException; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; - +import java.io.IOException; +import org.eclipse.jgit.errors.ConfigInvalidException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AssigneeValidator implements AssigneeValidationListener { - private static final Logger log = - LoggerFactory.getLogger(AssigneeValidationListener.class); + private static final Logger log = LoggerFactory.getLogger(AssigneeValidationListener.class); private static int MAX_ASSIGNED_CHANGES = 5; - @Inject - ChangeQueryBuilder queryBuilder; + @Inject ChangeQueryBuilder queryBuilder; - @Inject - ChangeQueryProcessor queryProcessor; + @Inject ChangeQueryProcessor queryProcessor; @Override - public void validateAssignee(Change change, Account assignee) - throws ValidationException { + public void validateAssignee(Change change, Account assignee) throws ValidationException { try { if (queryProcessor - .query(queryBuilder.assignee(assignee.getPreferredEmail())).entities() - .size() > MAX_ASSIGNED_CHANGES) { - throw new ValidationException("Cannot assign user to more than " - + MAX_ASSIGNED_CHANGES + " changes"); + .query(queryBuilder.assignee(assignee.getPreferredEmail())) + .entities() + .size() + > MAX_ASSIGNED_CHANGES) { + throw new ValidationException( + "Cannot assign user to more than " + MAX_ASSIGNED_CHANGES + " changes"); } - } catch (OrmException | QueryParseException e) { + } catch (OrmException | IOException | ConfigInvalidException | QueryParseException e) { log.error("Failed to validate assignee for change " + change.getId(), e); // Allow assignee. }
diff --git a/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/Module.java b/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/Module.java index 05ff04d..f3304f4 100644 --- a/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/Module.java +++ b/example-validationListenerAssignee/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerassignee/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), AssigneeValidationListener.class) - .to(AssigneeValidator.class); + DynamicSet.bind(binder(), AssigneeValidationListener.class).to(AssigneeValidator.class); } }
diff --git a/example-validationListenerCommit/WORKSPACE b/example-validationListenerCommit/WORKSPACE index 6ab125d..93b263f 100644 --- a/example-validationListenerCommit/WORKSPACE +++ b/example-validationListenerCommit/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerCommit/pom.xml b/example-validationListenerCommit/pom.xml index d7fea09..812c175 100644 --- a/example-validationListenerCommit/pom.xml +++ b/example-validationListenerCommit/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerCommit</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/CommitValidator.java b/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/CommitValidator.java index 70bca21..92f873f 100644 --- a/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/CommitValidator.java +++ b/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/CommitValidator.java
@@ -19,19 +19,17 @@ import com.google.gerrit.server.git.validators.CommitValidationException; import com.google.gerrit.server.git.validators.CommitValidationListener; import com.google.gerrit.server.git.validators.CommitValidationMessage; - import java.util.List; public class CommitValidator implements CommitValidationListener { @Override - public List<CommitValidationMessage> onCommitReceived( - CommitReceivedEvent receiveEvent) throws CommitValidationException { - if ("plugins/example-validationListenerCommit".equals(receiveEvent.project.getName()) && - !receiveEvent.commit.getShortMessage().startsWith("Cookbook: ")) { - CommitValidationMessage m = new CommitValidationMessage( - "Subject should begin with 'Cookbook: '", true); - throw new CommitValidationException( - "Invalid commit message", ImmutableList.of(m)); + public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent) + throws CommitValidationException { + if ("plugins/example-validationListenerCommit".equals(receiveEvent.project.getName()) + && !receiveEvent.commit.getShortMessage().startsWith("Cookbook: ")) { + CommitValidationMessage m = + new CommitValidationMessage("Subject should begin with 'Cookbook: '", true); + throw new CommitValidationException("Invalid commit message", ImmutableList.of(m)); } return ImmutableList.of(); }
diff --git a/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/Module.java b/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/Module.java index db39957..2220299 100644 --- a/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/Module.java +++ b/example-validationListenerCommit/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenercommit/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), CommitValidationListener.class) - .to(CommitValidator.class); + DynamicSet.bind(binder(), CommitValidationListener.class).to(CommitValidator.class); } }
diff --git a/example-validationListenerHashtag/WORKSPACE b/example-validationListenerHashtag/WORKSPACE index e097f4e..038cc42 100644 --- a/example-validationListenerHashtag/WORKSPACE +++ b/example-validationListenerHashtag/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerHashtag/pom.xml b/example-validationListenerHashtag/pom.xml index 88883b8..847a2d0 100644 --- a/example-validationListenerHashtag/pom.xml +++ b/example-validationListenerHashtag/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerHashtag</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/HashtagValidator.java b/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/HashtagValidator.java index 02e149e..bccc62e 100644 --- a/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/HashtagValidator.java +++ b/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/HashtagValidator.java
@@ -17,7 +17,6 @@ import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.server.validators.HashtagValidationListener; import com.google.gerrit.server.validators.ValidationException; - import java.util.Set; public class HashtagValidator implements HashtagValidationListener { @@ -29,7 +28,8 @@ if (toAdd.size() > 0) { for (String hashtag : toAdd) { if (!hashtag.startsWith("example-validationListenerHashtag-")) { - throw new ValidationException("Invalid example-validationListenerHashtag hashtag: " + hashtag); + throw new ValidationException( + "Invalid example-validationListenerHashtag hashtag: " + hashtag); } } }
diff --git a/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/Module.java b/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/Module.java index 43c4426..9c6b53d 100644 --- a/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/Module.java +++ b/example-validationListenerHashtag/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerhashtag/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), HashtagValidationListener.class) - .to(HashtagValidator.class); + DynamicSet.bind(binder(), HashtagValidationListener.class).to(HashtagValidator.class); } }
diff --git a/example-validationListenerMerge/WORKSPACE b/example-validationListenerMerge/WORKSPACE index 9d9fd0f..6df9790 100644 --- a/example-validationListenerMerge/WORKSPACE +++ b/example-validationListenerMerge/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerMerge/pom.xml b/example-validationListenerMerge/pom.xml index 5cefa5f..b63c248 100644 --- a/example-validationListenerMerge/pom.xml +++ b/example-validationListenerMerge/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerMerge</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/MergeUserValidator.java b/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/MergeUserValidator.java index d8cbf98..5088d29 100644 --- a/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/MergeUserValidator.java +++ b/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/MergeUserValidator.java
@@ -20,30 +20,42 @@ import com.google.gerrit.server.git.CodeReviewCommit; import com.google.gerrit.server.git.validators.MergeValidationException; import com.google.gerrit.server.git.validators.MergeValidationListener; +import com.google.gerrit.server.permissions.GlobalPermission; +import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.project.ProjectState; +import com.google.inject.Inject; import com.google.inject.Singleton; - import org.eclipse.jgit.lib.Repository; // Because we have a dedicated Module, we need to bind to the set // there, however, if you are using this as a base for your own // plugin, you can simply comment out the 'Listen' annotation and // it will work as expected. -//@Listen +// @Listen @Singleton public class MergeUserValidator implements MergeValidationListener { - /** - * Reject all merges if the submitter is not an administrator - */ + private PermissionBackend permissionBackend; + + @Inject + MergeUserValidator(PermissionBackend permissionBackend) { + this.permissionBackend = permissionBackend; + } + + /** Reject all merges if the submitter is not an administrator */ @Override - public void onPreMerge(Repository repo, CodeReviewCommit commit, - ProjectState destProject, Branch.NameKey destBranch, - PatchSet.Id patchSetId, IdentifiedUser caller) - throws MergeValidationException { - if (!caller.getCapabilities().canAdministrateServer()) { - throw new MergeValidationException("Submitter " + caller.getNameEmail() - + " is not a site administrator"); + public void onPreMerge( + Repository repo, + CodeReviewCommit commit, + ProjectState destProject, + Branch.NameKey destBranch, + PatchSet.Id patchSetId, + IdentifiedUser caller) + throws MergeValidationException { + + if (!permissionBackend.user(caller).testOrFalse(GlobalPermission.ADMINISTRATE_SERVER)) { + throw new MergeValidationException( + "Submitter " + caller.getNameEmail() + " is not a site administrator"); } } }
diff --git a/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/Module.java b/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/Module.java index dde757c..3f5a5d9 100644 --- a/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/Module.java +++ b/example-validationListenerMerge/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenermerge/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), MergeValidationListener.class) - .to(MergeUserValidator.class); + DynamicSet.bind(binder(), MergeValidationListener.class).to(MergeUserValidator.class); } }
diff --git a/example-validationListenerNewProjectCreated/WORKSPACE b/example-validationListenerNewProjectCreated/WORKSPACE index ac23090..6b7f1a3 100644 --- a/example-validationListenerNewProjectCreated/WORKSPACE +++ b/example-validationListenerNewProjectCreated/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerNewProjectCreated/pom.xml b/example-validationListenerNewProjectCreated/pom.xml index 5cf130f..1229aef 100644 --- a/example-validationListenerNewProjectCreated/pom.xml +++ b/example-validationListenerNewProjectCreated/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerNewProjectCreated</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/Module.java b/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/Module.java index 650febf..187a8e8 100644 --- a/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/Module.java +++ b/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), NewProjectCreatedListener.class) - .to(ProjectCreatedListener.class); + DynamicSet.bind(binder(), NewProjectCreatedListener.class).to(ProjectCreatedListener.class); } }
diff --git a/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/ProjectCreatedListener.java b/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/ProjectCreatedListener.java index 33c4cc7..61afa48 100644 --- a/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/ProjectCreatedListener.java +++ b/example-validationListenerNewProjectCreated/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenernewprojectcreated/ProjectCreatedListener.java
@@ -19,27 +19,22 @@ import com.google.gerrit.extensions.events.NewProjectCreatedListener; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.inject.Inject; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class ProjectCreatedListener implements NewProjectCreatedListener { - private static final Logger log = - LoggerFactory.getLogger(ProjectCreatedListener.class); + private static final Logger log = LoggerFactory.getLogger(ProjectCreatedListener.class); - @Inject - protected GerritApi gApi; + @Inject protected GerritApi gApi; @Override public void onNewProjectCreated(Event event) { String name = event.getProjectName(); try { ProjectApi api = gApi.projects().name(name); - log.info(String.format( - "New project: '%s', Parent: '%s'", name, api.get().parent)); + log.info(String.format("New project: '%s', Parent: '%s'", name, api.get().parent)); } catch (RestApiException e) { - log.error(String.format( - "Failed to get info for new project %s", name), e); + log.error(String.format("Failed to get info for new project %s", name), e); } } }
diff --git a/example-validationListenerRefOperation/WORKSPACE b/example-validationListenerRefOperation/WORKSPACE index 373a12f..5d76636 100644 --- a/example-validationListenerRefOperation/WORKSPACE +++ b/example-validationListenerRefOperation/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerRefOperation/pom.xml b/example-validationListenerRefOperation/pom.xml index 437f0f4..208f1ad 100644 --- a/example-validationListenerRefOperation/pom.xml +++ b/example-validationListenerRefOperation/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerRefOperation</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerRefOperation/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerrefoperation/RefOperationValidationExample.java b/example-validationListenerRefOperation/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerrefoperation/RefOperationValidationExample.java index 4cabd36..da7f4cb 100644 --- a/example-validationListenerRefOperation/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerrefoperation/RefOperationValidationExample.java +++ b/example-validationListenerRefOperation/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerrefoperation/RefOperationValidationExample.java
@@ -19,26 +19,31 @@ import com.google.gerrit.server.events.RefReceivedEvent; import com.google.gerrit.server.git.validators.RefOperationValidationListener; import com.google.gerrit.server.git.validators.ValidationMessage; +import com.google.gerrit.server.permissions.GlobalPermission; +import com.google.gerrit.server.permissions.PermissionBackend; import com.google.gerrit.server.validators.ValidationException; - +import com.google.inject.Inject; import java.util.ArrayList; import java.util.List; -public class RefOperationValidationExample implements - RefOperationValidationListener { +public class RefOperationValidationExample implements RefOperationValidationListener { + + private PermissionBackend permissionBackend; + + @Inject + RefOperationValidationExample(PermissionBackend permissionBackend) { + this.permissionBackend = permissionBackend; + } @Override - public List<ValidationMessage> onRefOperation(RefReceivedEvent event) - throws ValidationException { + public List<ValidationMessage> onRefOperation(RefReceivedEvent event) throws ValidationException { ArrayList<ValidationMessage> messages = Lists.newArrayList(); - if (event.command.getRefName() - .startsWith(RefNames.REFS_HEADS + "protected-") - && !event.user.getCapabilities().canAdministrateServer()) { - throw new ValidationException(String.format( - "Operation %s on %s branch in project %s is not valid!", - event.command.getType(), - event.command.getRefName(), - event.project.getName())); + if (event.command.getRefName().startsWith(RefNames.REFS_HEADS + "protected-") + && !permissionBackend.user(event.user).testOrFalse(GlobalPermission.ADMINISTRATE_SERVER)) { + throw new ValidationException( + String.format( + "Operation %s on %s branch in project %s is not valid!", + event.command.getType(), event.command.getRefName(), event.project.getName())); } return messages; }
diff --git a/example-validationListenerUpload/WORKSPACE b/example-validationListenerUpload/WORKSPACE index f7bc3d4..eebb7b5 100644 --- a/example-validationListenerUpload/WORKSPACE +++ b/example-validationListenerUpload/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-validationListenerUpload/pom.xml b/example-validationListenerUpload/pom.xml index 640aac6..0a4bc4a 100644 --- a/example-validationListenerUpload/pom.xml +++ b/example-validationListenerUpload/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-validationListenerUpload</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/DenyUploadExample.java b/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/DenyUploadExample.java index 7d85dce..e2231f8 100644 --- a/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/DenyUploadExample.java +++ b/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/DenyUploadExample.java
@@ -19,21 +19,23 @@ import com.google.gerrit.server.git.validators.UploadValidationListener; import com.google.gerrit.server.validators.ValidationException; import com.google.inject.Inject; - +import java.util.Collection; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.UploadPack; -import java.util.Collection; - public class DenyUploadExample implements UploadValidationListener { - @Inject - private CurrentUser user; + @Inject private CurrentUser user; @Override - public void onPreUpload(Repository repository, Project project, - String remoteHost, UploadPack up, Collection<? extends ObjectId> wants, - Collection<? extends ObjectId> haves) throws ValidationException { + public void onPreUpload( + Repository repository, + Project project, + String remoteHost, + UploadPack up, + Collection<? extends ObjectId> wants, + Collection<? extends ObjectId> haves) + throws ValidationException { up.sendMessage("Validating project name for " + user.getUserName() + "\n"); up.sendMessage(" from host: " + remoteHost + "\n"); if (project.getName().equals("deny-upload-project")) {
diff --git a/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/Module.java b/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/Module.java index 8bb84a3..9df23d8 100644 --- a/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/Module.java +++ b/example-validationListenerUpload/src/main/java/com/googlesource/gerrit/plugins/examples/validationlistenerupload/Module.java
@@ -21,7 +21,6 @@ public class Module extends AbstractModule { @Override protected void configure() { - DynamicSet.bind(binder(), UploadValidationListener.class) - .to(DenyUploadExample.class); + DynamicSet.bind(binder(), UploadValidationListener.class).to(DenyUploadExample.class); } }
diff --git a/example-webLinkBranch/WORKSPACE b/example-webLinkBranch/WORKSPACE index b7b4ce9..bacbd3a 100644 --- a/example-webLinkBranch/WORKSPACE +++ b/example-webLinkBranch/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-webLinkBranch/pom.xml b/example-webLinkBranch/pom.xml index 724baf8..b52782f 100644 --- a/example-webLinkBranch/pom.xml +++ b/example-webLinkBranch/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-webLinkBranch</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-webLinkBranch/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkbranch/HelloWeblink.java b/example-webLinkBranch/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkbranch/HelloWeblink.java index 1a73ada..6a0ba2a 100644 --- a/example-webLinkBranch/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkbranch/HelloWeblink.java +++ b/example-webLinkBranch/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkbranch/HelloWeblink.java
@@ -19,13 +19,13 @@ public class HelloWeblink implements BranchWebLink { private String name = "HelloLink"; - private String placeHolderUrlProjectBranch = - "http://my.hellolink.com/project=%s-branch=%s"; + private String placeHolderUrlProjectBranch = "http://my.hellolink.com/project=%s-branch=%s"; private String myImageUrl = "http://placehold.it/16x16.gif"; @Override public WebLinkInfo getBranchWebLink(String projectName, String branchName) { - return new WebLinkInfo(name, + return new WebLinkInfo( + name, myImageUrl, String.format(placeHolderUrlProjectBranch, projectName, branchName), Target.BLANK);
diff --git a/example-webLinkFileHistory/WORKSPACE b/example-webLinkFileHistory/WORKSPACE index f1ef565..db61ebc 100644 --- a/example-webLinkFileHistory/WORKSPACE +++ b/example-webLinkFileHistory/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-webLinkFileHistory/pom.xml b/example-webLinkFileHistory/pom.xml index 2c4366c..f5be5d1 100644 --- a/example-webLinkFileHistory/pom.xml +++ b/example-webLinkFileHistory/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-webLinkFileHistory</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-webLinkFileHistory/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkfilehistory/HelloWeblink.java b/example-webLinkFileHistory/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkfilehistory/HelloWeblink.java index e5462c8..f0d9ef2 100644 --- a/example-webLinkFileHistory/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkfilehistory/HelloWeblink.java +++ b/example-webLinkFileHistory/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkfilehistory/HelloWeblink.java
@@ -19,19 +19,17 @@ public class HelloWeblink implements FileHistoryWebLink { private String name = "HelloLink"; - private String placeHolderUrlProject = - "http://my.hellolink.com/project=%s"; + private String placeHolderUrlProject = "http://my.hellolink.com/project=%s"; private String placeHolderUrlProjectRevisionFileName = placeHolderUrlProject + "-revision=%s-file=%s"; private String myImageUrl = "http://placehold.it/16x16.gif"; @Override - public WebLinkInfo getFileHistoryWebLink(String projectName, String revision, - String fileName) { - return new WebLinkInfo(name, + public WebLinkInfo getFileHistoryWebLink(String projectName, String revision, String fileName) { + return new WebLinkInfo( + name, myImageUrl, - String.format(placeHolderUrlProjectRevisionFileName, projectName, - revision, fileName), + String.format(placeHolderUrlProjectRevisionFileName, projectName, revision, fileName), Target.BLANK); } }
diff --git a/example-webLinkPatchSet/WORKSPACE b/example-webLinkPatchSet/WORKSPACE index f1ef565..db61ebc 100644 --- a/example-webLinkPatchSet/WORKSPACE +++ b/example-webLinkPatchSet/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-webLinkPatchSet/pom.xml b/example-webLinkPatchSet/pom.xml index 48a06c0..b6a7406 100644 --- a/example-webLinkPatchSet/pom.xml +++ b/example-webLinkPatchSet/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-webLinkPatchSet</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-webLinkPatchSet/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkpatchset/HelloWeblink.java b/example-webLinkPatchSet/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkpatchset/HelloWeblink.java index 6ec68ac..b6d1a45 100644 --- a/example-webLinkPatchSet/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkpatchset/HelloWeblink.java +++ b/example-webLinkPatchSet/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkpatchset/HelloWeblink.java
@@ -19,15 +19,14 @@ public class HelloWeblink implements PatchSetWebLink { private String name = "HelloLink"; - private String placeHolderUrlProject = - "http://my.hellolink.com/project=%s"; - private String placeHolderUrlProjectCommit = - placeHolderUrlProject + "/commit=%s"; + private String placeHolderUrlProject = "http://my.hellolink.com/project=%s"; + private String placeHolderUrlProjectCommit = placeHolderUrlProject + "/commit=%s"; private String myImageUrl = "http://placehold.it/16x16.gif"; @Override public WebLinkInfo getPatchSetWebLink(String projectName, String commit) { - return new WebLinkInfo(name, + return new WebLinkInfo( + name, myImageUrl, String.format(placeHolderUrlProjectCommit, projectName, commit), Target.BLANK);
diff --git a/example-webLinkProject/WORKSPACE b/example-webLinkProject/WORKSPACE index f1ef565..db61ebc 100644 --- a/example-webLinkProject/WORKSPACE +++ b/example-webLinkProject/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-webLinkProject/pom.xml b/example-webLinkProject/pom.xml index b583de1..91da1fe 100644 --- a/example-webLinkProject/pom.xml +++ b/example-webLinkProject/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-webLinkProject</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-webLinkProject/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkproject/HelloWeblink.java b/example-webLinkProject/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkproject/HelloWeblink.java index 91ba9d0..e1a264f 100644 --- a/example-webLinkProject/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkproject/HelloWeblink.java +++ b/example-webLinkProject/src/main/java/com/googlesource/gerrit/plugins/examples/weblinkproject/HelloWeblink.java
@@ -15,22 +15,16 @@ package com.googlesource.gerrit.plugins.examples.weblinkproject; import com.google.gerrit.extensions.common.WebLinkInfo; -import com.google.gerrit.extensions.webui.BranchWebLink; -import com.google.gerrit.extensions.webui.FileHistoryWebLink; -import com.google.gerrit.extensions.webui.PatchSetWebLink; import com.google.gerrit.extensions.webui.ProjectWebLink; public class HelloWeblink implements ProjectWebLink { private String name = "HelloLink"; - private String placeHolderUrlProject = - "http://my.hellolink.com/project=%s"; + private String placeHolderUrlProject = "http://my.hellolink.com/project=%s"; private String myImageUrl = "http://placehold.it/16x16.gif"; @Override public WebLinkInfo getProjectWeblink(String projectName) { - return new WebLinkInfo(name, - myImageUrl, - String.format(placeHolderUrlProject, projectName), - Target.BLANK); + return new WebLinkInfo( + name, myImageUrl, String.format(placeHolderUrlProject, projectName), Target.BLANK); } }
diff --git a/example-wuiChangeScreenBelowChangeInfoBlock/WORKSPACE b/example-wuiChangeScreenBelowChangeInfoBlock/WORKSPACE index 70c3239..9c736d9 100644 --- a/example-wuiChangeScreenBelowChangeInfoBlock/WORKSPACE +++ b/example-wuiChangeScreenBelowChangeInfoBlock/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiChangeScreenBelowChangeInfoBlock/pom.xml b/example-wuiChangeScreenBelowChangeInfoBlock/pom.xml index cef3ace..331de3d 100644 --- a/example-wuiChangeScreenBelowChangeInfoBlock/pom.xml +++ b/example-wuiChangeScreenBelowChangeInfoBlock/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiChangeScreenBelowChangeInfoBlock</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/Module.java b/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/Module.java index 836d631..0000021 100644 --- a/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/Module.java +++ b/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExampleChangeScreenExtensionTwo.java b/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExampleChangeScreenExtensionTwo.java new file mode 100644 index 0000000..bced2ca --- /dev/null +++ b/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExampleChangeScreenExtensionTwo.java
@@ -0,0 +1,57 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.wuichangescreenbelowchangeinfoblock.client; + +import com.google.gerrit.client.GerritUiExtensionPoint; +import com.google.gerrit.client.info.ChangeInfo; +import com.google.gerrit.client.info.ChangeInfo.RevisionInfo; +import com.google.gerrit.plugin.client.extension.Panel; +import com.google.gwt.user.client.ui.Grid; +import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.google.gwtexpui.clippy.client.CopyableLabel; + +/** Extension for change screen that displays the numeric change ID with copy-to-clipboard icon. */ +public class ExampleChangeScreenExtensionTwo extends VerticalPanel { + static class Factory implements Panel.EntryPoint { + @Override + public void onLoad(Panel panel) { + panel.setWidget(new ExampleChangeScreenExtensionTwo(panel)); + } + } + + ExampleChangeScreenExtensionTwo(Panel panel) { + ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast(); + RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast(); + + Grid g = new Grid(2, 2); + g.addStyleName("infoBlock"); + CellFormatter fmt = g.getCellFormatter(); + + g.setText(0, 0, "(2) Numeric Change ID"); + fmt.addStyleName(0, 0, "header"); + fmt.addStyleName(0, 0, "topmost"); + fmt.addStyleName(0, 1, "topmost"); + g.setWidget(0, 1, new CopyableLabel(Integer.toString(change._number()))); + add(g); + + g.setText(1, 0, "(2) Patch Set ID"); + fmt.addStyleName(1, 0, "header"); + fmt.addStyleName(1, 0, "bottomheader"); + fmt.addStyleName(1, 1, "bottomheader"); + g.setWidget(1, 1, new CopyableLabel(String.valueOf(rev._number()))); + add(g); + } +}
diff --git a/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExamplePlugin.java b/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExamplePlugin.java index 0a6e189..312c857 100644 --- a/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExamplePlugin.java +++ b/example-wuiChangeScreenBelowChangeInfoBlock/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenbelowchangeinfoblock/client/ExamplePlugin.java
@@ -18,12 +18,7 @@ import com.google.gerrit.client.Resources; import com.google.gerrit.plugin.client.Plugin; import com.google.gerrit.plugin.client.PluginEntryPoint; -import com.google.gerrit.plugin.client.extension.Panel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; public class ExamplePlugin extends PluginEntryPoint { public static final Resources RESOURCES = GWT.create(Resources.class); @@ -33,6 +28,12 @@ Plugin.get() .panel( GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK, - new ExampleChangeScreenExtension.Factory()); + new ExampleChangeScreenExtension.Factory(), + "first"); + Plugin.get() + .panel( + GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK, + new ExampleChangeScreenExtensionTwo.Factory(), + "second"); } }
diff --git a/example-wuiChangeScreenHeader/WORKSPACE b/example-wuiChangeScreenHeader/WORKSPACE index 504943c..00385de 100644 --- a/example-wuiChangeScreenHeader/WORKSPACE +++ b/example-wuiChangeScreenHeader/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiChangeScreenHeader/pom.xml b/example-wuiChangeScreenHeader/pom.xml index b4e3580..6e67cdc 100644 --- a/example-wuiChangeScreenHeader/pom.xml +++ b/example-wuiChangeScreenHeader/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiChangeScreenHeader</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/Module.java b/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/Module.java index d0905d4..8507a5e 100644 --- a/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/Module.java +++ b/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/client/ExamplePlugin.java b/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/client/ExamplePlugin.java index c9467b1..5679e0d 100644 --- a/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/client/ExamplePlugin.java +++ b/example-wuiChangeScreenHeader/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheader/client/ExamplePlugin.java
@@ -18,12 +18,7 @@ import com.google.gerrit.client.Resources; import com.google.gerrit.plugin.client.Plugin; import com.google.gerrit.plugin.client.PluginEntryPoint; -import com.google.gerrit.plugin.client.extension.Panel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; public class ExamplePlugin extends PluginEntryPoint { public static final Resources RESOURCES = GWT.create(Resources.class); @@ -32,6 +27,8 @@ public void onPluginLoad() { Plugin.get() .panel( - GerritUiExtensionPoint.CHANGE_SCREEN_HEADER, new ChangeScreenStatusExtension.Factory()); + GerritUiExtensionPoint.CHANGE_SCREEN_HEADER, + new ChangeScreenStatusExtension.Factory(), + "status"); } }
diff --git a/example-wuiChangeScreenHeaderRightOfButtons/WORKSPACE b/example-wuiChangeScreenHeaderRightOfButtons/WORKSPACE index 4f0f830..e4d6eb9 100644 --- a/example-wuiChangeScreenHeaderRightOfButtons/WORKSPACE +++ b/example-wuiChangeScreenHeaderRightOfButtons/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiChangeScreenHeaderRightOfButtons/pom.xml b/example-wuiChangeScreenHeaderRightOfButtons/pom.xml index 66999c0..46b7e3e 100644 --- a/example-wuiChangeScreenHeaderRightOfButtons/pom.xml +++ b/example-wuiChangeScreenHeaderRightOfButtons/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiChangeScreenHeaderRightOfButtons</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/Module.java b/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/Module.java index bc92f20..25b6824 100644 --- a/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/Module.java +++ b/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/client/ExamplePlugin.java b/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/client/ExamplePlugin.java index 810dc5a..e1200a3 100644 --- a/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/client/ExamplePlugin.java +++ b/example-wuiChangeScreenHeaderRightOfButtons/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofbuttons/client/ExamplePlugin.java
@@ -46,6 +46,7 @@ }); panel.setWidget(b); } - }); + }, + "library_compliance"); } }
diff --git a/example-wuiChangeScreenHeaderRightOfPopDowns/WORKSPACE b/example-wuiChangeScreenHeaderRightOfPopDowns/WORKSPACE index 0139999..c38baeb 100644 --- a/example-wuiChangeScreenHeaderRightOfPopDowns/WORKSPACE +++ b/example-wuiChangeScreenHeaderRightOfPopDowns/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiChangeScreenHeaderRightOfPopDowns/pom.xml b/example-wuiChangeScreenHeaderRightOfPopDowns/pom.xml index dae5b8b..8ae6e83 100644 --- a/example-wuiChangeScreenHeaderRightOfPopDowns/pom.xml +++ b/example-wuiChangeScreenHeaderRightOfPopDowns/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiChangeScreenHeaderRightOfPopDowns</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/Module.java b/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/Module.java index fade050..d9d071b 100644 --- a/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/Module.java +++ b/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/client/ExamplePlugin.java b/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/client/ExamplePlugin.java index e9ed191..582b7b6 100644 --- a/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/client/ExamplePlugin.java +++ b/example-wuiChangeScreenHeaderRightOfPopDowns/src/main/java/com/googlesource/gerrit/plugins/examples/wuichangescreenheaderrightofpopdowns/client/ExamplePlugin.java
@@ -18,12 +18,7 @@ import com.google.gerrit.client.Resources; import com.google.gerrit.plugin.client.Plugin; import com.google.gerrit.plugin.client.PluginEntryPoint; -import com.google.gerrit.plugin.client.extension.Panel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; public class ExamplePlugin extends PluginEntryPoint { public static final Resources RESOURCES = GWT.create(Resources.class); @@ -33,6 +28,7 @@ Plugin.get() .panel( GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS, - new BuildsDropDownPanel.Factory()); + new BuildsDropDownPanel.Factory(), + "status"); } }
diff --git a/example-wuiPluginScreen/.bazelrc b/example-wuiPluginScreen/.bazelrc new file mode 100644 index 0000000..4ed16cf --- /dev/null +++ b/example-wuiPluginScreen/.bazelrc
@@ -0,0 +1,2 @@ +build --workspace_status_command=./tools/workspace-status.sh +test --build_tests_only
diff --git a/example-wuiPluginScreen/.buckconfig b/example-wuiPluginScreen/.buckconfig new file mode 100644 index 0000000..98b47af --- /dev/null +++ b/example-wuiPluginScreen/.buckconfig
@@ -0,0 +1,15 @@ +[alias] + plugin = //:example-wuiPluginScreen + +[java] + src_roots = java, resources + source_level = 8 + target_level = 8 + +[project] + ignore = .git + +[cache] + mode = dir + dir = buck-out/cache +
diff --git a/example-wuiPluginScreen/BUILD b/example-wuiPluginScreen/BUILD new file mode 100644 index 0000000..d646b8f --- /dev/null +++ b/example-wuiPluginScreen/BUILD
@@ -0,0 +1,15 @@ +load("//tools/bzl:plugin.bzl", "gerrit_plugin") + +MODULE = "com.googlesource.gerrit.plugins.examples.wuipluginscreen.HelloForm" + +gerrit_plugin( + name = "example-wuiPluginScreen", + srcs = glob(["src/main/java/**/*.java"]), + gwt_module = MODULE, + manifest_entries = [ + "Gerrit-PluginName: example-wuiPluginScreen", + "Gerrit-Module: com.googlesource.gerrit.plugins.examples.wuipluginscreen.Module", + "Implementation-Title: Example Plugin Screen Extension", + ], + resources = glob(["src/main/**/*"]), +)
diff --git a/example-wuiPluginScreen/LICENSE b/example-wuiPluginScreen/LICENSE new file mode 100644 index 0000000..11069ed --- /dev/null +++ b/example-wuiPluginScreen/LICENSE
@@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.
diff --git a/example-wuiPluginScreen/WORKSPACE b/example-wuiPluginScreen/WORKSPACE new file mode 100644 index 0000000..b79bf1c --- /dev/null +++ b/example-wuiPluginScreen/WORKSPACE
@@ -0,0 +1,33 @@ +workspace(name = "wuiSettingsScreen") + +load("//:bazlets.bzl", "load_bazlets") + +load_bazlets( + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", + # local_path = "/home/<user>/projects/bazlets", +) + +# Release Plugin API +load( + "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", + "gerrit_api", +) + +# Snapshot Plugin API +#load( +# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", +# "gerrit_api_maven_local", +#) + +load( + "@com_googlesource_gerrit_bazlets//:gerrit_gwt.bzl", + "gerrit_gwt", +) + +# Load release Plugin API +gerrit_api() + +# Load snapshot Plugin API +#gerrit_api_maven_local() + +gerrit_gwt()
diff --git a/example-wuiPluginScreen/bazlets.bzl b/example-wuiPluginScreen/bazlets.bzl new file mode 100644 index 0000000..6c4fffc --- /dev/null +++ b/example-wuiPluginScreen/bazlets.bzl
@@ -0,0 +1,19 @@ +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +NAME = "com_googlesource_gerrit_bazlets" + +def load_bazlets( + commit, + local_path = None + ): + if not local_path: + git_repository( + name = NAME, + remote = "https://gerrit.googlesource.com/bazlets", + commit = commit, + ) + else: + native.local_repository( + name = NAME, + path = local_path, + )
diff --git a/example-wuiPluginScreen/lib/BUCK b/example-wuiPluginScreen/lib/BUCK new file mode 100644 index 0000000..d333cba --- /dev/null +++ b/example-wuiPluginScreen/lib/BUCK
@@ -0,0 +1,18 @@ +include_defs('//bucklets/maven_jar.bucklet') + +maven_jar( + name = 'junit', + id = 'junit:junit:4.11', + sha1 = '4e031bb61df09069aeb2bffb4019e7a5034a4ee0', + license = 'DO_NOT_DISTRIBUTE', +) + +maven_jar( + name = 'truth', + id = 'com.google.truth:truth:0.27', + sha1 = 'bd17774d2dc0fffa884d42c07d2537e86c67acd6', + license = 'DO_NOT_DISTRIBUTE', + exported_deps = [ + ':junit', + ], +)
diff --git a/example-wuiPluginScreen/lib/gwt/BUCK b/example-wuiPluginScreen/lib/gwt/BUCK new file mode 100644 index 0000000..26e55d3 --- /dev/null +++ b/example-wuiPluginScreen/lib/gwt/BUCK
@@ -0,0 +1,73 @@ +include_defs('//bucklets/maven_jar.bucklet') + +VERSION = '2.8.0' + +maven_jar( + name = 'user', + id = 'com.google.gwt:gwt-user:' + VERSION, + sha1 = '518579870499e15531f454f35dca0772d7fa31f7', + license = 'Apache2.0', + attach_source = False, +) + +maven_jar( + name = 'dev', + id = 'com.google.gwt:gwt-dev:' + VERSION, + sha1 = 'f160a61272c5ebe805cd2d3d3256ed3ecf14893f', + license = 'Apache2.0', + attach_source = False, +) + +maven_jar( + name = 'javax-validation', + id = 'javax.validation:validation-api:1.0.0.GA', + bin_sha1 = 'b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e', + src_sha1 = '7a561191db2203550fbfa40d534d4997624cd369', + license = 'Apache2.0', + visibility = ['PUBLIC'], +) + +maven_jar( + name = 'jsinterop-annotations', + id = 'com.google.jsinterop:jsinterop-annotations:1.0.0', + bin_sha1 = '23c3a3c060ffe4817e67673cc8294e154b0a4a95', + src_sha1 = '5d7c478efbfccc191430d7c118d7bd2635e43750', + license = 'Apache2.0', + visibility = ['PUBLIC'], +) + +maven_jar( + name = 'ant', + id = 'ant:ant:1.6.5', + bin_sha1 = '7d18faf23df1a5c3a43613952e0e8a182664564b', + src_sha1 = '9e0a847494563f35f9b02846a1c1eb4aa2ee5a9a', + license = 'Apache2.0', + visibility = ['PUBLIC'], +) + +maven_jar( + name = 'colt', + id = 'colt:colt:1.2.0', + attach_source = False, + bin_sha1 = '0abc984f3adc760684d49e0f11ddf167ba516d4f', + license = 'DO_NOT_DISTRIBUTE', + visibility = ['PUBLIC'], +) + +maven_jar( + name = 'tapestry', + id = 'tapestry:tapestry:4.0.2', + attach_source = False, + bin_sha1 = 'e855a807425d522e958cbce8697f21e9d679b1f7', + license = 'Apache2.0', + visibility = ['PUBLIC'], +) + +maven_jar( + name = 'w3c-css-sac', + id = 'org.w3c.css:sac:1.3', + attach_source = False, + bin_sha1 = 'cdb2dcb4e22b83d6b32b93095f644c3462739e82', + license = 'DO_NOT_DISTRIBUTE', + visibility = ['PUBLIC'], +)
diff --git a/example-wuiPluginScreen/lib/ow2/BUCK b/example-wuiPluginScreen/lib/ow2/BUCK new file mode 100644 index 0000000..543bc09 --- /dev/null +++ b/example-wuiPluginScreen/lib/ow2/BUCK
@@ -0,0 +1,39 @@ +include_defs('//bucklets/maven_jar.bucklet') + +VERSION = '5.1' + +maven_jar( + name = 'ow2-asm', + id = 'org.ow2.asm:asm:' + VERSION, + sha1 = '5ef31c4fe953b1fd00b8a88fa1d6820e8785bb45', + license = 'ow2', +) + +maven_jar( + name = 'ow2-asm-analysis', + id = 'org.ow2.asm:asm-analysis:' + VERSION, + sha1 = '6d1bf8989fc7901f868bee3863c44f21aa63d110', + license = 'ow2', +) + +maven_jar( + name = 'ow2-asm-commons', + id = 'org.ow2.asm:asm-commons:' + VERSION, + sha1 = '25d8a575034dd9cfcb375a39b5334f0ba9c8474e', + deps = [':ow2-asm-tree'], + license = 'ow2', +) + +maven_jar( + name = 'ow2-asm-tree', + id = 'org.ow2.asm:asm-tree:' + VERSION, + sha1 = '87b38c12a0ea645791ead9d3e74ae5268d1d6c34', + license = 'ow2', +) + +maven_jar( + name = 'ow2-asm-util', + id = 'org.ow2.asm:asm-util:' + VERSION, + sha1 = 'b60e33a6bd0d71831e0c249816d01e6c1dd90a47', + license = 'ow2', +)
diff --git a/example-wuiPluginScreen/pom.xml b/example-wuiPluginScreen/pom.xml new file mode 100644 index 0000000..3abddec --- /dev/null +++ b/example-wuiPluginScreen/pom.xml
@@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (C) 2013 The Android Open Source Project + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>com.googlesource.gerrit.plugins</groupId> + <artifactId>example-wuiPluginScreen</artifactId> + <packaging>jar</packaging> + <version>2.14-SNAPSHOT</version> + <properties> + <Gerrit-ApiType>plugin</Gerrit-ApiType> + <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion> + <GWT-Version>2.8.0</GWT-Version> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <Gerrit-PluginName>example-wuiPluginScreen</Gerrit-PluginName> + <Gerrit-Module>com.googlesource.gerrit.plugins.examples.wuipluginscreen.Module</Gerrit-Module> + + <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor> + <Implementation-URL>https://gerrit-review.googlesource.com/#/admin/projects/plugins/examples</Implementation-URL> + + <Implementation-Title>Example Plugin Screen Extension</Implementation-Title> + <Implementation-Version>${project.version}</Implementation-Version> + + <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType> + <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>gwt-maven-plugin</artifactId> + <version>${GWT-Version}</version> + <configuration> + <module>com.googlesource.gerrit.plugins.examples.wuipluginscreen.HelloForm</module> + <disableClassMetadata>true</disableClassMetadata> + <disableCastChecking>true</disableCastChecking> + <webappDirectory>${project.build.directory}/classes/static</webappDirectory> + </configuration> + <executions> + <execution> + <goals> + <goal>compile</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + </build> + + <dependencies> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.gerrit</groupId> + <artifactId>gerrit-plugin-gwtui</artifactId> + <version>${Gerrit-ApiVersion}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.gwt</groupId> + <artifactId>gwt-user</artifactId> + <version>${GWT-Version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <repositories> + <repository> + <id>maven.org</id> + <url>http://repo1.maven.org/maven2</url> + </repository> + </repositories> +</project>
diff --git a/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/HelloForm.gwt.xml b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/HelloForm.gwt.xml new file mode 100644 index 0000000..767b43c --- /dev/null +++ b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/HelloForm.gwt.xml
@@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (C) 2017 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<module rename-to="example"> + <!-- Inherit the core Web Toolkit stuff. --> + <inherits name="com.google.gwt.user.User"/> + <!-- Other module inherits --> + <inherits name="com.google.gerrit.GerritGwtUICommon"/> + <inherits name="com.google.gerrit.Plugin"/> + <inherits name="com.google.gwt.http.HTTP"/> + <inherits name="com.google.gwt.json.JSON"/> + <!-- Using GWT built-in themes adds a number of static --> + <!-- resources to the plugin. No theme inherits lines were --> + <!-- added in order to make this plugin as simple as possible --> + <!-- Specify the app entry point class. --> + <entry-point class="com.googlesource.gerrit.plugins.examples.wuipluginscreen.client.ExamplePlugin"/> + <stylesheet src="example.css"/> +</module>
diff --git a/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/HelloTopMenu.java b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/HelloTopMenu.java new file mode 100644 index 0000000..2f6dae8 --- /dev/null +++ b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/HelloTopMenu.java
@@ -0,0 +1,46 @@ +// Copyright (C) 2013 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.topmenu; + +import com.google.common.collect.Lists; +import com.google.gerrit.extensions.annotations.PluginName; +import com.google.gerrit.extensions.client.MenuItem; +import com.google.gerrit.extensions.webui.TopMenu; +import com.google.inject.Inject; +import java.util.List; + +public class HelloTopMenu implements TopMenu { + private final List<MenuEntry> menuEntries; + + @Inject + public HelloTopMenu(@PluginName String pluginName) { + String baseUrl = "/plugins/" + pluginName + "/"; + List<MenuItem> menuItems = Lists.newArrayListWithCapacity(2); + menuItems.add(new MenuItem("Greeting", "#/x/" + pluginName + "/", "")); + menuItems.add(new MenuItem("Documentation", baseUrl)); + menuEntries = Lists.newArrayListWithCapacity(2); + menuEntries.add(new MenuEntry("Examples", menuItems)); + menuEntries.add( + new MenuEntry( + "Projects", + Lists.newArrayList( + new MenuItem("Browse Repositories", "https://gerrit.googlesource.com/")))); + } + + @Override + public List<MenuEntry> getEntries() { + return menuEntries; + } +}
diff --git a/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/Module.java b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/Module.java new file mode 100644 index 0000000..6806e8a --- /dev/null +++ b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/Module.java
@@ -0,0 +1,31 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.wuipluginscreen; + +import com.google.gerrit.extensions.registration.DynamicSet; +import com.google.gerrit.extensions.webui.GwtPlugin; +import com.google.gerrit.extensions.webui.TopMenu; +import com.google.gerrit.extensions.webui.WebUiPlugin; +import com.google.inject.AbstractModule; +import com.googlesource.gerrit.plugins.examples.topmenu.HelloTopMenu; + +public class Module extends AbstractModule { + + @Override + protected void configure() { + DynamicSet.bind(binder(), TopMenu.class).to(HelloTopMenu.class); + DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("example")); + } +}
diff --git a/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/client/ExamplePlugin.java b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/client/ExamplePlugin.java new file mode 100644 index 0000000..6fc3755 --- /dev/null +++ b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/client/ExamplePlugin.java
@@ -0,0 +1,29 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.wuipluginscreen.client; + +import com.google.gerrit.client.Resources; +import com.google.gerrit.plugin.client.Plugin; +import com.google.gerrit.plugin.client.PluginEntryPoint; +import com.google.gwt.core.client.GWT; + +public class ExamplePlugin extends PluginEntryPoint { + public static final Resources RESOURCES = GWT.create(Resources.class); + + @Override + public void onPluginLoad() { + Plugin.get().screen("", new IndexScreen.Factory()); + } +}
diff --git a/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/client/IndexScreen.java b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/client/IndexScreen.java new file mode 100644 index 0000000..261a76a --- /dev/null +++ b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/client/IndexScreen.java
@@ -0,0 +1,138 @@ +// Copyright (C) 2017 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.googlesource.gerrit.plugins.examples.wuipluginscreen.client; + +import com.google.gerrit.plugin.client.screen.Screen; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.dom.client.KeyPressEvent; +import com.google.gwt.event.dom.client.KeyPressHandler; +import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.Label; +import com.google.gwt.user.client.ui.Panel; +import com.google.gwt.user.client.ui.TextArea; +import com.google.gwt.user.client.ui.TextBox; +import com.google.gwt.user.client.ui.VerticalPanel; + +class IndexScreen extends VerticalPanel { + static class Factory implements Screen.EntryPoint { + @Override + public void onLoad(Screen screen) { + screen.setPageTitle("example index"); + screen.show(new IndexScreen()); + } + } + + private TextBox usernameTxt; + private TextArea greetingTxt; + + IndexScreen() { + setStyleName("example-panel"); + + Panel labelImagePanel = new HorizontalPanel(); + Panel usernamePanel = new VerticalPanel(); + Image img = new Image(ExamplePlugin.RESOURCES.info()); + img.setTitle("User to send greetings to"); + labelImagePanel.add(new Label("Username")); + labelImagePanel.add(img); + labelImagePanel.add(new Label(":")); + usernamePanel.add(labelImagePanel); + usernameTxt = + new TextBox() { + @Override + public void onBrowserEvent(Event event) { + super.onBrowserEvent(event); + if (event.getTypeInt() == Event.ONPASTE) { + Scheduler.get() + .scheduleDeferred( + new ScheduledCommand() { + @Override + public void execute() { + if (getValue().trim().length() != 0) { + setEnabled(true); + } + } + }); + } + } + }; + usernameTxt.addKeyPressHandler( + new KeyPressHandler() { + @Override + public void onKeyPress(final KeyPressEvent event) { + event.stopPropagation(); + } + }); + usernameTxt.sinkEvents(Event.ONPASTE); + usernameTxt.setVisibleLength(40); + usernamePanel.add(usernameTxt); + add(usernamePanel); + + Panel messagePanel = new VerticalPanel(); + messagePanel.add(new Label("Message:")); + greetingTxt = new TextArea(); + greetingTxt.addKeyPressHandler( + new KeyPressHandler() { + @Override + public void onKeyPress(final KeyPressEvent event) { + event.stopPropagation(); + } + }); + greetingTxt.setVisibleLines(12); + greetingTxt.setCharacterWidth(80); + greetingTxt.getElement().setPropertyBoolean("spellcheck", false); + messagePanel.add(greetingTxt); + add(messagePanel); + + Button helloButton = new Button("Say Hello"); + helloButton.addStyleName("example-helloButton"); + helloButton.addClickHandler( + new ClickHandler() { + @Override + public void onClick(final ClickEvent event) { + sayHello(); + } + }); + add(helloButton); + helloButton.setEnabled(true); + } + + private void sayHello() { + String username = usernameTxt.getValue(); + String greeting = greetingTxt.getText(); + if (username == null) { + username = ""; + } else { + username = username.trim(); + } + if (greeting == null) { + greeting = ""; + } else { + greeting = greeting.trim(); + } + StringBuilder sb = new StringBuilder(); + sb.append("Hey "); + sb.append(username.isEmpty() ? "Dude" : username); + sb.append(", "); + sb.append(greeting.isEmpty() ? "what's up?" : greeting); + Window.alert(sb.toString()); + } +}
diff --git a/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/public/example.css b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/public/example.css new file mode 100644 index 0000000..cca1597 --- /dev/null +++ b/example-wuiPluginScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuipluginscreen/public/example.css
@@ -0,0 +1,8 @@ +.example-panel { + border-spacing: 0px 5px; +} + +.example-helloButton { + margin-left: 35px !important; + margin-right: 450px !important; +}
diff --git a/example-wuiPluginScreen/src/main/resources/Documentation/about.md b/example-wuiPluginScreen/src/main/resources/Documentation/about.md new file mode 100644 index 0000000..e814753 --- /dev/null +++ b/example-wuiPluginScreen/src/main/resources/Documentation/about.md
@@ -0,0 +1,3 @@ +Sample plugin to demonstrate an Index Screen extension. + +An example Index Screen is located under the Examples (TopMenu) > Greetings section
diff --git a/example-wuiPluginScreen/tools/bzl/BUILD b/example-wuiPluginScreen/tools/bzl/BUILD new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example-wuiPluginScreen/tools/bzl/BUILD
diff --git a/example-wuiPluginScreen/tools/bzl/plugin.bzl b/example-wuiPluginScreen/tools/bzl/plugin.bzl new file mode 100644 index 0000000..89a1643 --- /dev/null +++ b/example-wuiPluginScreen/tools/bzl/plugin.bzl
@@ -0,0 +1,8 @@ +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + _gerrit_plugin = "gerrit_plugin", + _plugin_deps = "PLUGIN_DEPS", +) + +gerrit_plugin = _gerrit_plugin +PLUGIN_DEPS = _plugin_deps
diff --git a/example-wuiPluginScreen/tools/workspace-status.sh b/example-wuiPluginScreen/tools/workspace-status.sh new file mode 100755 index 0000000..f337593 --- /dev/null +++ b/example-wuiPluginScreen/tools/workspace-status.sh
@@ -0,0 +1,17 @@ +#!/bin/bash + +# This script will be run by bazel when the build process starts to +# generate key-value information that represents the status of the +# workspace. The output should be like +# +# KEY1 VALUE1 +# KEY2 VALUE2 +# +# If the script exits with non-zero code, it's considered as a failure +# and the output will be discarded. + +function rev() { + git describe --always --match "v[0-9].*" --dirty +} + +echo STABLE_BUILD_EXAMPLE-WUIPLUGINSCREEN_LABEL $(rev)
diff --git a/example-wuiPreferenceScreenBottom/WORKSPACE b/example-wuiPreferenceScreenBottom/WORKSPACE index 6907c43..b5ec636 100644 --- a/example-wuiPreferenceScreenBottom/WORKSPACE +++ b/example-wuiPreferenceScreenBottom/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiPreferenceScreenBottom/pom.xml b/example-wuiPreferenceScreenBottom/pom.xml index f95776e..96cf47c 100644 --- a/example-wuiPreferenceScreenBottom/pom.xml +++ b/example-wuiPreferenceScreenBottom/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiPreferenceScreenBottom</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/Module.java b/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/Module.java index 306be40..79883b0 100644 --- a/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/Module.java +++ b/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/client/ExamplePlugin.java b/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/client/ExamplePlugin.java index 946bc89..2714cf6 100644 --- a/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/client/ExamplePlugin.java +++ b/example-wuiPreferenceScreenBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuipreferencescreenbottom/client/ExamplePlugin.java
@@ -18,12 +18,7 @@ import com.google.gerrit.client.Resources; import com.google.gerrit.plugin.client.Plugin; import com.google.gerrit.plugin.client.PluginEntryPoint; -import com.google.gerrit.plugin.client.extension.Panel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; public class ExamplePlugin extends PluginEntryPoint { public static final Resources RESOURCES = GWT.create(Resources.class); @@ -33,6 +28,7 @@ Plugin.get() .panel( GerritUiExtensionPoint.PREFERENCES_SCREEN_BOTTOM, - new ChangeScreenPreferencePanel.Factory()); + new ChangeScreenPreferencePanel.Factory(), + "change_screen_preferences"); } }
diff --git a/example-wuiProfileExtensionBottom/WORKSPACE b/example-wuiProfileExtensionBottom/WORKSPACE index 560444b..81cc109 100644 --- a/example-wuiProfileExtensionBottom/WORKSPACE +++ b/example-wuiProfileExtensionBottom/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiProfileExtensionBottom/pom.xml b/example-wuiProfileExtensionBottom/pom.xml index a11c742..824e5bc 100644 --- a/example-wuiProfileExtensionBottom/pom.xml +++ b/example-wuiProfileExtensionBottom/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiProfileExtensionBottom</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/Module.java b/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/Module.java index 637b947..ef5d5a2 100644 --- a/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/Module.java +++ b/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/client/ExamplePlugin.java b/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/client/ExamplePlugin.java index 8f2aad8..2770325 100644 --- a/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/client/ExamplePlugin.java +++ b/example-wuiProfileExtensionBottom/src/main/java/com/googlesource/gerrit/plugins/examples/wuiprofileextensionbottom/client/ExamplePlugin.java
@@ -18,12 +18,7 @@ import com.google.gerrit.client.Resources; import com.google.gerrit.plugin.client.Plugin; import com.google.gerrit.plugin.client.PluginEntryPoint; -import com.google.gerrit.plugin.client.extension.Panel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; public class ExamplePlugin extends PluginEntryPoint { public static final Resources RESOURCES = GWT.create(Resources.class); @@ -32,6 +27,8 @@ public void onPluginLoad() { Plugin.get() .panel( - GerritUiExtensionPoint.PROFILE_SCREEN_BOTTOM, new ExampleProfileExtension.Factory()); + GerritUiExtensionPoint.PROFILE_SCREEN_BOTTOM, + new ExampleProfileExtension.Factory(), + "account_info"); } }
diff --git a/example-wuiSettingsScreen/WORKSPACE b/example-wuiSettingsScreen/WORKSPACE index dc23cfb..b79bf1c 100644 --- a/example-wuiSettingsScreen/WORKSPACE +++ b/example-wuiSettingsScreen/WORKSPACE
@@ -3,7 +3,7 @@ load("//:bazlets.bzl", "load_bazlets") load_bazlets( - commit = "e48c6a61d5a3f9ab4589f324fc85b8e3777d8854", + commit = "ec949feac1b9dae6cc2c8c25d254f34924c54296", # local_path = "/home/<user>/projects/bazlets", )
diff --git a/example-wuiSettingsScreen/pom.xml b/example-wuiSettingsScreen/pom.xml index 90bb4a2..e92d839 100644 --- a/example-wuiSettingsScreen/pom.xml +++ b/example-wuiSettingsScreen/pom.xml
@@ -22,7 +22,7 @@ <groupId>com.googlesource.gerrit.plugins</groupId> <artifactId>example-wuiSettingsScreen</artifactId> <packaging>jar</packaging> - <version>2.14.20</version> + <version>2.15-SNAPSHOT</version> <properties> <Gerrit-ApiType>plugin</Gerrit-ApiType> <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
diff --git a/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/Module.java b/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/Module.java index c17232d..bb203d2 100644 --- a/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/Module.java +++ b/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/Module.java
@@ -16,9 +16,7 @@ import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.webui.GwtPlugin; -import com.google.gerrit.extensions.webui.JavaScriptPlugin; import com.google.gerrit.extensions.webui.WebUiPlugin; -import com.google.gerrit.server.plugins.ServerPluginProvider; import com.google.inject.AbstractModule; public class Module extends AbstractModule {
diff --git a/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/client/ExamplePlugin.java b/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/client/ExamplePlugin.java index 292e649..c612751 100644 --- a/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/client/ExamplePlugin.java +++ b/example-wuiSettingsScreen/src/main/java/com/googlesource/gerrit/plugins/examples/wuisettingsscreen/client/ExamplePlugin.java
@@ -14,16 +14,10 @@ package com.googlesource.gerrit.plugins.examples.wuisettingsscreen.client; -import com.google.gerrit.client.GerritUiExtensionPoint; import com.google.gerrit.client.Resources; import com.google.gerrit.plugin.client.Plugin; import com.google.gerrit.plugin.client.PluginEntryPoint; -import com.google.gerrit.plugin.client.extension.Panel; import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Button; public class ExamplePlugin extends PluginEntryPoint { public static final Resources RESOURCES = GWT.create(Resources.class);