Initial builds using bazel
Change-Id: I38123b396a2ffda5f36cdca43f3ad1fa67a7ab52
diff --git a/utils/junit/BUILD b/utils/junit/BUILD
new file mode 100644
index 0000000..13a2068
--- /dev/null
+++ b/utils/junit/BUILD
@@ -0,0 +1,25 @@
+SRC = 'src/main/java/org/onlab/**/'
+TEST_SRC = 'src/test/java/org/onlab/**/'
+
+COMPILE_DEPS = [
+ "@guava//jar",
+ "@slf4j_api//jar",
+ "@hamcrest_all//jar",
+ "@junit//jar",
+]
+
+TEST_DEPS = [
+ "@guava_testlib//jar",
+]
+
+osgi_jar_with_tests(
+ name = 'onlab-junit',
+ srcs = glob([SRC + '*.java']),
+ deps = COMPILE_DEPS,
+ test_srcs = glob([TEST_SRC + '*.java']),
+ test_deps = TEST_DEPS,
+ package_name_root = 'org.onlab',
+ visibility = ["//visibility:public"],
+)
+
+
diff --git a/utils/misc/BUILD b/utils/misc/BUILD
new file mode 100644
index 0000000..3635a41
--- /dev/null
+++ b/utils/misc/BUILD
@@ -0,0 +1,17 @@
+COMPILE_DEPS = COMPILE + JACKSON + [
+ "@kryo//jar",
+ "@metrics_core//jar",
+ "@netty//jar",
+ "@netty_common//jar",
+ "@objenesis//jar",
+]
+
+osgi_jar_with_tests(
+ name = 'onlab-misc',
+ deps = COMPILE_DEPS,
+ package_name_root = 'org.onlab',
+ exclude_tests = ['org.onlab.graph.AbstractGraphPathSearchTest',
+ 'org.onlab.graph.GraphTest',
+ 'org.onlab.util.SlidingWindowCounterTest'],
+ visibility = ["//visibility:public"],
+)
diff --git a/utils/misc/src/test/java/org/onlab/MiscTestSuite.java b/utils/misc/src/test/java/org/onlab/MiscTestSuite.java
new file mode 100644
index 0000000..33eb892
--- /dev/null
+++ b/utils/misc/src/test/java/org/onlab/MiscTestSuite.java
@@ -0,0 +1,60 @@
+/*
+ * 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.onlab;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.onlab.graph.AbstractEdgeTest;
+import org.onlab.graph.AdjacencyListsGraphTest;
+import org.onlab.graph.BellmanFordGraphSearchTest;
+import org.onlab.graph.BreadthFirstSearchTest;
+import org.onlab.graph.DefaultMutablePathTest;
+import org.onlab.graph.DefaultPathTest;
+import org.onlab.graph.DepthFirstSearchTest;
+import org.onlab.graph.DijkstraGraphSearchTest;
+import org.onlab.graph.DisjointPathPairTest;
+import org.onlab.graph.HeapTest;
+import org.onlab.graph.KShortestPathsSearchTest;
+import org.onlab.graph.LazyKShortestPathsSearchTest;
+import org.onlab.graph.SrlgGraphSearchTest;
+import org.onlab.graph.SuurballeGraphSearchTest;
+import org.onlab.graph.TarjanGraphSearchTest;
+import org.onlab.util.ImmutableByteSequenceTest;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AbstractEdgeTest.class,
+ AdjacencyListsGraphTest.class,
+ BellmanFordGraphSearchTest.class,
+ BreadthFirstSearchTest.class,
+ DefaultMutablePathTest.class,
+ DefaultPathTest.class,
+ DepthFirstSearchTest.class,
+ DijkstraGraphSearchTest.class,
+ DisjointPathPairTest.class,
+ HeapTest.class,
+ KShortestPathsSearchTest.class,
+ LazyKShortestPathsSearchTest.class,
+ SrlgGraphSearchTest.class,
+ SuurballeGraphSearchTest.class,
+ TarjanGraphSearchTest.class,
+ ImmutableByteSequenceTest.class,
+})
+
+public class MiscTestSuite {
+
+}
diff --git a/utils/osgi/BUILD b/utils/osgi/BUILD
new file mode 100644
index 0000000..91dd172
--- /dev/null
+++ b/utils/osgi/BUILD
@@ -0,0 +1,8 @@
+COMPILE_DEPS = COMPILE
+
+osgi_jar_with_tests(
+ name = 'onlab-osgi',
+ deps = COMPILE_DEPS,
+ package_name_root = 'org.onlab',
+ visibility = ["//visibility:public"],
+)
diff --git a/utils/osgiwrap/BUILD b/utils/osgiwrap/BUILD
new file mode 100644
index 0000000..8e1e872
--- /dev/null
+++ b/utils/osgiwrap/BUILD
@@ -0,0 +1,15 @@
+OSGIWRAP_EXECUTABLE = 'osgi-jar'
+
+COMPILE_DEPS = [
+ '@guava//jar',
+ '@bndlib//jar',
+ '@org_apache_felix_scr_bnd//jar'
+]
+
+java_binary(
+ name = OSGIWRAP_EXECUTABLE,
+ srcs = glob(['src/main/java/**/*.java']),
+ deps = COMPILE_DEPS,
+ main_class = 'org.onlab.osgiwrap.OSGiWrapper',
+ visibility = ["//visibility:public"]
+)
diff --git a/utils/osgiwrap/src/main/java/org/onlab/osgiwrap/OSGiWrapper.java b/utils/osgiwrap/src/main/java/org/onlab/osgiwrap/OSGiWrapper.java
index 8a10992..fe286cb 100644
--- a/utils/osgiwrap/src/main/java/org/onlab/osgiwrap/OSGiWrapper.java
+++ b/utils/osgiwrap/src/main/java/org/onlab/osgiwrap/OSGiWrapper.java
@@ -74,10 +74,11 @@
private String bundleLicense;
private String webContext;
+ private String destdir;
// FIXME should consider using Commons CLI, etc.
public static void main(String[] args) {
- if (args.length < 12) {
+ if (args.length < 13) {
System.err.println("Not enough args");
System.exit(1);
}
@@ -94,6 +95,7 @@
String includeResources = args[9];
String webContext = args[10];
String dynamicimportPackages = args[11];
+ String destdir = args[12];
String desc = Joiner.on(' ').join(Arrays.copyOfRange(args, 12, args.length));
OSGiWrapper wrapper = new OSGiWrapper(jar, output, cp,
@@ -103,7 +105,8 @@
includeResources,
webContext,
dynamicimportPackages,
- desc);
+ desc,
+ destdir);
wrapper.log(wrapper + "\n");
if (!wrapper.execute()) {
System.err.printf("Error generating %s\n", name);
@@ -124,7 +127,8 @@
String includeResources,
String webContext,
String dynamicimportPackages,
- String bundleDescription) {
+ String bundleDescription,
+ String destdir) {
this.inputJar = inputJar;
this.classpath = Lists.newArrayList(classpath.split(":"));
if (!this.classpath.contains(inputJar)) {
@@ -151,6 +155,7 @@
}
this.webContext = webContext;
+ this.destdir = destdir;
}
private void setProperties(Analyzer analyzer) {
@@ -209,6 +214,8 @@
// Scan the JAR for Felix SCR annotations and generate XML files
Map<String, String> properties = Maps.newHashMap();
+ // destdir hack
+ properties.put("destdir", destdir);
SCRDescriptorBndPlugin scrDescriptorBndPlugin = new SCRDescriptorBndPlugin();
scrDescriptorBndPlugin.setProperties(properties);
scrDescriptorBndPlugin.setReporter(analyzer);
diff --git a/utils/rest/BUILD b/utils/rest/BUILD
new file mode 100644
index 0000000..0538ba6
--- /dev/null
+++ b/utils/rest/BUILD
@@ -0,0 +1,13 @@
+COMPILE_DEPS = COMPILE + JACKSON + [
+ "//utils/osgi:onlab-osgi",
+ "//utils/misc:onlab-misc",
+ "@javax_ws_rs_api//jar",
+ "@jersey_server//jar",
+]
+
+osgi_jar(
+ name = 'onlab-rest',
+ deps = COMPILE_DEPS,
+ package_name_root = 'org.onlab',
+ visibility = ["//visibility:public"],
+)