Removed BUCK files and Buck related support scripts and other collateral.
Change-Id: Ic6debd17e2d9d2f1c8b894f816efaca2853e433f
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index 4b81a6f..6330fcb 100644
--- a/tools/build/bazel/generate_workspace.bzl
+++ b/tools/build/bazel/generate_workspace.bzl
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Wed, 14 Nov 2018 01:38:56 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Tue, 27 Nov 2018 19:36:00 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
diff --git a/tools/build/bazel/osgi_java_library.bzl b/tools/build/bazel/osgi_java_library.bzl
index bd68a30..b7a73cf 100644
--- a/tools/build/bazel/osgi_java_library.bzl
+++ b/tools/build/bazel/osgi_java_library.bzl
@@ -281,7 +281,7 @@
executable = True,
cfg = "host",
allow_files = True,
- default = Label("//tools/build/buck-plugin:swagger_generator"),
+ default = Label("//tools/build/swagger:swagger_generator"),
),
"swagger_java": attr.output(),
},
@@ -305,7 +305,7 @@
executable = True,
cfg = "host",
allow_files = True,
- default = Label("//tools/build/buck-plugin:swagger_generator"),
+ default = Label("//tools/build/swagger:swagger_generator"),
),
"swagger_json": attr.output(),
},
diff --git a/tools/build/buck-plugin/BUCK b/tools/build/buck-plugin/BUCK
deleted file mode 100644
index 8593941..0000000
--- a/tools/build/buck-plugin/BUCK
+++ /dev/null
@@ -1,46 +0,0 @@
-# Comment the remote_jar out for local buck development
-remote_jar (
- name = 'buck-api',
- out = 'buck.jar',
- url = 'https://oss.sonatype.org/content/repositories/snapshots/org/onosproject/buck-api/0.1-SNAPSHOT/buck-api-0.1-20161113.012708-6.jar',
- sha1 = 'da823563b03964eafc9ff76cd721b9253ae473a1',
- visibility = [],
-)
-
-# Uncomment the prebuilt_jar and copy buck-api to lib/buck.jar for local buck development
-# prebuilt_jar (
-# name = 'buck-api',
-# binary_jar = 'lib/buck.jar'
-# )
-
-# Use buck's guava version - 19.0
-remote_jar (
- name = 'guava',
- out = 'guava-19.0.jar',
- url = 'mvn:com.google.guava:guava:jar:19.0',
- sha1 = '6ce200f6b23222af3d8abb6b6459e6c44f4bb0e9',
- maven_coords = 'com.google.guava:guava:19.0',
-)
-
-COMPILE = [
- '//lib:qdox',
- ':guava',
- '//lib:bndlib',
- '//lib:org.apache.felix.scr.bnd'
-]
-
-java_library(
- name = 'lib',
- srcs = glob(['src/main/java/**/*.java']),
- resources = glob(['src/main/resources/**/*']),
- resources_root = 'src/main/resources',
- deps = COMPILE,
- provided_deps = [':buck-api'],
- visibility = [],
-)
-
-java_binary(
- name = 'onos',
- deps = [':lib'],
- visibility = ['PUBLIC'],
-)
diff --git a/tools/build/buck-plugin/buck-plugin-install b/tools/build/buck-plugin/buck-plugin-install
deleted file mode 100755
index 15cf0e6..0000000
--- a/tools/build/buck-plugin/buck-plugin-install
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-PLUGINS=$ONOS_ROOT/bin/plugins
-
-set -e
-
-# Build it first
-pluginJar=$(NO_BUCKD=1 onos-buck build //tools/build/buck-plugin:onos --no-cache --show-output | grep onos.jar | cut -d\ -f2)
-
-# Then install it
-mkdir -p $PLUGINS
-cp $ONOS_ROOT/$pluginJar $PLUGINS
-
-ls -l $PLUGINS
diff --git a/tools/build/buck-plugin/buck-plugin-test b/tools/build/buck-plugin/buck-plugin-test
deleted file mode 100755
index cb8fd76..0000000
--- a/tools/build/buck-plugin/buck-plugin-test
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-NO_BUCKD=1 onos-buck build //apps/dhcp/app:onos-apps-dhcp-app --no-cache --show-output
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java
deleted file mode 100644
index 86c6938..0000000
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OSGiWrapper.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.onosjar;
-
-import aQute.bnd.header.Attrs;
-import aQute.bnd.header.Parameters;
-import aQute.bnd.osgi.Analyzer;
-import aQute.bnd.osgi.Builder;
-import aQute.bnd.osgi.Constants;
-import aQute.bnd.osgi.Descriptors;
-import aQute.bnd.osgi.FileResource;
-import aQute.bnd.osgi.Jar;
-import aQute.bnd.osgi.Packages;
-import aQute.bnd.osgi.Processor;
-import aQute.bnd.osgi.Resource;
-import com.facebook.buck.step.ExecutionContext;
-import com.facebook.buck.step.Step;
-import com.facebook.buck.step.StepExecutionResult;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;
-import org.codehaus.plexus.util.DirectoryScanner;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.file.FileVisitResult;
-import java.nio.file.FileVisitor;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.jar.Manifest;
-import java.util.stream.Collectors;
-
-import static java.nio.file.Files.walkFileTree;
-
-/**
- * BND-based wrapper to convert Buck JARs to OSGi-compatible JARs.
- */
-public class OSGiWrapper implements Step {
-
- private static final String EMBED_DEPENDENCY = "Embed-Dependency";
- private static final String EMBEDDED_ARTIFACTS = "Embedded-Artifacts";
-
- private Path inputJar;
- private Path outputJar;
- private Path sourcesDir;
- private Path classesDir;
- private List<String> classpath;
-
- private String bundleName;
- private String groupId;
- private String bundleSymbolicName;
- private String bundleVersion;
-
- private String importPackages;
- private String privatePackages;
- private String dynamicimportPackages;
- private String embeddedDependencies;
-
- private String exportPackages;
- private String includeResources;
- private Set<String> includedResources = Sets.newHashSet();
-
- private String bundleDescription;
- private String bundleLicense;
-
- private String bundleClasspath;
-
- private String webContext;
-
- private PrintStream stderr = System.err;
-
- public OSGiWrapper(Path inputJar,
- Path outputJar,
- Path sourcesDir,
- Path classesDir,
- ImmutableSortedSet<Path> classpath,
- String bundleName,
- String groupId,
- String bundleVersion,
- String bundleLicense,
- String importPackages,
- String exportPackages,
- String includeResources,
- String webContext,
- String dynamicimportPackages,
- String embeddedDependencies,
- String bundleDescription,
- String privatePackages,
- String bundleClasspath) {
- this.inputJar = inputJar;
- this.sourcesDir = sourcesDir;
- this.classesDir = classesDir;
- this.classpath = Lists.newArrayList(
- classpath.stream().map(Path::toString).collect(Collectors.toList()));
- if (!this.classpath.contains(inputJar.toString())) {
- this.classpath.add(0, inputJar.toString());
- }
- this.outputJar = outputJar;
-
- this.bundleName = bundleName;
- this.groupId = groupId;
- this.bundleSymbolicName = String.format("%s.%s", groupId, bundleName);
-
- this.bundleVersion = bundleVersion;
- this.bundleLicense = bundleLicense;
- this.bundleDescription = bundleDescription;
-
- this.importPackages = importPackages;
- this.privatePackages = privatePackages;
- this.dynamicimportPackages = dynamicimportPackages;
- this.embeddedDependencies = embeddedDependencies;
- this.exportPackages = exportPackages;
- this.includeResources = includeResources;
-
- this.webContext = webContext;
-
- this.bundleClasspath = bundleClasspath;
- }
-
- private void setProperties(Analyzer analyzer) {
-
- analyzer.setProperty(Analyzer.BUNDLE_NAME, bundleName);
- analyzer.setProperty(Analyzer.BUNDLE_SYMBOLICNAME, bundleSymbolicName);
- analyzer.setProperty(Analyzer.BUNDLE_VERSION, bundleVersion.replace('-', '.'));
-
- if (bundleDescription != null) {
- analyzer.setProperty(Analyzer.BUNDLE_DESCRIPTION, bundleDescription);
- }
- if (bundleLicense != null) {
- analyzer.setProperty(Analyzer.BUNDLE_LICENSE, bundleLicense);
- }
-
- //TODO consider using stricter version policy
- //analyzer.setProperty("-provider-policy", "${range;[===,==+)}");
- //analyzer.setProperty("-consumer-policy", "${range;[===,==+)}");
-
- if (privatePackages != null) {
- analyzer.setProperty(Analyzer.PRIVATE_PACKAGE, privatePackages);
- }
- analyzer.setProperty(Analyzer.REMOVEHEADERS, "Private-Package,Include-Resource");
-
- analyzer.setProperty(Analyzer.DYNAMICIMPORT_PACKAGE,
- dynamicimportPackages);
-
- // TODO include version in export, but not in import
- analyzer.setProperty(Analyzer.EXPORT_PACKAGE, exportPackages);
-
- // TODO we may need INCLUDE_RESOURCE, or that might be done by Buck
- // FIXME NOTE we handle this manually below
- if (includeResources != null) {
- analyzer.setProperty(Analyzer.INCLUDE_RESOURCE, includeResources);
- }
-
- if (embeddedDependencies != null) {
- analyzer.setProperty(EMBED_DEPENDENCY, embeddedDependencies);
- }
-
- // There are no good defaults so make sure you set the Import-Package
- analyzer.setProperty(Analyzer.IMPORT_PACKAGE, importPackages);
-
- if (isWab()) {
- analyzer.setProperty(Analyzer.WAB, "src/main/webapp/");
- analyzer.setProperty("Web-ContextPath", webContext);
- analyzer.setProperty(Analyzer.IMPORT_PACKAGE, importPackages +
- ",org.glassfish.jersey.servlet,org.jvnet.mimepull\n");
- }
- }
-
- public boolean execute() {
- Builder analyzer = new Builder();
- try {
-
- Jar jar = new Jar(inputJar.toFile()); // where our data is
- analyzer.setJar(jar); // give bnd the contents
-
- // You can provide additional class path entries to allow
- // bnd to pickup export version from the packageinfo file,
- // Version annotation, or their manifests.
- analyzer.addClasspath(classpath);
-
- setProperties(analyzer);
-
- // Analyze the target JAR first
- analyzer.analyze();
-
- // Scan the JAR for Felix SCR annotations and generate XML files
- Map<String, String> properties = Maps.newHashMap();
- properties.put("destdir", classesDir.toAbsolutePath().toString());
- SCRDescriptorBndPlugin scrDescriptorBndPlugin = new SCRDescriptorBndPlugin();
- scrDescriptorBndPlugin.setProperties(properties);
- scrDescriptorBndPlugin.setReporter(analyzer);
- scrDescriptorBndPlugin.analyzeJar(analyzer);
-
- //Add local packges to jar file.
- //FIXME removing this call for now; not sure what exactly it's doing
- //addLocalPackages(new File(classesDir.toString()), analyzer);
-
- //add resources.
- if (includeResources != null || embeddedDependencies != null) {
- doIncludeResources(analyzer);
- }
-
- // Repack the JAR as a WAR
- doWabStaging(analyzer);
-
- // Calculate the manifest
- Manifest manifest = analyzer.calcManifest();
-
- //Build the jar files
- //FIXME this call conflicts with some of the above
-// analyzer.build();
-
- if (analyzer.isOk()) {
- //add calculated manifest file.
- analyzer.getJar().setManifest(manifest);
- if (analyzer.save(outputJar.toFile(), true)) {
- log("Saved!\n");
- } else {
- warn("Failed to create jar \n");
- return false;
- }
- } else {
- warn("Analyzer Errors:\n%s\n", analyzer.getErrors());
- return false;
- }
-
- analyzer.close();
-
- return true;
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- }
-
- private static void addLocalPackages(File outputDirectory, Analyzer analyzer) throws IOException {
- Packages packages = new Packages();
-
- if (outputDirectory != null && outputDirectory.isDirectory()) {
- // scan classes directory for potential packages
- DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir(outputDirectory);
- scanner.setIncludes(new String[]
- {"**/*.class"});
-
- scanner.addDefaultExcludes();
- scanner.scan();
-
- String[] paths = scanner.getIncludedFiles();
- for (int i = 0; i < paths.length; i++) {
- packages.put(analyzer.getPackageRef(getPackageName(paths[i])));
- }
- }
-
- Packages exportedPkgs = new Packages();
- Packages privatePkgs = new Packages();
-
- boolean noprivatePackages = "!*".equals(analyzer.getProperty(Analyzer.PRIVATE_PACKAGE));
-
- for (Descriptors.PackageRef pkg : packages.keySet()) {
- // mark all source packages as private by default (can be overridden by export list)
- privatePkgs.put(pkg);
-
- // we can't export the default package (".") and we shouldn't export internal packages
- String fqn = pkg.getFQN();
- if (noprivatePackages || !(".".equals(fqn) || fqn.contains(".internal") || fqn.contains(".impl"))) {
- exportedPkgs.put(pkg);
- }
- }
-
- Properties properties = analyzer.getProperties();
- String exported = properties.getProperty(Analyzer.EXPORT_PACKAGE);
- if (exported == null) {
- if (!properties.containsKey(Analyzer.EXPORT_CONTENTS)) {
- // no -exportcontents overriding the exports, so use our computed list
- for (Attrs attrs : exportedPkgs.values()) {
- attrs.put(Constants.SPLIT_PACKAGE_DIRECTIVE, "merge-first");
- }
- properties.setProperty(Analyzer.EXPORT_PACKAGE, Processor.printClauses(exportedPkgs));
- } else {
- // leave Export-Package empty (but non-null) as we have -exportcontents
- properties.setProperty(Analyzer.EXPORT_PACKAGE, "");
- }
- }
-
- String internal = properties.getProperty(Analyzer.PRIVATE_PACKAGE);
- if (internal == null) {
- if (!privatePkgs.isEmpty()) {
- for (Attrs attrs : privatePkgs.values()) {
- attrs.put(Constants.SPLIT_PACKAGE_DIRECTIVE, "merge-first");
- }
- properties.setProperty(Analyzer.PRIVATE_PACKAGE, Processor.printClauses(privatePkgs));
- } else {
- // if there are really no private packages then use "!*" as this will keep the Bnd Tool happy
- properties.setProperty(Analyzer.PRIVATE_PACKAGE, "!*");
- }
- }
- }
-
- private static String getPackageName(String filename) {
- int n = filename.lastIndexOf(File.separatorChar);
- return n < 0 ? "." : filename.substring(0, n).replace(File.separatorChar, '.');
- }
-
- private boolean isWab() {
- return webContext != null;
- }
-
- private void doWabStaging(Analyzer analyzer) throws Exception {
- if (!isWab()) {
- return;
- }
- String wab = analyzer.getProperty(analyzer.WAB);
- Jar dot = analyzer.getJar();
-
- log("wab %s", wab);
-
- if (bundleClasspath != null) {
- analyzer.setBundleClasspath("WEB-INF/classes," + bundleClasspath);
- }
-
- Set<String> paths = new HashSet<>(dot.getResources().keySet());
-
- for (String path : paths) {
- if (path.indexOf('/') > 0 && !Character.isUpperCase(path.charAt(0))) {
- log("wab: moving: %s", path);
- dot.rename(path, "WEB-INF/classes/" + path);
- }
- }
-
- Path wabRoot = Paths.get(wab);
- includeFiles(dot, null, wabRoot.toString());
- }
-
- /**
- * Parse the Bundle-Includes header. Files in the bundles Include header are
- * included in the jar. The source can be a directory or a file.
- *
- * @throws Exception
- */
- private void doIncludeResources(Analyzer analyzer) throws Exception {
- String includes = analyzer.getProperty(Analyzer.INCLUDE_RESOURCE);
- if (includes == null) {
- return;
- }
- Parameters clauses = analyzer.parseHeader(includes);
- Jar jar = analyzer.getJar();
-
- for (Map.Entry<String, Attrs> entry : clauses.entrySet()) {
- String name = entry.getKey();
- Map<String, String> extra = entry.getValue();
- // TODO consider doing something with extras
-
- String[] parts = name.split("\\s*=\\s*");
- String source = parts[0];
- String destination = parts[0];
- if (parts.length == 2) {
- source = parts[1];
- }
-
- includeFiles(jar, destination, source);
- }
- }
-
- private void includeFiles(Jar jar, String destinationRoot, String sourceRoot)
- throws IOException {
-
- Path classesBasedPath = classesDir.resolve(sourceRoot);
- Path sourceBasedPath = sourcesDir.resolve(sourceRoot);
-
- File classFile = classesBasedPath.toFile();
- File sourceFile = sourceBasedPath.toFile();
-
- if (classFile.isFile()) {
- addFileToJar(jar, destinationRoot, classesBasedPath.toAbsolutePath().toString());
- } else if (sourceFile.isFile()) {
- addFileToJar(jar, destinationRoot, sourceBasedPath.toAbsolutePath().toString());
- } else if (classFile.isDirectory()) {
- includeDirectory(jar, destinationRoot, classesBasedPath);
- } else if (sourceFile.isDirectory()) {
- includeDirectory(jar, destinationRoot, sourceBasedPath);
- } else {
- warn("Skipping resource in bundle %s: %s (File Not Found)\n",
- bundleSymbolicName, sourceRoot);
- }
- }
-
- private void includeDirectory(Jar jar, String destinationRoot, Path sourceRoot)
- throws IOException {
- // iterate through sources
- // put each source on the jar
- FileVisitor<Path> visitor = new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Path relativePath = sourceRoot.relativize(file);
- String destination = destinationRoot != null ?
- destinationRoot + "/" + relativePath.toString() : //TODO
- relativePath.toString();
-
- addFileToJar(jar, destination, file.toAbsolutePath().toString());
- return FileVisitResult.CONTINUE;
- }
- };
-
- walkFileTree(sourceRoot, visitor);
- }
-
- private boolean addFileToJar(Jar jar, String destination, String sourceAbsPath) {
- if (includedResources.contains(sourceAbsPath)) {
- log("Skipping already included resource: %s\n", sourceAbsPath);
- return false;
- }
- File file = new File(sourceAbsPath);
- if (!file.isFile()) {
- throw new RuntimeException(
- String.format("Skipping non-existent file: %s\n", sourceAbsPath));
- }
- Resource resource = new FileResource(file);
- if (jar.getResource(destination) != null) {
- warn("Skipping duplicate resource: %s\n", destination);
- return false;
- }
- jar.putResource(destination, resource);
- includedResources.add(sourceAbsPath);
- log("Adding resource: %s\n", destination);
- return true;
- }
-
- private void log(String format, Object... objects) {
- //System.err.printf(format, objects);
- }
-
- private void warn(String format, Object... objects) {
- stderr.printf(format, objects);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("inputJar", inputJar)
- .add("outputJar", outputJar)
- .add("classpath", classpath)
- .add("bundleName", bundleName)
- .add("groupId", groupId)
- .add("bundleSymbolicName", bundleSymbolicName)
- .add("bundleVersion", bundleVersion)
- .add("bundleDescription", bundleDescription)
- .add("bundleLicense", bundleLicense)
- .toString();
- }
-
- @Override
- public StepExecutionResult execute(ExecutionContext executionContext)
- throws IOException, InterruptedException {
- stderr = executionContext.getStdErr();
- boolean success = execute();
- stderr = System.err;
- return success ? StepExecutionResult.SUCCESS : StepExecutionResult.ERROR;
- }
-
- @Override
- public String getShortName() {
- return "osgiwrap";
- }
-
- @Override
- public String getDescription(ExecutionContext executionContext) {
- return "osgiwrap"; //FIXME
- }
-}
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJar.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJar.java
deleted file mode 100644
index b9ec3d6..0000000
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJar.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.onosjar;
-
-import com.facebook.buck.jvm.java.CompileToJarStepFactory;
-import com.facebook.buck.jvm.java.DefaultJavaLibrary;
-import com.facebook.buck.jvm.java.HasMavenCoordinates;
-import com.facebook.buck.jvm.java.JavaLibrary;
-import com.facebook.buck.jvm.java.MavenPublishable;
-import com.facebook.buck.model.BuildTarget;
-import com.facebook.buck.rules.AddToRuleKey;
-import com.facebook.buck.rules.BuildRule;
-import com.facebook.buck.rules.BuildRuleParams;
-import com.facebook.buck.rules.SourcePath;
-import com.facebook.buck.rules.SourcePathResolver;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedMap;
-import com.google.common.collect.ImmutableSortedSet;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.net.URL;
-import java.nio.file.Path;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Implementation of a build rule that generates a onosjar.json file for a set
- * of Java sources.
- */
-public class OnosJar extends DefaultJavaLibrary
- implements MavenPublishable{
-
- // Inject the SHA of this rule's jar into the rule key
- private static String RULE_VERSION;
- static {
- URL pluginJarLocation = OnosJar.class.getProtectionDomain().getCodeSource().getLocation();
- try {
- MessageDigest md = MessageDigest.getInstance("SHA");
- DigestInputStream dis = new DigestInputStream(pluginJarLocation.openStream(), md);
- // Consume the InputStream...
- while (dis.read() != -1);
- RULE_VERSION = String.format("%032x", new BigInteger(1, md.digest()));
- } catch (NoSuchAlgorithmException | IOException e) {
- System.err.println("Failed to compute hash for OnosJar rule");
- RULE_VERSION = "nil";
- //TODO consider bailing here instead
- }
- }
- @AddToRuleKey
- private final String ruleVersion = RULE_VERSION;
-
- @AddToRuleKey
- final Optional<String> webContext;
-
- @AddToRuleKey
- final Optional<String> apiTitle;
-
- @AddToRuleKey
- final Optional<String> apiVersion;
-
- @AddToRuleKey
- final Optional<String> apiPackage;
-
- @AddToRuleKey
- final Optional<String> apiDescription;
-
- @AddToRuleKey
- final Optional<ImmutableSortedMap<String, SourcePath>> includedResources;
-
- private final ImmutableSortedSet<HasMavenCoordinates> mavenDeps;
-
- public OnosJar(BuildRuleParams params,
- SourcePathResolver resolver,
- Set<? extends SourcePath> srcs,
- Set<? extends SourcePath> resources,
- Optional<Path> generatedSourceFolder,
- Optional<SourcePath> proguardConfig,
- ImmutableList<String> postprocessClassesCommands,
- ImmutableSortedSet<BuildRule> exportedDeps,
- ImmutableSortedSet<BuildRule> providedDeps,
- SourcePath abiJar, boolean trackClassUsage,
- ImmutableSet<Path> additionalClasspathEntries,
- CompileToJarStepFactory compileStepFactory,
- Optional<Path> resourcesRoot,
- Optional<SourcePath> manifestFile,
- Optional<String> mavenCoords,
- ImmutableSortedSet<BuildTarget> tests,
- ImmutableSet<Pattern> classesToRemoveFromJar,
- Optional<String> webContext,
- Optional<String> apiTitle,
- Optional<String> apiVersion,
- Optional<String> apiPackage,
- Optional<String> apiDescription,
- Optional<ImmutableSortedMap<String, SourcePath>> includedResources) {
- super(params, resolver, srcs, resources, generatedSourceFolder,
- proguardConfig, postprocessClassesCommands, exportedDeps,
- providedDeps, abiJar, trackClassUsage, additionalClasspathEntries,
- compileStepFactory, resourcesRoot, manifestFile, mavenCoords,
- tests, classesToRemoveFromJar);
- this.webContext = webContext;
- this.apiTitle = apiTitle;
- this.apiVersion = apiVersion;
- this.apiPackage = apiPackage;
- this.apiDescription = apiDescription;
- this.includedResources = includedResources;
- this.mavenDeps = computeMavenDeps();
- }
-
- private ImmutableSortedSet<HasMavenCoordinates> computeMavenDeps() {
- ImmutableSortedSet.Builder<HasMavenCoordinates> mavenDeps = ImmutableSortedSet.naturalOrder();
- for (JavaLibrary javaLibrary : getTransitiveClasspathDeps()) {
- if (this.equals(javaLibrary)) {
- // no need to include ourself
- continue;
- } else if (HasMavenCoordinates.MAVEN_COORDS_PRESENT_PREDICATE.apply(javaLibrary)) {
- mavenDeps.add(javaLibrary);
- //FIXME BOC do we always want to exclude all of a maven jar's dependencies? probably.
- mavenDeps.addAll(javaLibrary.getTransitiveClasspathDeps());
- }
- }
- return mavenDeps.build();
- }
-
- @Override
- public Iterable<HasMavenCoordinates> getMavenDeps() {
- return mavenDeps;
- }
-
- @Override
- public Iterable<BuildRule> getPackagedDependencies() {
- //FIXME this is not supported at the moment
- return ImmutableList.of();
- }
-
- @Override
- public Optional<Path> getPomTemplate() {
- //FIXME we should consider supporting this
- return Optional.absent();
- }
-}
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java
deleted file mode 100644
index 3f27760..0000000
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarDescription.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.onosjar;
-
-import com.facebook.buck.cli.BuckConfig;
-import com.facebook.buck.jvm.java.CalculateAbi;
-import com.facebook.buck.jvm.java.DefaultJavaLibrary;
-import com.facebook.buck.jvm.java.JavaBuckConfig;
-import com.facebook.buck.jvm.java.JavaLibrary;
-import com.facebook.buck.jvm.java.JavaLibraryDescription;
-import com.facebook.buck.jvm.java.JavaOptions;
-import com.facebook.buck.jvm.java.JavaSourceJar;
-import com.facebook.buck.jvm.java.JavacOptions;
-import com.facebook.buck.jvm.java.JavacOptionsAmender;
-import com.facebook.buck.jvm.java.JavacOptionsFactory;
-import com.facebook.buck.jvm.java.JavacToJarStepFactory;
-import com.facebook.buck.jvm.java.JavadocJar;
-import com.facebook.buck.jvm.java.MavenUberJar;
-import com.facebook.buck.maven.AetherUtil;
-import com.facebook.buck.model.BuildTarget;
-import com.facebook.buck.model.Flavor;
-import com.facebook.buck.model.Flavored;
-import com.facebook.buck.model.ImmutableFlavor;
-import com.facebook.buck.parser.NoSuchBuildTargetException;
-import com.facebook.buck.rules.BuildRule;
-import com.facebook.buck.rules.BuildRuleParams;
-import com.facebook.buck.rules.BuildRuleResolver;
-import com.facebook.buck.rules.BuildRuleType;
-import com.facebook.buck.rules.BuildRules;
-import com.facebook.buck.rules.BuildTargetSourcePath;
-import com.facebook.buck.rules.Description;
-import com.facebook.buck.rules.SourcePath;
-import com.facebook.buck.rules.SourcePathResolver;
-import com.facebook.buck.rules.SourcePaths;
-import com.facebook.buck.rules.TargetGraph;
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedMap;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-import java.nio.file.Path;
-import java.util.List;
-
-import static com.facebook.buck.jvm.common.ResourceValidator.validateResources;
-
-/**
- * Description for the onos_jar rules.
- *
- * Currently, this only does Swagger generation.
- */
-public class OnosJarDescription implements Description<OnosJarDescription.Arg>, Flavored {
- public static final BuildRuleType TYPE = BuildRuleType.of("onos_jar");
- public static final Flavor NON_OSGI_JAR = ImmutableFlavor.of("non-osgi");
-
- public static final ImmutableSet<Flavor> SUPPORTED_FLAVORS = ImmutableSet.of(
- JavaLibrary.SRC_JAR,
- JavaLibrary.MAVEN_JAR,
- JavaLibrary.JAVADOC_JAR,
- NON_OSGI_JAR);
-
- private final JavacOptions defaultJavacOptions;
- private final JavaOptions defaultJavaOptions;
-
- public OnosJarDescription(BuckConfig config) {
- JavaBuckConfig javaConfig = new JavaBuckConfig(config);
- defaultJavacOptions = javaConfig.getDefaultJavacOptions();
- defaultJavaOptions = javaConfig.getDefaultJavaOptions();
- }
-
- @Override
- public BuildRuleType getBuildRuleType() {
- return TYPE;
- }
-
- @Override
- public Arg createUnpopulatedConstructorArg() {
- return new Arg();
- }
-
- @Override
- public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph,
- BuildRuleParams params,
- BuildRuleResolver resolver,
- A args)
- throws NoSuchBuildTargetException {
-
-
- SourcePathResolver pathResolver = new SourcePathResolver(resolver);
- BuildTarget target = params.getBuildTarget();
-
- // We know that the flavour we're being asked to create is valid, since the check is done when
- // creating the action graph from the target graph.
-
- ImmutableSortedSet<Flavor> flavors = target.getFlavors();
- BuildRuleParams paramsWithMavenFlavor = null;
-
- if (flavors.contains(JavaLibrary.MAVEN_JAR)) {
- paramsWithMavenFlavor = params;
-
- // Maven rules will depend upon their vanilla versions, so the latter have to be constructed
- // without the maven flavor to prevent output-path conflict
- params = params.copyWithBuildTarget(
- params.getBuildTarget().withoutFlavors(ImmutableSet.of(JavaLibrary.MAVEN_JAR)));
- }
-
- if (flavors.contains(JavaLibrary.SRC_JAR)) {
- args.mavenCoords = args.mavenCoords.transform(
- new Function<String, String>() {
- @Override
- public String apply(String input) {
- return AetherUtil.addClassifier(input, AetherUtil.CLASSIFIER_SOURCES);
- }
- });
-
- if (!flavors.contains(JavaLibrary.MAVEN_JAR)) {
- return new JavaSourceJar(
- params,
- pathResolver,
- args.srcs.get(),
- args.mavenCoords);
- } else {
- return MavenUberJar.SourceJar.create(
- Preconditions.checkNotNull(paramsWithMavenFlavor),
- pathResolver,
- args.srcs.get(),
- args.mavenCoords,
- Optional.absent()); //FIXME
- }
- }
-
- if (flavors.contains(JavaLibrary.JAVADOC_JAR)) {
- args.mavenCoords = args.mavenCoords.transform(
- new Function<String, String>() {
- @Override
- public String apply(String input) {
- return AetherUtil.addClassifier(input, AetherUtil.CLASSIFIER_JAVADOC);
- }
- });
-
- JavadocJar.JavadocArgs.Builder javadocArgs = JavadocJar.JavadocArgs.builder()
- .addArg("-windowtitle", target.getShortName())
- .addArg("-link", "http://docs.oracle.com/javase/8/docs/api")
- .addArg("-tag", "onos.rsModel:a:\"onos model\""); //FIXME from buckconfig + rule
-
- final ImmutableSortedMap.Builder<SourcePath, Path> javadocFiles = ImmutableSortedMap.naturalOrder();
- if (args.javadocFiles.isPresent()) {
- for (SourcePath path : args.javadocFiles.get()) {
- javadocFiles.put(path,
- JavadocJar.getDocfileWithPath(pathResolver, path, args.javadocFilesRoot.orNull()));
- }
- }
-
-
- if (!flavors.contains(JavaLibrary.MAVEN_JAR)) {
- return new JavadocJar(
- params,
- pathResolver,
- args.srcs.get(),
- javadocFiles.build(),
- javadocArgs.build(),
- args.mavenCoords);
- } else {
- return MavenUberJar.MavenJavadocJar.create(
- Preconditions.checkNotNull(paramsWithMavenFlavor),
- pathResolver,
- args.srcs.get(),
- javadocFiles.build(),
- javadocArgs.build(),
- args.mavenCoords,
- Optional.absent()); //FIXME
- }
- }
-
- JavacOptions javacOptions = JavacOptionsFactory.create(
- defaultJavacOptions,
- params,
- resolver,
- pathResolver,
- args
- );
-
- BuildTarget abiJarTarget = params.getBuildTarget().withAppendedFlavors(CalculateAbi.FLAVOR);
-
- ImmutableSortedSet<BuildRule> exportedDeps = resolver.getAllRules(args.exportedDeps.get());
-
- // Build the resources string
- List<String> resourceMappings = Lists.newArrayList();
-
- if (args.includeResources.isPresent()) {
- args.includeResources.get().entrySet().forEach(p ->
- resourceMappings.add(String.format("%s=%s", p.getKey(), p.getValue())));
- }
-
- if (args.apiTitle.isPresent()) {
- resourceMappings.add("WEB-INF/classes/apidoc/swagger.json=swagger.json");
- }
-
- Optional<String> includedResourcesString = Optional.of(String.join(",", resourceMappings));
- final DefaultJavaLibrary defaultJavaLibrary;
- if (!flavors.contains(NON_OSGI_JAR)) {
- defaultJavaLibrary =
- resolver.addToIndex(
- new OnosJar(
- params.appendExtraDeps(
- Iterables.concat(
- BuildRules.getExportedRules(
- Iterables.concat(
- params.getDeclaredDeps().get(),
- exportedDeps,
- resolver.getAllRules(args.providedDeps.get()))),
- pathResolver.filterBuildRuleInputs(
- javacOptions.getInputs(pathResolver)))),
- pathResolver,
- args.srcs.get(),
- validateResources(
- pathResolver,
- params.getProjectFilesystem(),
- args.resources.get()),
- javacOptions.getGeneratedSourceFolderName(),
- args.proguardConfig.transform(
- SourcePaths.toSourcePath(params.getProjectFilesystem())),
- args.postprocessClassesCommands.get(), // FIXME this should be forbidden
- exportedDeps,
- resolver.getAllRules(args.providedDeps.get()),
- new BuildTargetSourcePath(abiJarTarget),
- javacOptions.trackClassUsage(),
- /* additionalClasspathEntries */ ImmutableSet.<Path>of(),
- new OnosJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY,
- args.webContext, args.apiTitle, args.apiVersion,
- args.apiPackage, args.apiDescription, args.resources,
- args.groupId, args.bundleName, args.bundleVersion,
- args.bundleLicense, args.bundleDescription, args.importPackages,
- args.exportPackages, includedResourcesString,
- args.dynamicimportPackages, args.privatePackages, args.embeddedDependencies, args.bundleClasspath),
- args.resourcesRoot,
- args.manifestFile,
- args.mavenCoords,
- args.tests.get(),
- javacOptions.getClassesToRemoveFromJar(),
- args.webContext,
- args.apiTitle,
- args.apiVersion,
- args.apiPackage,
- args.apiDescription,
- args.includeResources));
- } else {
- defaultJavaLibrary =
- resolver.addToIndex(
- new DefaultJavaLibrary(
- params.appendExtraDeps(
- Iterables.concat(
- BuildRules.getExportedRules(
- Iterables.concat(
- params.getDeclaredDeps().get(),
- exportedDeps,
- resolver.getAllRules(args.providedDeps.get()))),
- pathResolver.filterBuildRuleInputs(
- javacOptions.getInputs(pathResolver)))),
- pathResolver,
- args.srcs.get(),
- validateResources(
- pathResolver,
- params.getProjectFilesystem(),
- args.resources.get()),
- javacOptions.getGeneratedSourceFolderName(),
- args.proguardConfig.transform(
- SourcePaths.toSourcePath(params.getProjectFilesystem())),
- args.postprocessClassesCommands.get(),
- exportedDeps,
- resolver.getAllRules(args.providedDeps.get()),
- new BuildTargetSourcePath(abiJarTarget),
- javacOptions.trackClassUsage(),
- /* additionalClasspathEntries */ ImmutableSet.<Path>of(),
- new JavacToJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY),
- args.resourcesRoot,
- args.manifestFile,
- args.mavenCoords,
- args.tests.get(),
- javacOptions.getClassesToRemoveFromJar()));
- }
-
- resolver.addToIndex(
- CalculateAbi.of(
- abiJarTarget,
- pathResolver,
- params,
- new BuildTargetSourcePath(defaultJavaLibrary.getBuildTarget())));
-
- return defaultJavaLibrary;
- }
-
- @Override
- public boolean hasFlavors(ImmutableSet<Flavor> flavors) {
- return SUPPORTED_FLAVORS.containsAll(flavors);
- }
-
- public static class Arg extends JavaLibraryDescription.Arg {
- public Optional<String> webContext;
- public Optional<String> apiTitle;
- public Optional<String> apiVersion;
- public Optional<String> apiPackage;
- public Optional<String> apiDescription;
-
- public Optional<String> groupId;
- public Optional<String> bundleName;
- public Optional<String> bundleVersion;
- public Optional<String> bundleLicense;
- public Optional<String> bundleDescription;
-
- public Optional<String> importPackages;
- public Optional<String> privatePackages;
- public Optional<String> exportPackages;
- public Optional<ImmutableSortedMap<String, SourcePath>> includeResources;
- public Optional<String> dynamicimportPackages;
- public Optional<String> embeddedDependencies;
- public Optional<String> bundleClasspath;
- }
-}
\ No newline at end of file
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java
deleted file mode 100644
index 6550d89..0000000
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/OnosJarStepFactory.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.onosjar;
-
-import com.facebook.buck.io.ProjectFilesystem;
-import com.facebook.buck.jvm.core.SuggestBuildRules;
-import com.facebook.buck.jvm.java.ClassUsageFileWriter;
-import com.facebook.buck.jvm.java.JarDirectoryStep;
-import com.facebook.buck.jvm.java.JavacOptions;
-import com.facebook.buck.jvm.java.JavacOptionsAmender;
-import com.facebook.buck.jvm.java.JavacToJarStepFactory;
-import com.facebook.buck.model.BuildTarget;
-import com.facebook.buck.rules.BuildContext;
-import com.facebook.buck.rules.BuildableContext;
-import com.facebook.buck.rules.SourcePath;
-import com.facebook.buck.rules.SourcePathResolver;
-import com.facebook.buck.step.Step;
-import com.facebook.buck.step.fs.CopyStep;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedSet;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-/**
- * Creates the list of build steps for the onos_jar rules.
- */
-public class OnosJarStepFactory extends JavacToJarStepFactory {
-
- private static final String DEFINITIONS = "/definitions/";
- private final String webContext;
- private final String apiTitle;
- private final String apiVersion;
- private final String apiPackage;
- private final String apiDescription;
- private final Optional<ImmutableSortedSet<SourcePath>> resources;
- private final String groupId;
- private final String bundleName;
- private final String bundleVersion;
- private final String bundleLicense;
- private final String bundleDescription;
- private final String importPackages;
- private final String privatePackages;
- private final String exportPackages;
- private final String includeResources;
- private final String dynamicimportPackages;
- private final String embeddedDependencies;
- private final String bundleClasspath;
-
- public OnosJarStepFactory(JavacOptions javacOptions,
- JavacOptionsAmender amender,
- Optional<String> webContext,
- Optional<String> apiTitle,
- Optional<String> apiVersion,
- Optional<String> apiPackage,
- Optional<String> apiDescription,
- Optional<ImmutableSortedSet<SourcePath>> resources,
- Optional<String> groupId,
- Optional<String> bundleName,
- Optional<String> bundleVersion,
- Optional<String> bundleLicense,
- Optional<String> bundleDescription,
- Optional<String> importPackages,
- Optional<String> exportPackages,
- Optional<String> includeResources,
- Optional<String> dynamicimportPackages,
- Optional<String> privatePackages,
- Optional<String> embeddedDependencies,
- Optional<String> bundleClasspath) {
- super(javacOptions, amender);
- this.bundleDescription = processParameter(bundleDescription);
- this.importPackages = processParameter(importPackages);
- this.privatePackages = processParameter(privatePackages);
- this.exportPackages = processParameter(exportPackages);
- this.includeResources = processParameter(includeResources);
- this.dynamicimportPackages = processParameter(dynamicimportPackages);
- this.groupId = processParameter(groupId);
- this.bundleName = processParameter(bundleName);
- this.bundleVersion = processParameter(bundleVersion);
- this.bundleLicense = processParameter(bundleLicense);
- this.webContext = processParameter(webContext);
- this.apiTitle = processParameter(apiTitle);
- this.apiVersion = processParameter(apiVersion);
- this.apiPackage = processParameter(apiPackage);
- this.apiDescription = processParameter(apiDescription);
- this.resources = resources;
- this.embeddedDependencies = processParameter(embeddedDependencies);
- this.bundleClasspath = processParameter(bundleClasspath);
- }
-
- private String processParameter(Optional<String> p) {
- return !p.isPresent() || p.get().equals("NONE") ? null : p.get();
- }
-
- @Override
- public void createCompileToJarStep(BuildContext context,
- ImmutableSortedSet<Path> sourceFilePaths,
- BuildTarget invokingRule,
- SourcePathResolver resolver,
- ProjectFilesystem filesystem,
- ImmutableSortedSet<Path> declaredClasspathEntries,
- Path outputDirectory,
- Optional<Path> workingDirectory,
- Path pathToSrcsList,
- Optional<SuggestBuildRules> suggestBuildRules,
- ImmutableList<String> postprocessClassesCommands,
- ImmutableSortedSet<Path> entriesToJar,
- Optional<String> mainClass,
- Optional<Path> manifestFile,
- Path outputJar,
- ClassUsageFileWriter usedClassesFileWriter,
- ImmutableList.Builder<Step> steps,
- BuildableContext buildableContext,
- ImmutableSet<Pattern> classesToRemoveFromJar) {
-
- ImmutableSet.Builder<Path> sourceFilePathBuilder = ImmutableSet.builder();
- sourceFilePathBuilder.addAll(sourceFilePaths);
-
- ImmutableSet.Builder<Pattern> blacklistBuilder = ImmutableSet.builder();
- blacklistBuilder.addAll(classesToRemoveFromJar);
-
- // precompilation steps
- // - generate sources
- // add all generated sources ot pathToSrcsList
- if (webContext != null && apiTitle != null && resources.isPresent()) {
- ImmutableSortedSet<Path> resourceFilePaths = findSwaggerModelDefs(resolver, resources.get());
- blacklistBuilder.addAll(resourceFilePaths.stream()
- .map(rp -> Pattern.compile(rp.getFileName().toString(), Pattern.LITERAL))
- .collect(Collectors.toSet()));
- Path genSourcesOutput = workingDirectory.get();
-
- SwaggerStep swaggerStep = new SwaggerStep(filesystem, sourceFilePaths, resourceFilePaths,
- genSourcesOutput, outputDirectory,
- webContext, apiTitle, apiVersion,
- apiPackage, apiDescription);
- sourceFilePathBuilder.add(swaggerStep.apiRegistratorPath());
- steps.add(swaggerStep);
-
-// steps.addAll(sourceFilePaths.stream()
-// .filter(sp -> sp.startsWith("src/main/webapp/"))
-// .map(sp -> CopyStep.forFile(filesystem, sp, outputDirectory))
-// .iterator());
- }
-
- createCompileStep(context,
- ImmutableSortedSet.copyOf(sourceFilePathBuilder.build()),
- invokingRule,
- resolver,
- filesystem,
- declaredClasspathEntries,
- outputDirectory,
- workingDirectory,
- pathToSrcsList,
- suggestBuildRules,
- usedClassesFileWriter,
- steps,
- buildableContext);
-
- // post compilation steps
-
-
- // FIXME BOC: add mechanism to inject new Steps
- //context.additionalStepFactory(JavaStep.class);
-
- // build the jar
- steps.add(new JarDirectoryStep(filesystem,
- outputJar,
- ImmutableSortedSet.of(outputDirectory),
- mainClass.orNull(),
- manifestFile.orNull(),
- true,
- blacklistBuilder.build()));
-
- OSGiWrapper osgiStep = new OSGiWrapper(
- outputJar, //input jar
- outputJar, //Paths.get(outputJar.toString() + ".jar"), //output jar
- invokingRule.getBasePath(), // sources dir
- outputDirectory, // classes dir
- declaredClasspathEntries, // classpath
- bundleName, // bundle name
- groupId, // groupId
- bundleVersion, // bundle version
- bundleLicense, // bundle license
- importPackages, // import packages
- exportPackages, // export packages
- includeResources, // include resources
- webContext, // web context
- dynamicimportPackages, // dynamic import packages
- embeddedDependencies, // embedded dependencies
- bundleDescription, // bundle description
- privatePackages, // private packages
- bundleClasspath // bundle classpath
- );
- steps.add(osgiStep);
-
- //steps.add(CopyStep.forFile(filesystem, Paths.get(outputJar.toString() + ".jar"), outputJar));
-
- }
-
- private ImmutableSortedSet<Path> findSwaggerModelDefs(SourcePathResolver resolver,
- ImmutableSortedSet<SourcePath> resourcePaths) {
- if (resourcePaths == null) {
- return ImmutableSortedSet.of();
- }
- return ImmutableSortedSet.copyOf(resourcePaths.stream()
- .filter(sp -> sp.toString().contains(DEFINITIONS))
- .map(resolver::getRelativePath)
- .collect(Collectors.toList()));
- }
-}
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/ProjectJavadocDescription.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/ProjectJavadocDescription.java
deleted file mode 100644
index 12cf48e..0000000
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/ProjectJavadocDescription.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.onosjar;
-
-import com.facebook.buck.cli.BuckConfig;
-import com.facebook.buck.jvm.java.JavaLibrary;
-import com.facebook.buck.jvm.java.JavadocJar;
-import com.facebook.buck.model.BuildTarget;
-import com.facebook.buck.model.Flavor;
-import com.facebook.buck.model.Flavored;
-import com.facebook.buck.model.Pair;
-import com.facebook.buck.parser.NoSuchBuildTargetException;
-import com.facebook.buck.rules.BuildRule;
-import com.facebook.buck.rules.BuildRuleParams;
-import com.facebook.buck.rules.BuildRuleResolver;
-import com.facebook.buck.rules.BuildRuleType;
-import com.facebook.buck.rules.Description;
-import com.facebook.buck.rules.SourcePath;
-import com.facebook.buck.rules.SourcePathResolver;
-import com.facebook.buck.rules.TargetGraph;
-import com.google.common.base.Optional;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSortedMap;
-import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Ordering;
-
-import java.nio.file.Path;
-import java.util.Map;
-
-/**
- * Description for the onos_jar rules.
- *
- * Currently, this only does Swagger generation.
- */
-public class ProjectJavadocDescription implements Description<ProjectJavadocDescription.Arg>, Flavored {
- public static final BuildRuleType TYPE = BuildRuleType.of("project_javadoc");
-
- public ProjectJavadocDescription(BuckConfig config) {
- //TODO
- }
-
- @Override
- public BuildRuleType getBuildRuleType() {
- return TYPE;
- }
-
- @Override
- public Arg createUnpopulatedConstructorArg() {
- return new Arg();
- }
-
- @Override
- public <A extends Arg> BuildRule createBuildRule(TargetGraph targetGraph,
- BuildRuleParams params,
- BuildRuleResolver resolver,
- A args)
- throws NoSuchBuildTargetException {
-
- ImmutableSet.Builder<SourcePath> srcs = ImmutableSet.builder();
- ImmutableSet.Builder<BuildRule> deps = ImmutableSet.builder();
- ImmutableSortedMap.Builder<SourcePath, Path> docfiles = ImmutableSortedMap.naturalOrder();
- for(BuildTarget dep : args.deps) {
- BuildRule rule = resolver.requireRule(dep.withFlavors(JavaLibrary.JAVADOC_JAR));
- if (rule instanceof JavadocJar) {
- JavadocJar jarRule = (JavadocJar) rule;
- srcs.addAll(jarRule.getSources());
- deps.addAll(jarRule.getDeps());
- docfiles.putAll(jarRule.getDocFiles());
- } else {
- throw new RuntimeException("rule is not a javalib"); //FIXME
- }
- }
-
- BuildRuleParams newParams = params.copyWithDeps(
- Suppliers.ofInstance(
- FluentIterable.from(deps.build())
- .toSortedSet(Ordering.<BuildRule>natural())),
- Suppliers.ofInstance(ImmutableSortedSet.<BuildRule>of()));
-
- SourcePathResolver sourceResolver = new SourcePathResolver(resolver);
- ImmutableList.Builder<SourcePath> auxSources = ImmutableList.builder();
-
- JavadocJar.JavadocArgs.Builder javadocArgs = JavadocJar.JavadocArgs.builder()
- .addArg("-windowtitle", args.projectTitle)
- .addArg("-doctitle", args.projectTitle)
- .addArg("-link", "http://docs.oracle.com/javase/8/docs/api")
- .addArg("-tag", "onos.rsModel:a:\"onos model\""); //FIXME from buckconfig + rule
-
- if (args.groups.isPresent()) {
- for (Pair<String, ImmutableList<String>> pair : args.groups.get()) {
- javadocArgs.addArg("-group", pair.getFirst(), pair.getSecond());
- }
- }
-
- if (args.excludePackages.isPresent() &&
- !args.excludePackages.get().isEmpty()) {
- javadocArgs.addArg("-exclude", args.excludePackages.get());
- }
-
- if (args.overview.isPresent()) {
- javadocArgs.addArg("-overview",
- sourceResolver.getAbsolutePath(args.overview.get()).toString());
-
- }
-
- if (args.javadocFiles.isPresent()) {
- for (SourcePath path : args.javadocFiles.get()) {
- docfiles.put(path,
- JavadocJar.getDocfileWithPath(sourceResolver, path, args.javadocFilesRoot.orNull()));
- }
- }
-
-
- JavadocJar javadocJar = new JavadocJar(newParams,
- sourceResolver,
- ImmutableSortedSet.copyOf(srcs.build()),
- docfiles.build(),
- javadocArgs.build(),
- /* mavenCoords */ Optional.absent());
- return javadocJar;
-
- }
-
- @Override
- public boolean hasFlavors(ImmutableSet<Flavor> flavors) {
- return false;
- }
-
- public static class Arg {
- public ImmutableSortedSet<BuildTarget> deps;
- public String projectTitle;
-
- public Optional<SourcePath> overview;
- public Optional<ImmutableSortedSet<SourcePath>> javadocFiles;
- public Optional<Path> javadocFilesRoot;
-
- public Optional<ImmutableList<String>> excludePackages;
- public Optional<ImmutableList<Pair<String, ImmutableList<String>>>> groups;
- }
-}
\ No newline at end of file
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/SwaggerStep.java b/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/SwaggerStep.java
deleted file mode 100644
index cbb6e82..0000000
--- a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/SwaggerStep.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.onosjar;
-
-import com.facebook.buck.io.ProjectFilesystem;
-import com.facebook.buck.rules.SourcePathResolver;
-import com.facebook.buck.step.AbstractExecutionStep;
-import com.facebook.buck.step.ExecutionContext;
-import com.facebook.buck.step.StepExecutionResult;
-import com.google.common.collect.ImmutableSortedSet;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Buck build step to trigger SwaggerGenerator.
- */
-public class SwaggerStep extends AbstractExecutionStep {
-
- private final ProjectFilesystem filesystem;
-
- private final ImmutableSortedSet<Path> srcs;
- private final ImmutableSortedSet<Path> resources;
- private final Path genSourcesOutput;
- private final Path genResourcesOutput;
-
- private final String webContext;
- private final String apiTitle;
- private final String apiVersion;
- private final String apiPackage;
- private final String apiDescription;
-
-
- public SwaggerStep(ProjectFilesystem filesystem,
- ImmutableSortedSet<Path> srcs,
- ImmutableSortedSet<Path> resources,
- Path genSourcesOutput, Path genResourcesOutput,
- String webContext, String apiTitle, String apiVersion,
- String apiPackage, String apiDescription) {
- super("swagger");
- this.filesystem = filesystem;
- this.srcs = srcs;
- this.resources = resources;
- this.genSourcesOutput = genSourcesOutput;
- this.genResourcesOutput = genResourcesOutput;
- this.webContext = webContext;
- this.apiTitle = apiTitle;
- this.apiVersion = apiVersion;
- this.apiPackage = apiPackage;
- this.apiDescription = apiDescription;
- }
-
- @Override
- public StepExecutionResult execute(ExecutionContext executionContext)
- throws IOException, InterruptedException {
- try {
- List<File> srcFiles = srcs.stream()
- .map(src -> filesystem.resolve(src).toFile())
- .collect(Collectors.toList());
- List<File> resourceFiles = resources.stream()
- .map(rsrc -> filesystem.resolve(rsrc).toFile())
- .collect(Collectors.toList());
- new SwaggerGenerator(srcFiles, resourceFiles, null, null,
- filesystem.resolve(genSourcesOutput).toFile(),
- filesystem.resolve(genResourcesOutput).toFile(),
- webContext,
- apiTitle,
- apiVersion,
- apiPackage,
- apiDescription).execute();
-
- return StepExecutionResult.SUCCESS;
- } catch (Exception e) {
- e.printStackTrace();
- // FIXME print the exception
- return StepExecutionResult.ERROR;
- }
- }
-
- Path apiRegistratorPath() {
- return genSourcesOutput.resolve(SwaggerGenerator.apiRegistratorPath(apiPackage));
- }
-}
diff --git a/tools/build/buck-publish b/tools/build/buck-publish
deleted file mode 100755
index 01ed7d9..0000000
--- a/tools/build/buck-publish
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Build and publish the ONOS version of buck.
-# -----------------------------------------------------------------------------
-
-if [ $# -ne 3 -a $# -ne 4 ]; then
- echo "Usage: buck-publish-setup buck-branch onos-branch yang-branch [version] [--dry-run]"
- echo "For example, to build buck branch 11-11-2016, onos branch master, and onos-yang-tools master:"
- echo "buck-publish 11-11-2016 master master"
- exit 1
-fi
-
-if [ $# -eq 4 -a "${4}" != "--dry-run" ]; then
- echo "$4 is an invalid parameter - only --dry-run allowed"
- exit 1
-fi
-
-BUCK_BRANCH="$1"
-ONOS_BRANCH="$2"
-YANG_BRANCH="$3"
-
-if [ -z "$4" ]; then
- onos-release-prerequisites
-fi
-
-DIR=$(mktemp -d /tmp/buck-publish.XXXXX) || { echo "Failed to create temp file"; exit 1; }
-
-buck-publish-setup $BUCK_BRANCH $ONOS_BRANCH $YANG_BRANCH $DIR
-pushd $DIR && buck-publish-package $4 && popd
-cp $DIR/onos/tools/build/onos-buck $ONOS_ROOT/tools/build/onos-buck
-
-
diff --git a/tools/build/buck-publish-api b/tools/build/buck-publish-api
deleted file mode 100755
index e27f1d0..0000000
--- a/tools/build/buck-publish-api
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-BUCK_LOCAL_CONFIG=${BUCK_LOCAL_CONFIG:-$ONOS_ROOT/.buckconfig.local}
-MVN_REPO="https://oss.sonatype.org/content/repositories/snapshots"
-NO_BUCKD=1
-
-set -e
-set -x
-
-#FIXME if pwd != buck
-pushd buck
-
-# build buck
-scripts/create_tag.sh
-buck build buck --show-output
-
-# publish cli:main-fixed as buck-api
-cp $BUCK_LOCAL_CONFIG .
-buck publish //src/com/facebook/buck/cli:main-fixed \
- --remote-repo=https://oss.sonatype.org/content/repositories/snapshots/ \
- | tee ../api-publish.txt
-
-# Alternatively, we can deploy org.onosproject:buck-api with the following:
-#mvn deploy:deploy-file -DgroupId=org.onosproject -DartifactId=buck-api \
-# -Dversion=0.1-SNAPSHOT -DgeneratePom=true -Dpackaging=jar \
-# -DrepositoryId=snapshot -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-# -Dfile=buck-out/gen/src/com/facebook/buck/cli/main-fixed/main-fixed.jar
-
-#FIXME upload API to S3 for backup
-
-popd #buck
-
-SNAPSHOT_VERSION=$(cat api-publish.txt | grep "^org.onosproject:buck-api:jar" \
- | cut -d' ' -f1 | cut -d: -f4)
-BUCK_API_URL="$MVN_REPO/org/onosproject/buck-api/0.1-SNAPSHOT/buck-api-$SNAPSHOT_VERSION.jar"
-echo $BUCK_API_URL
-
-BUCK_API_SHA=$(shasum buck/buck-out/gen/src/com/facebook/buck/cli/main-fixed/main-fixed.jar | cut -d' ' -f1)
-echo $BUCK_API_SHA
-
-pushd onos
-sed -i "" -E "s#url =.*#url = '$BUCK_API_URL',#" tools/build/buck-plugin/BUCK
-sed -i "" -E "s#sha1 =.*#sha1 = '$BUCK_API_SHA',#" tools/build/buck-plugin/BUCK
-popd #onos
-
-#pushd onos-yang-tools
-#FIXME update version (assume 0.1-SNAPSHOT for now)
-#popd #onos-yang-tools
-
-set +x
-
-echo
-echo "Please build and verify the ONOS Buck plugin and the Yang tools plugin:"
-echo " cd onos; buck build //tools/build/buck-plugin:onos"
-echo " cd onos-yang-tools; mvn clean package"
-echo "You should commit and push any required changes."
diff --git a/tools/build/buck-publish-package b/tools/build/buck-publish-package
deleted file mode 100755
index 09d1612..0000000
--- a/tools/build/buck-publish-package
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/bash
-
-for NEXT_VERSION in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20; do
- DEFAULT_TAG=${TAG:-$(date +v%Y.%m.%d.$NEXT_VERSION)}
- BUCK_ZIP="buck-$DEFAULT_TAG.zip"
- DOWNLOAD_BASE="http://repo1.maven.org/maven2/org/onosproject/onos-buck/$DEFAULT_TAG"
-
- if ! curl --output /dev/null --silent --head --fail "$DOWNLOAD_BASE/$BUCK_ZIP"; then
- break;
- fi
-done
-
-NO_BUCKD=1
-
-UPLOAD_BASE="https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-buck/$DEFAULT_TAG"
-BUCK_ZIP="buck-$DEFAULT_TAG.zip"
-ZIP_STAGE="buck-bin"
-
-rm -rf $ZIP_STAGE
-
-set -e
-set -x
-
-# build plugins
-
-pushd buck
-onos-buck build buck
-popd #buck
-
-pushd onos
-onos-buck build //tools/build/buck-plugin:onos
-popd #onos
-
-pushd onos-yang-tools
-mvn clean package
-popd #onos-yang-tools
-
-# assemble zip
-
-mkdir -p buck-bin/plugins
-
-cp buck/buck-out/gen/programs/buck.pex $ZIP_STAGE/buck
-cp onos/buck-out/gen/tools/build/buck-plugin/onos.jar $ZIP_STAGE/plugins/onos.jar
-cp onos-yang-tools/compiler/plugin/buck/target/onos-yang-compiler-buck-plugin-*.jar $ZIP_STAGE/plugins/yang.jar
-
-BUCK_VERSION=$(buck/buck-out/gen/programs/buck.pex -V)
-echo $BUCK_VERSION > $ZIP_STAGE/.buck_version
-
-chmod 555 $ZIP_STAGE/buck
-chmod 444 $ZIP_STAGE/.buck_version
-
-pushd $ZIP_STAGE
-zip -r ../$BUCK_ZIP buck .buck_version plugins
-popd #$ZIP_STAGE
-
-if [ "$1" != "--dry-run" ]; then
- # publish zip
- curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $BUCK_ZIP $UPLOAD_BASE/$BUCK_ZIP
- echo "New buck release is in " $BUCK_ZIP
-fi
-
-# update version in onos-buck
-URL="$DOWNLOAD_BASE/$BUCK_ZIP"
-SHA=$(shasum $BUCK_ZIP | cut -d' ' -f1)
-
-sed -i "" -E "s#BUCK_URL=.*#BUCK_URL=\"$URL\"#" onos/tools/build/onos-buck
-sed -i "" -E "s#BUCK_SHA=.*#BUCK_SHA=\"$SHA\"#" onos/tools/build/onos-buck
-
-set +x
-echo
-echo "Commit and push change to onos-buck on the onos directory."
diff --git a/tools/build/buck-publish-setup b/tools/build/buck-publish-setup
deleted file mode 100755
index d180479..0000000
--- a/tools/build/buck-publish-setup
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-BUCK_REF=${1:-"11-11-2016"}
-ONOS_REF=${2:-"master"}
-YANG_REF=${3:-"master"}
-DIR=$4
-
-set -x
-
-if [ -z "$4" ]; then
- DIR=$(mktemp -d /tmp/buck-publish.XXXXX) || { echo "Failed to create temp file"; exit 1; }
-fi
-# change to tmpdir
-cd $DIR
-
-# checkout buck
-git clone -b $BUCK_REF https://github.com/bocon13/buck
-
-# checkout plugins
-git clone -b $ONOS_REF https://gerrit.onosproject.org/onos.git
-git clone -b $YANG_REF https://gerrit.onosproject.org/onos-yang-tools.git
-
-set +x
-
-echo
-echo "Buck publish area:"
-echo " cd $DIR"
-
diff --git a/tools/build/conf/BUCK b/tools/build/conf/BUCK
deleted file mode 100644
index 11ab279..0000000
--- a/tools/build/conf/BUCK
+++ /dev/null
@@ -1,81 +0,0 @@
-checkstyle_source = 'src/main/resources/onos/checkstyle.xml'
-suppression_source = 'src/main/resources/onos/suppressions.xml'
-header_source = 'src/main/resources/onos/onos-java.header'
-
-export_file (
- name = 'checkstyle-xml',
- src = checkstyle_source,
- visibility = [ 'PUBLIC' ],
-)
-
-export_file (
- name = 'suppressions-xml',
- src = suppression_source,
- visibility = [ 'PUBLIC' ],
-)
-
-export_file (
- name = 'onos-java-header',
- src = header_source,
- visibility = [ 'PUBLIC' ],
-)
-
-export_file (
- name = 'start-buck-daemon',
- visibility = [ 'PUBLIC' ],
-)
-
-COMPILE = [
- '//lib:com_google_guava_guava',
- '//lib:checkstyle',
-]
-
-RUN = [
- '//lib:commons-logging',
- '//lib:commons-beanutils',
- '//lib:commons-lang3',
- '//lib:commons-collections',
- '//lib:antlr',
-]
-
-java_library (
- name = 'checkstyle',
- srcs = glob([ 'src/main/java/**/*.java' ]),
- deps = COMPILE,
-)
-
-java_binary (
- name = 'buck-daemon-jar',
- deps = [ ':checkstyle' ] + RUN,
- main_class = 'org.onosproject.buckdaemon.BuckDaemon',
- blacklist = [ 'META-INF/.*' ],
- visibility = [ 'PUBLIC' ],
-)
-
-osgi_jar (
- name = 'onos-build-conf',
- srcs = [],
- deps = [ ':checkstyle' ] + RUN,
-)
-
-# cmd = '#!/bin/bash\n'
-# cmd += '$1 &>/dev/null < /dev/null &'
-#
-# genrule(
-# name = 'checkstyle-sh',
-# bash = "echo '%s' > $OUT && chmod +x $OUT" % cmd,
-# out = 'checkstyle.sh',
-# )
-#
-# sh_test(
-# name = 'checkstyle-runner',
-# test = ':checkstyle-sh',
-# args = [
-# '$(exe :checkstyle-jar)',
-# '$(location //lib:checkstyle)',
-# '$(location //tools/build/conf:checkstyle-xml)',
-# '`mktemp /tmp/%s-checkstyle-XXXXXX`',
-# ],
-# labels = [ 'checkstyle' ],
-# visibility = [ 'PUBLIC' ],
-# )
diff --git a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java
deleted file mode 100644
index a253995..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckDaemon.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.buckdaemon;
-
-import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
-import org.onosproject.checkstyle.CheckstyleRunner;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import static java.nio.file.StandardOpenOption.CREATE;
-import static java.nio.file.StandardOpenOption.WRITE;
-
-/**
- * Buck daemon process.
- */
-public final class BuckDaemon {
-
- private static final long POLLING_INTERVAL = 1000; //ms
-
- private final Map<String, BuckTask> tasks = new HashMap<>();
- private final String portLock;
- private final String buckPid;
-
- // Public construction forbidden
- private BuckDaemon(String[] args) {
- portLock = args[0];
- buckPid = args[1];
- }
-
- /**
- * Main entry point for the daemon.
- *
- * @param args command-line arguments
- * @throws CheckstyleException on checkstyle error
- * @throws IOException on I/O error
- */
- public static void main(String[] args)
- throws CheckstyleException, IOException {
- BuckDaemon daemon = new BuckDaemon(args);
- daemon.registerTasks();
- daemon.startServer();
- }
-
- /**
- * Registers re-entrant tasks by their task name.
- */
- private void registerTasks() {
- tasks.put("checkstyle", new CheckstyleRunner(System.getProperty("checkstyle.config"),
- System.getProperty("checkstyle.suppressions")));
- // tasks.put("swagger", new SwaggerGenerator());
- }
-
- /**
- * Monitors another PID and exit when that process exits.
- */
- private void watchProcess(String pid) {
- if (pid == null || pid.equals("0")) {
- return;
- }
- Timer timer = new Timer(true); // start as a daemon, so we don't hang shutdown
- timer.scheduleAtFixedRate(new TimerTask() {
- private String cmd = "kill -s 0 " + pid;
-
- @Override
- public void run() {
- try {
- Process p = Runtime.getRuntime().exec(cmd);
- p.waitFor();
- if (p.exitValue() != 0) {
- debug("shutting down...");
- System.exit(0);
- }
- } catch (IOException | InterruptedException e) {
- //no-op
- e.printStackTrace();
- }
- }
- }, POLLING_INTERVAL, POLLING_INTERVAL);
- }
-
- /**
- * Initiates a server.
- */
- private void startServer() throws IOException, CheckstyleException {
- // Use a file lock to ensure only one copy of the daemon runs
- Path portLockPath = Paths.get(portLock);
- FileChannel channel = FileChannel.open(portLockPath, WRITE, CREATE);
- FileLock lock = channel.tryLock();
- if (lock == null) {
- debug("Server is already running");
- System.exit(1);
- } //else, hold the lock until the JVM exits
-
- // Start the server and bind it to a random port
- ServerSocket server = new ServerSocket(0);
-
- // Monitor the parent buck process
- watchProcess(buckPid);
-
- // Set up hook to clean up after ourselves
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- try {
- channel.truncate(0);
- channel.close();
- debug("tear down...");
- Files.delete(portLockPath);
- } catch (IOException e) {
- //no-op: shutting down
- e.printStackTrace();
- }
- }));
-
- // Write the bound port to the port file
- int port = server.getLocalPort();
- channel.truncate(0);
- channel.write(ByteBuffer.wrap(Integer.toString(port).getBytes()));
- channel.force(false); // flush the port number to disk
-
- // Instantiate a Checkstyle runner and executor; serve until exit...
- ExecutorService executor = Executors.newCachedThreadPool();
- while (true) {
- try {
- executor.submit(new BuckTaskRunner(server.accept()));
- } catch (Exception e) {
- e.printStackTrace();
- //no-op
- }
- }
- }
-
- /**
- * Runnable capable of invoking the appropriate Buck task with input
- * consumed form the specified socket and output produced back to that
- * socket.
- */
- private class BuckTaskRunner implements Runnable {
-
- private final Socket socket;
-
- public BuckTaskRunner(Socket socket) {
- this.socket = socket;
- }
-
- @Override
- public void run() {
- try {
- try {
- socket.setSoTimeout(1_000); //reads should time out after 1 second
- BuckTaskContext context = BuckTaskContext.createBuckTaskContext(socket.getInputStream());
- if (context == null) {
- socket.close();
- return;
- }
-
- String taskName = context.taskName();
- BuckTask task = tasks.get(taskName);
- if (task != null) {
- debug(String.format("Executing task '%s'", taskName));
- try {
- task.execute(context);
- for (String line : context.output()) {
- send(socket, line);
- }
- // TODO should we catch Exception, RuntimeException, or something specific?
- } catch (Throwable e) {
- e.printStackTrace(new PrintStream(socket.getOutputStream()));
- }
- } else {
- String message = String.format("No task named '%s'", taskName);
- debug(message);
- send(socket, message);
- }
- } catch (Throwable e) {
- StringWriter writer = new StringWriter();
- e.printStackTrace(new PrintWriter(writer));
- String stacktrace = writer.toString();
- debug(stacktrace);
- send(socket, stacktrace);
- }
- socket.getOutputStream().flush();
- socket.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- }
-
- private static void send(Socket socket, String line) throws IOException {
- socket.getOutputStream().write((line + "\n").getBytes());
- }
-
- private static void debug(String message) {
- // no-op; print to System.out if needed
- }
-}
diff --git a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTask.java b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTask.java
deleted file mode 100644
index d579305..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTask.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.buckdaemon;
-
-/**
- * Abstraction of a Buck task that can be spawned by the Buck daemon.
- */
-public interface BuckTask {
-
- /**
- * Executes the task, consuming the specified input and producing output.
- *
- * @param context context for the tast operation
- */
- void execute(BuckTaskContext context);
-
-}
diff --git a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTaskContext.java b/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTaskContext.java
deleted file mode 100644
index 8dabfd2..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/buckdaemon/BuckTaskContext.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.buckdaemon;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.List;
-
-/**
- * Context for executing a single Buck task.
- */
-public class BuckTaskContext {
-
- private final String taskName;
- private final ImmutableList<String> input;
- private final List<String> output;
-
- public static BuckTaskContext createBuckTaskContext(InputStream inputStream) throws IOException {
- ImmutableList<String> lines = slurpInput(inputStream);
- if (lines.size() == 0) {
- return null;
- } else {
- return new BuckTaskContext(lines);
- }
- }
-
- BuckTaskContext(ImmutableList<String> lines) {
- this.taskName = lines.get(0);
- this.input = lines.subList(1, lines.size());
- this.output = Lists.newArrayList();
- }
-
- /**
- * Reads all input, line by line, from a stream until an empty line or EOF is encountered.
- *
- * @param stream input stream
- * @return the lines of the input
- * @throws IOException
- */
- private static ImmutableList<String> slurpInput(InputStream stream) throws IOException {
- ImmutableList.Builder<String> lines = ImmutableList.builder();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream));
- while (true) {
- String line = bufferedReader.readLine();
- if (line == null || line.trim().length() == 0) {
- // Empty line or EOF
- break;
- }
- lines.add(line);
- }
- return lines.build();
- }
-
- /**
- * Returns the symbolic task name.
- *
- * @return symbolic task name
- */
- public String taskName() {
- return taskName;
- }
-
- /**
- * Returns the input data a list of strings.
- *
- * @return input data
- */
- public List<String> input() {
- return ImmutableList.copyOf(input);
- }
-
- /**
- * Returns the output data a list of strings.
- *
- * @return output data
- */
- List<String> output() {
- return ImmutableList.copyOf(output);
- }
-
- /**
- * Adds a line to the output data.
- *
- * @param line line of output data
- */
- public void output(String line) {
- output.add(line);
- }
-
-}
diff --git a/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java b/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
deleted file mode 100644
index ab1f7eb..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/checkstyle/CheckstyleRunner.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * 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 org.onosproject.checkstyle;
-
-import com.puppycrawl.tools.checkstyle.Checker;
-import com.puppycrawl.tools.checkstyle.ConfigurationLoader;
-import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
-import com.puppycrawl.tools.checkstyle.PropertiesExpander;
-import com.puppycrawl.tools.checkstyle.api.AuditEvent;
-import com.puppycrawl.tools.checkstyle.api.AuditListener;
-import com.puppycrawl.tools.checkstyle.api.CheckstyleException;
-import com.puppycrawl.tools.checkstyle.api.Configuration;
-import org.onosproject.buckdaemon.BuckTask;
-import org.onosproject.buckdaemon.BuckTaskContext;
-
-import java.io.File;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-/**
- * Buck task for executing checkstyle on the specified project files.
- */
-public class CheckstyleRunner implements BuckTask {
-
- private final Configuration config;
-
- public CheckstyleRunner(String configLocation, String suppressionLocation) {
- try {
- // create a configuration
- DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader
- .loadConfiguration(configLocation, new PropertiesExpander(System.getProperties()));
-
- // add the suppression file to the configuration
- DefaultConfiguration suppressions = new DefaultConfiguration("SuppressionFilter");
- suppressions.addAttribute("file", suppressionLocation);
- config.addChild(suppressions);
-
- this.config = config;
- } catch (CheckstyleException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void execute(BuckTaskContext context) {
- List<String> input = context.input();
- if (input.size() < 3 || input.get(2).length() == 0) {
- return;
- }
- String project = input.get(0);
- String baseDir = input.get(1);
-
- // create a listener for output
- StringAuditor listener = new StringAuditor(context);
- listener.setProjectName(project);
- listener.setBaseDir(baseDir);
-
- // create Checker object and run it
- final Checker checker = new Checker();
- final ClassLoader moduleClassLoader = Checker.class.getClassLoader();
- checker.setModuleClassLoader(moduleClassLoader);
-
- try {
- checker.configure(config);
- checker.addListener(listener);
-
- // run Checker
- List<File> fileList = input.subList(2, input.size()).stream()
- .filter(s -> !s.contains("/:")) // Yes, fighting a hack with a hack.
- .map(File::new)
- .collect(Collectors.toList());
- int errorCounter = checker.process(fileList);
- if (errorCounter > 0) {
- context.output("CHECKSTYLE ERROR");
- }
-
- listener.await();
- } catch (CheckstyleException | InterruptedException e) {
- e.printStackTrace(); //dump exeception to stderr
- throw new RuntimeException(e);
- } finally {
- checker.destroy();
- }
-
- }
-
- static class StringAuditor implements AuditListener {
-
- private final BuckTaskContext context;
- private CountDownLatch finishedLatch = new CountDownLatch(1);
- private String baseDir = "";
- private String project = "";
-
- StringAuditor(BuckTaskContext context) {
- this.context = context;
- }
-
- public void setBaseDir(String base) {
- this.baseDir = base;
- }
-
- public void setProjectName(String projectName) {
- this.project = projectName;
- }
-
- public void await() throws InterruptedException {
- finishedLatch.await();
- }
-
- @Override
- public void auditStarted(AuditEvent evt) {
- }
-
- @Override
- public void auditFinished(AuditEvent evt) {
- finishedLatch.countDown();
- }
-
- @Override
- public void fileStarted(AuditEvent evt) {
- }
-
- @Override
- public void fileFinished(AuditEvent evt) {
- }
-
- @Override
- public void addError(AuditEvent evt) {
- switch (evt.getSeverityLevel()) {
- case ERROR:
- StringBuilder output = new StringBuilder();
- String fileName = evt.getFileName();
- if (!isNullOrEmpty(baseDir)) {
- int index = fileName.indexOf(baseDir);
- if (index >= 0) {
- fileName = fileName.substring(index + baseDir.length() + 1);
- if (!isNullOrEmpty(project)) {
- output.append(project).append(':');
- }
- }
- }
- output.append(fileName).append(':').append(evt.getLine());
- if (evt.getColumn() > 0) {
- output.append(':').append(evt.getColumn());
- }
- output.append(": ").append(evt.getMessage());
- context.output(output.toString());
- break;
- case IGNORE:
- case INFO:
- case WARNING:
- default:
- break;
- }
- }
-
- @Override
- public void addException(AuditEvent evt, Throwable throwable) {
- addError(evt);
- context.output(throwable.getMessage());
- }
- }
-
-}
diff --git a/tools/build/conf/src/main/java/org/onosproject/checkstyle/package-info.java b/tools/build/conf/src/main/java/org/onosproject/checkstyle/package-info.java
deleted file mode 100644
index 241a819..0000000
--- a/tools/build/conf/src/main/java/org/onosproject/checkstyle/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.
- */
-/**
- * checkstyle runner for BuckDaemon.
- */
-package org.onosproject.checkstyle;
diff --git a/tools/build/conf/start-buck-daemon b/tools/build/conf/start-buck-daemon
deleted file mode 100755
index b747376..0000000
--- a/tools/build/conf/start-buck-daemon
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Launches Buck daemon if not already running and requests Buck task execution.
-# -----------------------------------------------------------------------------
-
-BUCK_DAEMON=$1
-TASK=${2:-unspecified}
-DATA=${3}
-
-# TODO: Figure out how to parametrize better
-BUCK_PROPS="-Dcheckstyle.config=$4 -Dcheckstyle.suppressions=$5"
-
-PORT_FILE="$1.port"
-
-function ppid() {
- ps -p ${1:-$$} -o ppid= -o pid= -o comm=
-}
-
-function buck_pid() {
- BUCK_PID=($(ppid))
- while [ ${BUCK_PID[0]} -ne 0 ]; do
- BUCK_PID=($(ppid $BUCK_PID))
- if [ "${BUCK_PID[2]}" == "buck" ]; then
- # use parent PID of buck
- echo ${BUCK_PID[0]}
- return
- fi
- if [ "${BUCK_PID[2]}" == "buckd" ] ||
- [[ "${BUCK_PID[2]}" == *"python"* ]]; then
- # use PID of buckd or python
- echo ${BUCK_PID[1]}
- return
- fi
- done
- # fallback last read PID
- echo ${BUCK_PID[1]}
-}
-
-function port() {
- cat $PORT_FILE 2>/dev/null || echo 0
-}
-
-function check_socket() {
- printf "\n" | nc localhost $(port) 2>/dev/null
- return $?
-}
-
-# check to see if buck daemon is running; if not, start it
-if ! check_socket; then
- # Starting buck daemon...
- #FIXME change to /dev/null if/when we are confident
- nohup java $BUCK_PROPS -jar $BUCK_DAEMON $PORT_FILE $(buck_pid) >>/tmp/buck.daemon 2>&1 &
-
- TRIES=20
- i=0
- # Wait for buck daemon to start for 2 seconds
- while [ $i -lt $TRIES ]; do
- if check_socket; then
- CONNECTED=true
- break
- fi
- let i=i+1
- sleep 0.1
- done
- if [ -z "$CONNECTED" ]; then
- echo "Failed to start buck daemon"
- exit 3
- fi
-fi
-
-# run the actual buck daemon client
-OUT=$((printf "%s\n" $TASK; cat $DATA) | nc localhost $(port))
-if [ $? -ne 0 ]; then
- echo "Error connecting to buck daemon server"
- exit 2
-fi
-if [ -n "$OUT" ]; then
- printf "$OUT"
- exit 1
-fi
\ No newline at end of file
diff --git a/tools/build/envDefaults b/tools/build/envDefaults
index 09e6979..b00ba3d 100644
--- a/tools/build/envDefaults
+++ b/tools/build/envDefaults
@@ -33,16 +33,7 @@
export ONOS_TAR=$ONOS_STAGE.tar.gz
export ONOS_ZIP=$ONOS_STAGE.zip
-# If the bazel-built bits are newer than the buck-built bits, use the former.
-BUCK_TAR=$ONOS_ROOT/buck-out/gen/tools/package/onos-package/onos.tar.gz
-BAZEL_TAR=$ONOS_ROOT/bazel-bin/onos.tar.gz
-if [ -f $BAZEL_TAR ] && [ $BAZEL_TAR -nt $ONOS_TAR ]; then
- rm -f $ONOS_TAR >/dev/null; ln -s $BAZEL_TAR $ONOS_TAR
-else
- if [ -f $BUCK_TAR ] && [ $BUCK_TAR -nt $ONOS_TAR ]; then
- rm -f $ONOS_TAR >/dev/null; ln -s $BUCK_TAR $ONOS_TAR
- fi
-fi
+ONOS_TAR=$ONOS_ROOT/bazel-bin/onos.tar.gz
# ONOS test bits (onos-test.tar.gz) staging environment
export ONOS_TEST_BITS=onos-test-${ONOS_VERSION%~*}
diff --git a/tools/build/jenkins/onos-buck-gerrit b/tools/build/jenkins/onos-buck-gerrit
deleted file mode 100644
index 7638a2a..0000000
--- a/tools/build/jenkins/onos-buck-gerrit
+++ /dev/null
@@ -1,37 +0,0 @@
-#!groovy
-
-pipeline {
-
- agent { node { label 'ubuntu16.04-basebuild-8c-15g' } }
-
- stages {
-
- stage('build') {
- steps {
- sh '''#!/bin/bash -l
- ONOS_ROOT=`pwd`
- source tools/build/envDefaults
- onos-buck build onos
- '''
- }
- }
-
- stage('test') {
- steps {
- parallel (
- "unit-tests": {
- sh '''#!/bin/bash -l
- ONOS_ROOT=`pwd`
- source tools/build/envDefaults
- onos-buck test
- onos-buck build //docs:external //docs:internal --show-output
- '''
- },
- // additional steps here (STC, docker buld, etc)
- )
- }
- }
- }
-
-}
-
diff --git a/tools/build/onos-buck b/tools/build/onos-buck
deleted file mode 100755
index 0a839e0..0000000
--- a/tools/build/onos-buck
+++ /dev/null
@@ -1,130 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Runs the custom version of Buck required by ONOS.
-# -----------------------------------------------------------------------------
-
-set -e
-
-BUCK_URL="http://repo1.maven.org/maven2/org/onosproject/onos-buck/v2018.02.09.01/buck-v2018.02.09.01.zip"
-BUCK_SHA="45d8bd28f441991257babf89f7a317edb3a2b536"
-
-# onos-yang-tools buck plugin version
-YANG_VER="2.5"
-ONOS_PLUGIN_VER="1.0.3"
-MAVEN_BASE="https://repo1.maven.org/maven2"
-MAVEN_ONOSPROJECT="$MAVEN_BASE/org/onosproject"
-
-[ "-U" = "$1" ] && shift && FORCE_UPDATE=True
-
-ROOT_DIR=${ONOS_ROOT:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"}
-
-mkdir -p $ROOT_DIR/bin
-pushd $ROOT_DIR/bin > /dev/null
-
-if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$BUCK_SHA" != "$(cat .buck_sha)" ]; then
- echo "Updating Buck..." >&2
- rm -fr .buck_version .buck_sha buck plugins
- mkdir -p cache
- BUCK_FILE=$(basename $BUCK_URL)
- # Check the local cache; download to cache if required
- [ -f "cache/$BUCK_FILE" ] || curl -o cache/$BUCK_FILE -L $BUCK_URL
- if [ -n "$(which shasum)" ]; then
- SHA=$(shasum cache/$BUCK_FILE | cut -d' ' -f1)
- if [ "$SHA" != "$BUCK_SHA" ]; then
- echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
- rm -f cache/$BUCK_FILE && exit 1
- else
- echo "$SHA" > .buck_sha
- fi
- else
- echo "SHA cannot be verified"
- fi
- unzip -qq cache/$BUCK_FILE
- # Kill buckd
- ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || :
- rm -rf $ROOT_DIR/buck-out
- printf "Successfully updated Buck in $ROOT_DIR/bin/buck to $BUCK_FILE\n\n"
-fi
-
-# Fetch & install onos yang tools buck plugin
-YANG_PLUGIN_CACHE="cache/onos-yang-compiler-buck-plugin-$YANG_VER.jar"
-if hash mvn 2>/dev/null; then
- if [[ $YANG_VER = *"-SNAPSHOT" ]] || [ ! -f "$YANG_PLUGIN_CACHE" ]; then
- echo "Updating Yang plugin $YANG_VER..." >&2
- ARTIFACT="org.onosproject:onos-yang-compiler-buck-plugin:$YANG_VER"
- mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy \
- -Dartifact=$ARTIFACT \
- -Dtransitive=false -Dmdep.overWriteSnapshots=true \
- -DoutputDirectory=cache > /dev/null
- fi
-else
- if [ ! -f "$YANG_PLUGIN_CACHE" ]; then
- echo "Updating Yang plugin $YANG_VER..." >&2
- if [[ $YANG_VER = *"-SNAPSHOT" ]]; then
- echo "mvn command must be installed to handle SNAPSHOT version"
- exit 1
- fi
-
- curl -o "$YANG_PLUGIN_CACHE" \
- -L $MAVEN_ONOSPROJECT/onos-yang-compiler-buck-plugin/$YANG_VER/onos-yang-compiler-buck-plugin-$YANG_VER.jar
- fi
-
- if [[ $YANG_VER != *"-SNAPSHOT" ]] && hash shasum 2>/dev/null; then
- SHA=$(shasum $YANG_PLUGIN_CACHE | cut -d' ' -f1)
- if [ ! -f "$YANG_PLUGIN_CACHE".sha1 ]; then
- curl -o "$YANG_PLUGIN_CACHE".sha1 \
- -L $MAVEN_ONOSPROJECT/onos-yang-compiler-buck-plugin/$YANG_VER/onos-yang-compiler-buck-plugin-$YANG_VER.jar.sha1
- fi
- YANG_PLUGIN_SHA=$(cat "$YANG_PLUGIN_CACHE".sha1)
- if [ "$SHA" != "$YANG_PLUGIN_SHA" ]; then
- echo "ERROR: Downloaded SHA ($SHA) did not match expected SHA ($YANG_PLUGIN_SHA)" &&
- rm -f $YANG_PLUGIN_CACHE $YANG_PLUGIN_CACHE.sha1 && exit 1
- fi
- else
- echo "SHA verification skipped"
- fi
-fi
-install -Cv "$YANG_PLUGIN_CACHE" plugins/yang.jar >/dev/null
-
-# Fetch & install onos buck plugin
-
-ONOS_PLUGIN_CACHE="cache/onos-buck-plugin-$ONOS_PLUGIN_VER.jar"
-
-if [ ! -f "$ONOS_PLUGIN_CACHE" ]; then
- echo "Updating ONOS plugin $ONOS_PLUGIN_VER..." >&2
- curl -o "$ONOS_PLUGIN_CACHE" \
- -L $MAVEN_ONOSPROJECT/onos-buck-plugin/$ONOS_PLUGIN_VER/onos-buck-plugin-$ONOS_PLUGIN_VER.jar
-fi
-
-
-if hash shasum 2>/dev/null; then
- SHA=$(shasum $ONOS_PLUGIN_CACHE | cut -d' ' -f1)
- if [ ! -f "$ONOS_PLUGIN_CACHE".sha1 ]; then
- curl -o "$ONOS_PLUGIN_CACHE".sha1 \
- -L $MAVEN_ONOSPROJECT/onos-buck-plugin/$ONOS_PLUGIN_VER/onos-buck-plugin-$ONOS_PLUGIN_VER.jar.sha1
- fi
- ONOS_PLUGIN_SHA=$(cat "$ONOS_PLUGIN_CACHE".sha1)
- if [ "$SHA" != "$ONOS_PLUGIN_SHA" ]; then
- echo "ERROR: Downloaded SHA ($SHA) did not match expected SHA ($ONOS_PLUGIN_SHA)" &&
- rm -f $ONOS_PLUGIN_CACHE $ONOS_PLUGIN_CACHE.sha1 && exit 1
- fi
-else
- echo "SHA verification skipped"
-fi
-install -Cv "$ONOS_PLUGIN_CACHE" plugins/onos.jar >/dev/null
-
-popd > /dev/null
-
-BUCK=$ROOT_DIR/bin/buck
-
-if [ "${ONOS_NO_BUCKD:-1}" == "1" ]; then
- export NO_BUCKD=1
-fi
-
-# HACK: Clean-up frequent problem-causers from buck-out
-#rm -fr \
-# $ONOS_ROOT/buck-out/bin/lib/.netty \
-# $ONOS_ROOT/buck-out/bin/lib/.KRYO
-
-# Finally, run the Buck command...
-$BUCK "$@"
diff --git a/tools/build/onos-buck-build-docs b/tools/build/onos-buck-build-docs
deleted file mode 100755
index 658a539..0000000
--- a/tools/build/onos-buck-build-docs
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Builds the ONOS Java API docs with buck.
-# -----------------------------------------------------------------------------
-
-set -e
-
-[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
-. $ONOS_ROOT/tools/build/envDefaults
-
-onos-buck build `onos-buck query "filter('.*-javadoc', '//...')"`
-
diff --git a/tools/build/onos-buck-publish b/tools/build/onos-buck-publish
deleted file mode 100755
index a4db536..0000000
--- a/tools/build/onos-buck-publish
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-#
-# Script that queries buck for main and test artifacts and publishes them to
-# a remote Maven repository. Main artifacts are published with javadoc and sources
-# jars and auto-generated pom.xml files. Test artifacts are published as compiled
-# jars only. All artifacts are signed.
-#
-
-ARTIFACT_PUB=$(mktemp /tmp/onos-publish.XXXXX) &&
- echo "Created temp file for artifact publish: $ARTIFACT_PUB" ||
- { echo "Failed to create temp file"; exit 1; }
-
-TEST_PUB=$(mktemp /tmp/onos-publish-tests.XXXXX) &&
- echo "Created temp file for test artifact publish: $TEST_PUB" ||
- { echo "Failed to create temp file"; exit 1; }
-
-trap "rm -f $ARTIFACT_PUB $ARTIFACT_PUB.bak $TEST_PUB $TEST_PUB.bak" EXIT
-
-set -e
-set -x
-
-# Prepare artifact publish commands
-cat ${ONOS_ROOT}/tools/build/publish-target-list | grep -v '#' >> $ARTIFACT_PUB
-sed -i.bak 's/^/onos-buck publish --to-maven-central --include-source --include-javadoc --sign /g' $ARTIFACT_PUB
-cp $ARTIFACT_PUB $ARTIFACT_PUB.bak
-( echo "set -e"; cat $ARTIFACT_PUB.bak ) >$ARTIFACT_PUB
-
-# Print commands to be run and then run them
-cat $ARTIFACT_PUB
-bash $ARTIFACT_PUB
-
-# Prepare feature commands
-onos-buck query "filter('.*-feature', deps(filter('.*-oar', deps('//tools/package:onos-package', 1)),1))" > $TEST_PUB
-echo "//tools/package:onos-features" >> $TEST_PUB
-
-# Prepare test commands
-cat ${ONOS_ROOT}/tools/build/publish-test-target-list | grep -v '#' >> $TEST_PUB
-sed -i.bak 's#^#onos-buck publish --to-maven-central --sign #g' $TEST_PUB
-cp $TEST_PUB $TEST_PUB.bak
-( echo "set -e"; cat $TEST_PUB.bak ) >$TEST_PUB
-
-# Print commands to be run and then run them
-cat $TEST_PUB
-bash $TEST_PUB
-
-# stage ONOS poms
-onos-buck publish --to-maven-central --sign //:top-level-pom
-onos-buck publish --to-maven-central --sign //lib:onos-dependencies-pom
-
-if ! grep "maven_url" $ONOS_ROOT/.buckconfig.local | grep -v '#' | grep -q snapshots ; then
- # Close the staging area
- onos-close-staging
-fi
diff --git a/tools/build/onos-buck-publish-local b/tools/build/onos-buck-publish-local
deleted file mode 100755
index 6c52db7..0000000
--- a/tools/build/onos-buck-publish-local
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-set -e
-onos-buck -V
-
-for package in `cat ${ONOS_ROOT}/tools/build/publish-target-list ${ONOS_ROOT}/tools/build/publish-test-target-list | grep -v '#'`; do
- onos-buck publish --to-local-repo ${package}
-done
-
-
diff --git a/tools/build/onos-lib-gen b/tools/build/onos-lib-gen
index 3a083f8..14d51a3 100755
--- a/tools/build/onos-lib-gen
+++ b/tools/build/onos-lib-gen
@@ -9,7 +9,7 @@
cd $ONOS_ROOT
REPO=${M2_REPO:-~/.m2/repository}
-VER=1.5
+VER=2.1
ARTIFACT=org/onosproject/onos-libgen/$VER/onos-libgen-$VER.jar
JAR=$REPO/$ARTIFACT
@@ -21,5 +21,4 @@
[ -f $JAR ] && printf "Done.\n"
fi
-[ -z "$1" -o "$1" = "bazel" ] && java -jar $JAR lib/deps.json tools/build/bazel/generate_workspace.bzl --bazel
-[ -z "$1" -o "$1" = "buck" ] && java -jar $JAR lib/deps.json lib/BUCK
+java -jar $JAR lib/deps.json tools/build/bazel/generate_workspace.bzl
diff --git a/tools/build/onos-validate-change-version.excludes b/tools/build/onos-validate-change-version.excludes
index 856a1f4..bca6a85 100755
--- a/tools/build/onos-validate-change-version.excludes
+++ b/tools/build/onos-validate-change-version.excludes
@@ -37,8 +37,6 @@
\./providers/snmp/
\./sonar-project.properties
\./tools/build/bazel
-\./tools/build/buck-plugin/BUCK
-\./tools/build/buck-publish-api
\./tools/build/conf/pom.xml
\./tools/build/libgen
\./tools/build/onos-buck
diff --git a/tools/build/push-buck-plugin b/tools/build/push-buck-plugin
deleted file mode 100755
index 97df2e5..0000000
--- a/tools/build/push-buck-plugin
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-# -----------------------------------------------------------------------------
-# Builds and uploads an ONOS buck plugin release
-# -----------------------------------------------------------------------------
-
-if [ $# -ne 1 ]; then
- echo "Usage: push-buck-plugin version"
- exit 1
-fi
-
-PLUGIN_VERSION="$1"
-PLUGIN_FILE="buck-out/gen/tools/build/buck-plugin/onos.jar"
-UPLOAD_BASE="https://oss.sonatype.org/service/local/staging/deploy/maven2/org/onosproject/onos-buck-plugin/$PLUGIN_VERSION"
-
-# Build the buck plugin
-onos-buck build //tools/build/buck-plugin:onos
-
-# Make the signature file
-gpg --armor --detach-sig $PLUGIN_FILE
-
-# Make the MD5 checksum file
-md5 -q $PLUGIN_FILE >$PLUGIN_FILE.md5
-
-# Make the SHA1 checksum file
-( shasum $PLUGIN_FILE | cut -d' ' -f1 ) > $PLUGIN_FILE.sha1
-
-curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE $UPLOAD_BASE/onos-buck-plugin-$PLUGIN_VERSION.jar
-curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE.asc $UPLOAD_BASE/onos-buck-plugin-$PLUGIN_VERSION.jar.asc
-curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE.md5 $UPLOAD_BASE/onos-buck-plugin-$PLUGIN_VERSION.jar.md5
-curl -v -u "$SONATYPE_USER:$SONATYPE_PASSWORD" --upload-file $PLUGIN_FILE.sha1 $UPLOAD_BASE/onos-buck-plugin-$PLUGIN_VERSION.jar.sha1
-
diff --git a/tools/build/buck-plugin/BUILD b/tools/build/swagger/BUILD
similarity index 100%
rename from tools/build/buck-plugin/BUILD
rename to tools/build/swagger/BUILD
diff --git a/tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/SwaggerGenerator.java b/tools/build/swagger/src/main/java/org/onosproject/onosjar/SwaggerGenerator.java
similarity index 100%
rename from tools/build/buck-plugin/src/main/java/org/onosproject/onosjar/SwaggerGenerator.java
rename to tools/build/swagger/src/main/java/org/onosproject/onosjar/SwaggerGenerator.java
diff --git a/tools/build/buck-plugin/src/main/resources/registrator.javat b/tools/build/swagger/src/main/resources/registrator.javat
similarity index 100%
rename from tools/build/buck-plugin/src/main/resources/registrator.javat
rename to tools/build/swagger/src/main/resources/registrator.javat