metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject [36/39] metron git commit: METRON-1136 Metron Extensions System and Parser Extensions Feature Branch (ottobackwards) closes apache/metron#720
Date Wed, 30 Aug 2017 15:05:01 GMT
http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/java/org/apache/metron/bundles/integration/BundleMapperIntegrationTest.java
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/java/org/apache/metron/bundles/integration/BundleMapperIntegrationTest.java b/bundles-lib/src/test/java/org/apache/metron/bundles/integration/BundleMapperIntegrationTest.java
new file mode 100644
index 0000000..977afa7
--- /dev/null
+++ b/bundles-lib/src/test/java/org/apache/metron/bundles/integration/BundleMapperIntegrationTest.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.metron.bundles.integration;
+
+import static org.apache.metron.bundles.util.TestUtil.loadSpecifiedProperties;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.metron.bundles.BundleClassLoaders;
+import org.apache.metron.bundles.BundleMapper;
+import org.apache.metron.bundles.ExtensionManager;
+import org.apache.metron.bundles.ExtensionMapping;
+import org.apache.metron.bundles.bundle.Bundle;
+import org.apache.metron.bundles.util.BundleProperties;
+import org.apache.metron.bundles.util.FileSystemManagerFactory;
+import org.apache.metron.integration.components.MRComponent;
+import org.apache.metron.parsers.interfaces.MessageParser;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class BundleMapperIntegrationTest {
+
+  static final Map<String, String> EMPTY_MAP = new HashMap<String, String>();
+  static MRComponent component;
+  static Configuration configuration;
+  static FileSystem fileSystem;
+
+
+  @AfterClass
+  public static void after() {
+    ExtensionManager.reset();
+    BundleClassLoaders.reset();
+  }
+
+  @After
+  public void afterTest() {
+    ExtensionManager.reset();
+    BundleClassLoaders.reset();
+  }
+  @BeforeClass
+  public static void setup() {
+    ExtensionManager.reset();
+    BundleClassLoaders.reset();
+    component = new MRComponent().withBasePath("target/hdfs");
+    component.start();
+    configuration = component.getConfiguration();
+
+    try {
+      fileSystem = FileSystem.newInstance(configuration);
+      fileSystem.mkdirs(new Path("/work/"),
+          new FsPermission(FsAction.READ_WRITE, FsAction.READ_WRITE, FsAction.READ_WRITE));
+      fileSystem.copyFromLocalFile(new Path("./src/test/resources/bundle.properties"),
+          new Path("/work/"));
+      fileSystem
+          .copyFromLocalFile(new Path("./src/test/resources/BundleMapper/lib/"), new Path("/"));
+      fileSystem
+          .copyFromLocalFile(new Path("./src/test/resources/BundleMapper/lib2/"), new Path("/"));
+      RemoteIterator<LocatedFileStatus> files = fileSystem.listFiles(new Path("/"), true);
+      System.out.println("==============(BEFORE)==============");
+      while (files.hasNext()) {
+        LocatedFileStatus fileStat = files.next();
+        System.out.println(fileStat.getPath().toString());
+      }
+    } catch (IOException e) {
+      throw new RuntimeException("Unable to start cluster", e);
+    }
+  }
+
+  @AfterClass
+  public static void teardown() {
+    try {
+      RemoteIterator<LocatedFileStatus> files = fileSystem.listFiles(new Path("/"), true);
+      System.out.println("==============(AFTER)==============");
+      while (files.hasNext()) {
+        LocatedFileStatus fileStat = files.next();
+        System.out.println(fileStat.getPath().toString());
+      }
+    } catch (Exception e) {
+    }
+    component.stop();
+    BundleClassLoaders.reset();
+  }
+
+  @Test
+  public void testUnpackBundles() throws Exception {
+    unpackBundles();
+  }
+
+  public void unpackBundles() throws Exception {
+    // setup properties
+    BundleProperties properties = loadSpecifiedProperties("/BundleMapper/conf/bundle.properties",
+        EMPTY_MAP);
+    // get the port we ended up with and set the paths
+    String hdfsPrefix = configuration.get("fs.defaultFS");
+    properties.setProperty(BundleProperties.BUNDLE_LIBRARY_DIRECTORY, hdfsPrefix +"/lib/");
+    properties.setProperty(BundleProperties.BUNDLE_LIBRARY_DIRECTORY_PREFIX + "alt", hdfsPrefix + "/lib2/");
+    FileSystemManager fileSystemManager = FileSystemManagerFactory.createFileSystemManager(new String[] {properties.getArchiveExtension()});
+    ArrayList<Class> classes = new ArrayList<>();
+    classes.add(MessageParser.class);
+    // create a FileSystemManager
+    Bundle systemBundle = ExtensionManager.createSystemBundle(fileSystemManager, properties);
+    ExtensionManager.init(classes, systemBundle, Collections.emptySet());
+
+    final ExtensionMapping extensionMapping = BundleMapper
+        .mapBundles(fileSystemManager,
+             properties);
+
+    assertNotNull(extensionMapping);
+    assertEquals(2, extensionMapping.getAllExtensionNames().size());
+
+    assertTrue(extensionMapping.getAllExtensionNames().keySet().contains(
+        "org.apache.metron.bar.BarParser"));
+    assertTrue(extensionMapping.getAllExtensionNames().keySet().contains(
+        "org.apache.metron.foo.FooParser"));
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/java/org/apache/metron/bundles/util/ImmutableCollectionUtilsTest.java
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/java/org/apache/metron/bundles/util/ImmutableCollectionUtilsTest.java b/bundles-lib/src/test/java/org/apache/metron/bundles/util/ImmutableCollectionUtilsTest.java
new file mode 100644
index 0000000..53669f2
--- /dev/null
+++ b/bundles-lib/src/test/java/org/apache/metron/bundles/util/ImmutableCollectionUtilsTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.metron.bundles.util;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ImmutableCollectionUtilsTest {
+
+  @Test
+  public void immutableMapOfSets() throws Exception {
+    Map<String,Set<String>> map = new HashMap<>();
+    map.put("one",new HashSet<String>(){{ add("a");}});
+
+    Map<String,Set<String>> immutableMap = ImmutableCollectionUtils.immutableMapOfSets(map);
+    Assert.assertNotNull(immutableMap);
+    boolean thrown = false;
+    try {
+      immutableMap.put("test", new HashSet<String>());
+    } catch(UnsupportedOperationException e){
+      thrown = true;
+    }
+    Assert.assertTrue(thrown);
+    thrown = false;
+
+    try {
+      immutableMap.get("one").add("b");
+    } catch(UnsupportedOperationException e) {
+      thrown = true;
+    }
+
+    Assert.assertTrue(thrown);
+
+  }
+
+  @Test
+  public void immutableMapOfLists() throws Exception {
+    Map<String,List<String>> map = new HashMap<>();
+    map.put("one", Arrays.asList("a"));
+
+    Map<String,List<String>> immutableMap = ImmutableCollectionUtils.immutableMapOfLists(map);
+    Assert.assertNotNull(immutableMap);
+    boolean thrown = false;
+    try {
+      immutableMap.put("test", new LinkedList<>());
+    } catch(UnsupportedOperationException e){
+      thrown = true;
+    }
+    Assert.assertTrue(thrown);
+    thrown = false;
+
+    try {
+      immutableMap.get("one").add("b");
+    } catch(UnsupportedOperationException e) {
+      thrown = true;
+    }
+
+    Assert.assertTrue(thrown);
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/java/org/apache/metron/bundles/util/ResourceCopier.java
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/java/org/apache/metron/bundles/util/ResourceCopier.java b/bundles-lib/src/test/java/org/apache/metron/bundles/util/ResourceCopier.java
new file mode 100644
index 0000000..fbfc10d
--- /dev/null
+++ b/bundles-lib/src/test/java/org/apache/metron/bundles/util/ResourceCopier.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.metron.bundles.util;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+public class ResourceCopier {
+
+  public static void copyResources(Path sourcePath, Path targetPath) throws IOException{
+    Files.walkFileTree(sourcePath, new SimpleFileVisitor<Path>() {
+
+      @Override
+      public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
+          throws IOException {
+
+        Path relativeSource = sourcePath.relativize(dir);
+        Path target = targetPath.resolve(relativeSource);
+
+        Files.createDirectories(target);
+
+        return FileVisitResult.CONTINUE;
+
+      }
+
+      @Override
+      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+          throws IOException {
+
+        Path relativeSource = sourcePath.relativize(file);
+        Path target = targetPath.resolve(relativeSource);
+
+        Files.copy(file, target, REPLACE_EXISTING);
+
+        return FileVisitResult.CONTINUE;
+      }
+    });
+  }
+}

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/java/org/apache/metron/bundles/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/java/org/apache/metron/bundles/util/TestUtil.java b/bundles-lib/src/test/java/org/apache/metron/bundles/util/TestUtil.java
new file mode 100644
index 0000000..b99ec55
--- /dev/null
+++ b/bundles-lib/src/test/java/org/apache/metron/bundles/util/TestUtil.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.metron.bundles.util;
+
+import com.google.common.collect.ImmutableList;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.vfs2.FileObject;
+import org.apache.commons.vfs2.FileSystemException;
+import org.apache.commons.vfs2.FileSystemManager;
+import org.apache.metron.bundles.integration.BundleMapperIntegrationTest;
+
+import java.net.URISyntaxException;
+import java.util.Map;
+
+public class TestUtil {
+  public static BundleProperties loadSpecifiedProperties(final String propertiesFile, final Map<String, String> others) {
+    String filePath;
+    try {
+      filePath = BundleMapperIntegrationTest.class.getResource(propertiesFile).toURI().getPath();
+    } catch (URISyntaxException ex) {
+      throw new RuntimeException("Cannot load properties file due to "
+              + ex.getLocalizedMessage(), ex);
+    }
+    return BundleProperties.createBasicBundleProperties(filePath, others);
+  }
+
+  public static List<FileObject> getExtensionLibs(FileSystemManager fileSystemManager, BundleProperties properties) throws URISyntaxException, FileSystemException{
+    List<URI> libDirs = properties.getBundleLibraryDirectories();
+    List<FileObject> libFileObjects = new ArrayList<>();
+    for(URI libUri : libDirs){
+      FileObject fileObject = fileSystemManager.resolveFile(libUri);
+      if(fileObject.exists()){
+        libFileObjects.add(fileObject);
+      }
+    }
+    return libFileObjects;
+  }
+}

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/java/org/apache/metron/parsers/interfaces/MessageParser.java
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/java/org/apache/metron/parsers/interfaces/MessageParser.java b/bundles-lib/src/test/java/org/apache/metron/parsers/interfaces/MessageParser.java
new file mode 100644
index 0000000..7d27da6
--- /dev/null
+++ b/bundles-lib/src/test/java/org/apache/metron/parsers/interfaces/MessageParser.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.metron.parsers.interfaces;
+
+public interface MessageParser {
+
+
+}

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/BundleMapper/conf/bundle.properties
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/BundleMapper/conf/bundle.properties b/bundles-lib/src/test/resources/BundleMapper/conf/bundle.properties
new file mode 100644
index 0000000..0f34b12
--- /dev/null
+++ b/bundles-lib/src/test/resources/BundleMapper/conf/bundle.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# Core Properties #
+bundle.library.directory=./target/BundleMapper/lib/
+bundle.library.directory.alt=./target/BundleMapper/lib2/
+bundle.archive.extension=bundle
+bundle.meta.id.prefix=Bundle
+bundle.extension.type.parser=org.apache.metron.parsers.interfaces.MessageParser

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/BundleMapper/lib/metron-parser-bar-bundle-0.4.1.bundle
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/BundleMapper/lib/metron-parser-bar-bundle-0.4.1.bundle b/bundles-lib/src/test/resources/BundleMapper/lib/metron-parser-bar-bundle-0.4.1.bundle
new file mode 100644
index 0000000..5b312fa
Binary files /dev/null and b/bundles-lib/src/test/resources/BundleMapper/lib/metron-parser-bar-bundle-0.4.1.bundle differ

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/BundleMapper/lib2/metron-parser-foo-bundle-0.4.1.bundle
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/BundleMapper/lib2/metron-parser-foo-bundle-0.4.1.bundle b/bundles-lib/src/test/resources/BundleMapper/lib2/metron-parser-foo-bundle-0.4.1.bundle
new file mode 100644
index 0000000..1fa8519
Binary files /dev/null and b/bundles-lib/src/test/resources/BundleMapper/lib2/metron-parser-foo-bundle-0.4.1.bundle differ

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/META-INF/services/org.apache.metron.bundles.AbstractFoo
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/META-INF/services/org.apache.metron.bundles.AbstractFoo b/bundles-lib/src/test/resources/META-INF/services/org.apache.metron.bundles.AbstractFoo
new file mode 100644
index 0000000..b7b36dc
--- /dev/null
+++ b/bundles-lib/src/test/resources/META-INF/services/org.apache.metron.bundles.AbstractFoo
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+org.apache.metron.bundles.BundleThreadContextClassLoaderTest$WithPropertiesConstructor
+org.apache.metron.bundles.BundleThreadContextClassLoaderTest$WithDefaultConstructor

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/bundle.properties
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/bundle.properties b/bundles-lib/src/test/resources/bundle.properties
new file mode 100644
index 0000000..d1a944a
--- /dev/null
+++ b/bundles-lib/src/test/resources/bundle.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# Core Properties #
+bundle.library.directory=./target/lib/
+bundle.archive.extension=foo
+bundle.meta.id.prefix=Bundle
+bundle.extension.type.parser=org.apache.metron.parsers.interfaces.MessageParser
+
+

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/utils-bundles/bundle-with-versioning/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/utils-bundles/bundle-with-versioning/META-INF/MANIFEST.MF b/bundles-lib/src/test/resources/utils-bundles/bundle-with-versioning/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..353d60d
--- /dev/null
+++ b/bundles-lib/src/test/resources/utils-bundles/bundle-with-versioning/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Build-Tag: HEAD
+Build-Revision: a032175
+Build-Branch: METRON-3380
+Build-Timestamp: 2017-01-23T10:36:27Z
+Build-Jdk: 1.8.0_74
+Built-By: ottobackwards
+Bundle-Group: org.apache.metron
+Bundle-Id: metron-hadoop-bundle
+Bundle-Version: 1.2.0
+Bundle-Dependency-Group: org.apache.metron.hadoop
+Bundle-Dependency-Id: metron-hadoop-libraries-bundle
+Bundle-Dependency-Version: 1.2.1
+Created-By: Apache Maven 3.3.3

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/utils-bundles/bundle-without-dependency/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/utils-bundles/bundle-without-dependency/META-INF/MANIFEST.MF b/bundles-lib/src/test/resources/utils-bundles/bundle-without-dependency/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..2ba6e98
--- /dev/null
+++ b/bundles-lib/src/test/resources/utils-bundles/bundle-without-dependency/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Build-Tag: HEAD
+Build-Revision: a032175
+Build-Branch: METRON-3380
+Build-Timestamp: 2017-01-23T10:36:27Z
+Build-Jdk: 1.8.0_74
+Built-By: ottobackwards
+Bundle-Group: org.apache.metron
+Bundle-Id: metron-hadoop-bundle
+Bundle-Version: 1.2.0
+Created-By: Apache Maven 3.3.3

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-lib/src/test/resources/utils-bundles/bundle-without-versioning/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/bundles-lib/src/test/resources/utils-bundles/bundle-without-versioning/META-INF/MANIFEST.MF b/bundles-lib/src/test/resources/utils-bundles/bundle-without-versioning/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..02aaea5
--- /dev/null
+++ b/bundles-lib/src/test/resources/utils-bundles/bundle-without-versioning/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Build-Jdk: 1.8.0_74
+Built-By: ottobackwards
+Bundle-Id: metron-hadoop-bundle
+Bundle-Dependency-Id: metron-hadoop-libraries-bundle
+Created-By: Apache Maven 3.3.3

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-maven-plugin/LICENSE
----------------------------------------------------------------------
diff --git a/bundles-maven-plugin/LICENSE b/bundles-maven-plugin/LICENSE
new file mode 100644
index 0000000..7a4a3ea
--- /dev/null
+++ b/bundles-maven-plugin/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-maven-plugin/NOTICE
----------------------------------------------------------------------
diff --git a/bundles-maven-plugin/NOTICE b/bundles-maven-plugin/NOTICE
new file mode 100644
index 0000000..6d192c1
--- /dev/null
+++ b/bundles-maven-plugin/NOTICE
@@ -0,0 +1,5 @@
+Apache NiFi
+Copyright 2014-2017 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-maven-plugin/README.md
----------------------------------------------------------------------
diff --git a/bundles-maven-plugin/README.md b/bundles-maven-plugin/README.md
new file mode 100644
index 0000000..c6d9e60
--- /dev/null
+++ b/bundles-maven-plugin/README.md
@@ -0,0 +1,89 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+# Apache Metron Bundle Maven Plugin
+
+Apache Metron Bundles Maven Plugin helps to build Bundles Archives to support the classloader isolation model.
+
+## Table of Contents
+
+- [Requirements](#requirements)
+- [Getting Started](#getting-started)
+- [Getting Help](#getting-help)
+- [License](#license)
+
+## Requirements
+* JDK 1.7 or higher
+* Apache Maven 3.1.0 or higher
+
+## Getting Started
+
+Building the bundles-maven-plugin module should be rare since it will be released infrequently compared to
+the main 'metron' code tree.
+
+- Build with `mvn clean install`
+- Presuming you need to make use of changes to the nifi-nar-maven-plugin module, you should next
+  go to the [metron](../metron) directory and follow its instructions. 
+
+
+## Settings and configuration
+
+There are several properties that can be set to change the behavior of this plugin.
+Two of special interest are:
+
+#### packageType
+packageType defines the type of archive to be produced and evaluated for special dependencies.  The default packageType is bundle.  This property should be changed if you have need to 
+customize the file extension of archives produced by this plugin.  This plugin will build archives with .bundle extentions, and look for othe .bundle dependencies by definition.
+Changing this value, for example to 'foo', will have the effect of having the plugin produce archives with .foo as the extension, and look for .foo files
+as bundle dependencies.
+ 
+#### packageIDPrefix 
+The archives produced by this plugin have the following entries added to the manifest ( where packageIDPrefix defaults to 'Bundle'):
+
+-  {packageIDPrefix}-Id
+-  {packageIDPrefix}-Group
+-  {packageIDPrefix}-Version
+-  {packageIDPrefix}-Dependency-Group
+-  {packageIDPrefix}-Dependency-Id
+-  {packageIDPrefix}-Dependency-Version
+
+This property can be used to change the name of these manifest entries.  One convention being to continue as the original by capitalizing the
+type, such as:
+Bundle to bundle
+
+ 
+
+## Getting Help
+If you have questions, you can reach out to our mailing list: dev@metron.apache.org
+We're also often available in IRC: #nifi on
+[irc.freenode.net](http://webchat.freenode.net/?channels=#apache-metron).
+
+
+## License
+
+Except as otherwise noted this software is licensed under the
+[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
+
+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.
+

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/bundles-maven-plugin/pom.xml b/bundles-maven-plugin/pom.xml
new file mode 100644
index 0000000..121b775
--- /dev/null
+++ b/bundles-maven-plugin/pom.xml
@@ -0,0 +1,328 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+      http://www.apache.org/licenses/LICENSE-2.0
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>17</version>
+        <relativePath />
+    </parent>
+    <groupId>org.apache.metron</groupId>
+    <artifactId>bundles-maven-plugin</artifactId>
+    <version>0.4.1</version>
+    <packaging>maven-plugin</packaging>
+    <description>Apache Metron Bundles Maven Plugin</description>
+    <url>http://metron.apache.org</url>
+    <organization>
+        <name>Apache Metron Project</name>
+        <url>http://metron.apache.org/</url>
+    </organization>
+    <licenses>
+        <license>
+            <name>Apache License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+        </license>
+    </licenses>
+    <prerequisites>
+        <maven>${maven.min-version}</maven>
+    </prerequisites>
+    <properties>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <maven.min-version>3.1.0</maven.min-version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <inceptionYear>2014</inceptionYear>
+    </properties>
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.2</version>
+                    <configuration>
+                        <fork>true</fork>
+                        <optimize>true</optimize>
+                        <showDeprecation>true</showDeprecation>
+                        <showWarnings>true</showWarnings>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-war-plugin</artifactId>
+                    <version>2.5</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-dependency-plugin</artifactId>
+                    <version>2.9</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-resources-plugin</artifactId>
+                    <version>2.7</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-surefire-plugin</artifactId>
+                    <version>2.18</version>
+                    <configuration>
+                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                        <argLine>-Xmx1G</argLine>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-source-plugin</artifactId>
+                    <version>2.4</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-jar-plugin</artifactId>
+                    <version>2.5</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-javadoc-plugin</artifactId>
+                    <version>2.10.1</version>
+                    <configuration>
+                        <failOnError>false</failOnError>
+                        <quiet>true</quiet>
+                        <show>private</show>
+                        <encoding>UTF-8</encoding>
+                        <quiet>true</quiet>
+                        <javadocVersion>1.7</javadocVersion>
+                        <additionalJOption>-J-Xmx512m</additionalJOption>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-release-plugin</artifactId>
+                    <version>2.5.1</version>
+                    <configuration>
+                        <useReleaseProfile>true</useReleaseProfile>
+                        <releaseProfiles>apache-release</releaseProfiles>
+                        <autoVersionSubmodules>true</autoVersionSubmodules>
+                        <goals>deploy</goals>
+                        <tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
+                        <pushChanges>false</pushChanges>
+                        <localCheckout>true</localCheckout>
+                    </configuration>
+                    <executions>
+                        <execution>
+                            <id>default</id>
+                            <goals>
+                                <goal>perform</goal>
+                            </goals>
+                            <configuration>
+                                <pomFileName>pom.xml</pomFileName>
+                            </configuration>
+                        </execution>
+                    </executions>
+                </plugin>
+                <plugin>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>rpm-maven-plugin</artifactId>
+                    <version>2.1.1</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.antlr</groupId>
+                    <artifactId>antlr3-maven-plugin</artifactId>
+                    <version>3.5.2</version>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-checkstyle-plugin</artifactId>
+                    <version>2.15</version>
+                    <dependencies>
+                        <dependency>
+                            <groupId>com.puppycrawl.tools</groupId>
+                            <artifactId>checkstyle</artifactId>
+                            <version>6.5</version>
+                        </dependency>
+                    </dependencies>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>org.sonatype.plugins</groupId>
+                <artifactId>nexus-staging-maven-plugin</artifactId>
+                <version>1.6.5</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <serverId>repository.apache.org</serverId>
+                    <nexusUrl>https://repository.apache.org/</nexusUrl>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>enforce-maven</id>
+                        <goals>
+                            <goal>enforce</goal>
+                        </goals>
+                        <configuration>
+                            <rules>
+                                <requireSameVersions>
+                                    <plugins>
+                                        <plugin>org.apache.maven.plugins:maven-surefire-plugin</plugin>
+                                        <plugin>org.apache.maven.plugins:maven-failsafe-plugin</plugin>
+                                        <plugin>org.apache.maven.plugins:maven-surefire-report-plugin</plugin>
+                                    </plugins>
+                                </requireSameVersions>
+                                <requireMavenVersion>
+                                    <version>${maven.min-version}</version>
+                                </requireMavenVersion>
+                            </rules>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.rat</groupId>
+                <artifactId>apache-rat-plugin</artifactId>
+                <configuration>
+                    <excludes>
+                        <exclude>nb-configuration.xml</exclude> <!-- courtesy excludes for netbeans users -->
+                        <exclude>nbactions.xml</exclude> <!-- courtesy excludes for netbeans users -->
+                        <exclude>DEPENDENCIES</exclude> <!-- auto generated file by apache's maven config while building sources.zip -->
+                    </excludes>
+                </configuration>
+                <dependencies>
+                    <!-- workaround for RAT-158 -->
+                    <dependency>
+                        <groupId>org.apache.maven.doxia</groupId>
+                        <artifactId>doxia-core</artifactId>
+                        <version>1.6</version>
+                        <exclusions>
+                            <exclusion>
+                                <groupId>xerces</groupId>
+                                <artifactId>xercesImpl</artifactId>
+                            </exclusion>
+                        </exclusions>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-descriptor</id>
+                        <goals>
+                            <goal>descriptor</goal>
+                        </goals>
+                        <phase>process-classes</phase>
+                    </execution>
+                    <execution>
+                        <id>help-descriptor</id>
+                        <goals>
+                            <goal>helpmojo</goal>
+                        </goals>
+                        <phase>process-classes</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-artifact</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-compat</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-dependency-plugin</artifactId>
+            <type>maven-plugin</type>
+            <version>2.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-dependency-tree</artifactId>
+            <version>2.2</version>
+        </dependency>
+        <dependency>
+            <!-- No code from maven-jar-plugin is actually used; it's included
+            just to simplify the dependencies list.                     -->
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-jar-plugin</artifactId>
+            <version>2.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.plugin-tools</groupId>
+            <artifactId>maven-plugin-annotations</artifactId>
+            <scope>provided</scope>
+            <version>3.3</version>
+        </dependency>
+    </dependencies>
+    <profiles>
+        <profile>
+            <!--
+            Checks style and licensing requirements.  This is a good idea to
+            run for contributions and for the release process.  While it
+            would be nice to run always these plugins can considerably slow
+            the build and have proven to create unstable builds in our
+            multi-module project and when building using multiple threads.
+            The stability issues seen with Checkstyle in multi-module builds
+            include false-positives and false negatives.-->
+            <id>contrib-check</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.rat</groupId>
+                        <artifactId>apache-rat-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                                <phase>verify</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-checkstyle-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>check-style</id>
+                                <goals>
+                                    <goal>check</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>

http://git-wip-us.apache.org/repos/asf/metron/blob/ffcb91ed/bundles-maven-plugin/src/main/java/org/apache/metron/maven/plugins/bundles/BundleMojo.java
----------------------------------------------------------------------
diff --git a/bundles-maven-plugin/src/main/java/org/apache/metron/maven/plugins/bundles/BundleMojo.java b/bundles-maven-plugin/src/main/java/org/apache/metron/maven/plugins/bundles/BundleMojo.java
new file mode 100644
index 0000000..b53abe1
--- /dev/null
+++ b/bundles-maven-plugin/src/main/java/org/apache/metron/maven/plugins/bundles/BundleMojo.java
@@ -0,0 +1,743 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.metron.maven.plugins.bundles;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
+import org.apache.maven.plugin.dependency.utils.filters.DestFileFilter;
+import org.apache.maven.plugin.dependency.utils.resolvers.ArtifactsResolver;
+import org.apache.maven.plugin.dependency.utils.resolvers.DefaultArtifactsResolver;
+import org.apache.maven.plugin.dependency.utils.translators.ArtifactTranslator;
+import org.apache.maven.plugin.dependency.utils.translators.ClassifierTypeTranslator;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
+import org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter;
+import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Packages the current project as an Apache Metron Bundle Archive (BUNDLE).
+ * Apache Metron Bundles are based on Apache Nifi Archives (NAR) 1.2.0
+ *
+ * The following code is derived from maven-dependencies-plugin and
+ * maven-jar-plugin. The functionality of CopyDependenciesMojo and JarMojo was
+ * simplified to the use case of BundleMojo.
+ *
+ */
+@Mojo(name = "bundle", defaultPhase = LifecyclePhase.PACKAGE, threadSafe = false, requiresDependencyResolution = ResolutionScope.RUNTIME)
+public class BundleMojo extends AbstractMojo {
+
+    private static final String[] DEFAULT_EXCLUDES = new String[]{"**/package.html"};
+    private static final String[] DEFAULT_INCLUDES = new String[]{"**/**"};
+
+    private static final String BUILD_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+    /**
+     * POM
+     *
+     */
+    @Parameter(defaultValue = "${project}", readonly = true, required = true)
+    protected MavenProject project;
+
+    @Parameter(defaultValue = "${session}", readonly = true, required = true)
+    protected MavenSession session;
+
+    /**
+     * List of files to include. Specified as fileset patterns.
+     */
+    @Parameter(property = "includes")
+    protected String[] includes;
+    /**
+     * List of files to exclude. Specified as fileset patterns.
+     */
+    @Parameter(property = "excludes")
+    protected String[] excludes;
+    /**
+     * Name of the generated BUNDLE.
+     *
+     */
+    @Parameter(alias = "bundleName", property = "bundle.finalName", defaultValue = "${project.build.finalName}", required = true)
+    protected String finalName;
+    /**
+     * Name of the prefix for package identifiers like Bundle-Id, where Bundle is the identifier
+     */
+    @Parameter(alias = "packageIDPrefix", property = "bundle.packageIDPrefix", defaultValue = "Bundle", required = true)
+    protected String packageIDPrefix;
+
+    /**
+     * The Jar archiver.
+     *
+     * \@\component role="org.codehaus.plexus.archiver.Archiver" roleHint="jar"
+     */
+    @Component(role = org.codehaus.plexus.archiver.Archiver.class, hint = "jar")
+    private JarArchiver jarArchiver;
+    /**
+     * The archive configuration to use.
+     *
+     * See <a
+     * href="http://maven.apache.org/shared/maven-archiver/index.html">the
+     * documentation for Maven Archiver</a>.
+     *
+     */
+    @Parameter(property = "archive")
+    protected final MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+    /**
+     * Path to the default MANIFEST file to use. It will be used if
+     * <code>useDefaultManifestFile</code> is set to <code>true</code>.
+     *
+     */
+    @Parameter(property = "defaultManifestFiles", defaultValue = "${project.build.outputDirectory}/META-INF/MANIFEST.MF", readonly = true, required = true)
+    protected File defaultManifestFile;
+
+    /**
+     * Set this to <code>true</code> to enable the use of the
+     * <code>defaultManifestFile</code>.
+     *
+     * @since 2.2
+     */
+    @Parameter(property = "bundle.useDefaultManifestFile", defaultValue = "false")
+    protected boolean useDefaultManifestFile;
+
+    @Component
+    protected MavenProjectHelper projectHelper;
+
+    /**
+     * Whether creating the archive should be forced.
+     *
+     */
+    @Parameter(property = "bundle.forceCreation", defaultValue = "false")
+    protected boolean forceCreation;
+
+    /**
+     * Classifier to add to the artifact generated. If given, the artifact will
+     * be an attachment instead.
+     *
+     */
+    @Parameter(property = "classifier")
+    protected String classifier;
+
+    @Component
+    protected ArtifactInstaller installer;
+
+    @Component
+    protected ArtifactRepositoryFactory repositoryFactory;
+
+    /**
+     * This only applies if the classifier parameter is used.
+     *
+     */
+    @Parameter(property = "mdep.failOnMissingClassifierArtifact", defaultValue = "true", required = false)
+    protected boolean failOnMissingClassifierArtifact = true;
+
+    /**
+     * Comma Separated list of Types to include. Empty String indicates include
+     * everything (default).
+     *
+     */
+    @Parameter(property = "includeTypes", required = false)
+    protected String includeTypes;
+
+    /**
+     * Comma Separated list of Types to exclude. Empty String indicates don't
+     * exclude anything (default).
+     *
+     */
+    @Parameter(property = "excludeTypes", required = false)
+    protected String excludeTypes;
+
+    /**
+     * Scope to include. An Empty string indicates all scopes (default).
+     *
+     */
+    @Parameter(property = "includeScope", required = false)
+    protected String includeScope;
+
+    /**
+     * Scope to exclude. An Empty string indicates no scopes (default).
+     *
+     */
+    @Parameter(property = "excludeScope", required = false)
+    protected String excludeScope;
+
+    /**
+     * Comma Separated list of Classifiers to include. Empty String indicates
+     * include everything (default).
+     *
+     */
+    @Parameter(property = "includeClassifiers", required = false)
+    protected String includeClassifiers;
+
+    /**
+     * Comma Separated list of Classifiers to exclude. Empty String indicates
+     * don't exclude anything (default).
+     *
+     */
+    @Parameter(property = "excludeClassifiers", required = false)
+    protected String excludeClassifiers;
+
+    /**
+     * Specify classifier to look for. Example: sources
+     *
+     */
+    @Parameter(property = "classifier", required = false)
+    protected String copyDepClassifier;
+
+    /**
+     * Specify packageType to look for when constructing artifact based on classifier.
+     * Example: java-source,jar,war,bundle
+     *
+     */
+    @Parameter(property = "packageType", required = false, defaultValue = "bundle")
+    protected String packageType;
+
+    /**
+     * Comma separated list of Artifact names too exclude.
+     *
+     */
+    @Parameter(property = "excludeArtifacts", required = false)
+    protected String excludeArtifactIds;
+
+    /**
+     * Comma separated list of Artifact names to include.
+     *
+     */
+    @Parameter(property = "includeArtifacts", required = false)
+    protected String includeArtifactIds;
+
+    /**
+     * Comma separated list of GroupId Names to exclude.
+     *
+     */
+    @Parameter(property = "excludeArtifacts", required = false)
+    protected String excludeGroupIds;
+
+    /**
+     * Comma separated list of GroupIds to include.
+     *
+     */
+    @Parameter(property = "includeGroupIds", required = false)
+    protected String includeGroupIds;
+
+    /**
+     * Directory to store flag files
+     *
+     */
+    @Parameter(property = "markersDirectory", required = false, defaultValue = "${project.build.directory}/dependency-maven-plugin-markers")
+    protected File markersDirectory;
+
+    /**
+     * Overwrite release artifacts
+     *
+     */
+    @Parameter(property = "overWriteReleases", required = false)
+    protected boolean overWriteReleases;
+
+    /**
+     * Overwrite snapshot artifacts
+     *
+     */
+    @Parameter(property = "overWriteSnapshots", required = false)
+    protected boolean overWriteSnapshots;
+
+    /**
+     * Overwrite artifacts that don't exist or are older than the source.
+     *
+     */
+    @Parameter(property = "overWriteIfNewer", required = false, defaultValue = "true")
+    protected boolean overWriteIfNewer;
+
+    @Parameter(property = "projectBuildDirectory", required = false, defaultValue = "${project.build.directory}")
+    protected File projectBuildDirectory;
+
+    /**
+     * Used to look up Artifacts in the remote repository.
+     */
+    @Component
+    protected ArtifactFactory factory;
+
+    /**
+     * Used to look up Artifacts in the remote repository.
+     *
+     */
+    @Component
+    protected ArtifactResolver resolver;
+
+    /**
+     * Artifact collector, needed to resolve dependencies.
+     *
+     */
+    @Component(role = org.apache.maven.artifact.resolver.ArtifactCollector.class)
+    protected ArtifactCollector artifactCollector;
+
+    @Component(role = org.apache.maven.artifact.metadata.ArtifactMetadataSource.class)
+    protected ArtifactMetadataSource artifactMetadataSource;
+
+    /**
+     * Location of the local repository.
+     *
+     */
+    @Parameter(property = "localRepository", required = true, readonly = true)
+    protected ArtifactRepository local;
+
+    /**
+     * List of Remote Repositories used by the resolver
+     *
+     */
+    @Parameter(property = "project.remoteArtifactRepositories", required = true, readonly = true)
+    protected List remoteRepos;
+
+    /**
+     * To look up Archiver/UnArchiver implementations
+     *
+     */
+    @Component
+    protected ArchiverManager archiverManager;
+
+    /**
+     * Contains the full list of projects in the reactor.
+     *
+     */
+    @Parameter(property = "reactorProjects", required = true, readonly = true)
+    protected List reactorProjects;
+
+    /**
+     * If the plugin should be silent.
+     *
+     */
+    @Parameter(property = "silent", required = false, defaultValue = "false")
+    public boolean silent;
+
+    /**
+     * Output absolute filename for resolved artifacts
+     *
+     */
+    @Parameter(property = "outputAbsoluteArtifactFilename", defaultValue = "false", required = false)
+    protected boolean outputAbsoluteArtifactFilename;
+
+    /* The values to use for populating the Bundle-Group, Bundle-Id, and Bundle-Version in the MANIFEST file. By default
+     * these values will be set to the standard Maven project equivalents, but they may be overridden through properties.
+     *
+     * For example if the pom.xml for the metron-test-bundle contained the following:
+     *
+     *    <groupId>org.apache.metron</groupId>
+     *    <artifactId>metron-test-bundle</artifactId>
+     *    <version>1.0</version>
+     *
+     *    <properties>
+     *       <bundleGroup>org.apache.metron.overridden</bundleGroup>
+     *       <bundleId>metron-overridden-test-bundle</bundleId>
+     *       <bundleVersion>2.0</bundleVersion>
+     *   </properties>
+     *
+     * It would produce a MANIFEST with:
+     *
+     *   Bundle-Id: metron-overridden-test-bundle
+     *   Bundle-Group: org.apache.metron.overridden
+     *   Bundle-Version: 2.0
+     *
+    */
+
+    @Parameter(property = "bundleGroup", defaultValue = "${project.groupId}", required = true)
+    protected String bundleGroup;
+
+    @Parameter(property = "bundleId", defaultValue = "${project.artifactId}", required = true)
+    protected String bundleId;
+
+    @Parameter(property = "bundleVersion", defaultValue = "${project.version}", required = true)
+    protected String bundleVersion;
+
+    @Parameter(property = "bundleDependencyGroup", required = false)
+    protected String bundleDependencyGroup = null;
+
+    @Parameter(property = "bundleDependencyId", required = false)
+    protected String bundleDependencyId = null;
+
+    @Parameter(property = "bundleDependencyVersion", required = false)
+    protected String bundleDependencyVersion = null;
+
+
+    /**
+     * Build info to be populated in MANIFEST.
+     */
+
+    @Parameter(property = "buildTag", defaultValue = "${project.scm.tag}", required = false)
+    protected String buildTag;
+
+    @Parameter(property = "buildBranch", defaultValue = "${buildBranch}", required = false)
+    protected String buildBranch;
+
+    @Parameter(property = "buildRevision", defaultValue = "${buildRevision}", required = false)
+    protected String buildRevision;
+
+    /**
+     * Allows a Bundle to specify if it's resources should be cloned when a component that depends on this Bundle
+     * is performing class loader isolation.
+     */
+    @Parameter(property = "cloneDuringInstanceClassLoading", defaultValue = "false", required = false)
+    protected boolean cloneDuringInstanceClassLoading;
+
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        copyDependencies();
+        makeBundle();
+    }
+
+    private void copyDependencies() throws MojoExecutionException {
+        DependencyStatusSets dss = getDependencySets(this.failOnMissingClassifierArtifact);
+        Set artifacts = dss.getResolvedDependencies();
+
+        for (Object artifactObj : artifacts) {
+            copyArtifact((Artifact) artifactObj);
+        }
+
+        artifacts = dss.getSkippedDependencies();
+        for (Object artifactOjb : artifacts) {
+            Artifact artifact = (Artifact) artifactOjb;
+            getLog().info(artifact.getFile().getName() + " already exists in destination.");
+        }
+    }
+
+    protected void copyArtifact(Artifact artifact) throws MojoExecutionException {
+        String destFileName = DependencyUtil.getFormattedFileName(artifact, false);
+        final File destDir = DependencyUtil.getFormattedOutputDirectory(false, false, false, false, false, getDependenciesDirectory(), artifact);
+        final File destFile = new File(destDir, destFileName);
+        copyFile(artifact.getFile(), destFile);
+    }
+
+    protected Artifact getResolvedPomArtifact(Artifact artifact) {
+        Artifact pomArtifact = this.factory.createArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), "", "pom");
+        // Resolve the pom artifact using repos
+        try {
+            this.resolver.resolve(pomArtifact, this.remoteRepos, this.local);
+        } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
+            getLog().info(e.getMessage());
+        }
+        return pomArtifact;
+    }
+
+    protected ArtifactsFilter getMarkedArtifactFilter() {
+        return new DestFileFilter(this.overWriteReleases, this.overWriteSnapshots, this.overWriteIfNewer, false, false, false, false, false, getDependenciesDirectory());
+    }
+
+    protected DependencyStatusSets getDependencySets(boolean stopOnFailure) throws MojoExecutionException {
+        // add filters in well known order, least specific to most specific
+        FilterArtifacts filter = new FilterArtifacts();
+
+        filter.addFilter(new ProjectTransitivityFilter(project.getDependencyArtifacts(), false));
+        filter.addFilter(new ScopeFilter(this.includeScope, this.excludeScope));
+        filter.addFilter(new TypeFilter(this.includeTypes, this.excludeTypes));
+        filter.addFilter(new ClassifierFilter(this.includeClassifiers, this.excludeClassifiers));
+        filter.addFilter(new GroupIdFilter(this.includeGroupIds, this.excludeGroupIds));
+        filter.addFilter(new ArtifactIdFilter(this.includeArtifactIds, this.excludeArtifactIds));
+
+        // explicitly filter our bundle dependencies as defined by packageType
+        filter.addFilter(new TypeFilter("", packageType));
+
+        // start with all artifacts.
+        Set artifacts = project.getArtifacts();
+
+        // perform filtering
+        try {
+            artifacts = filter.filter(artifacts);
+        } catch (ArtifactFilterException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+
+        // transform artifacts if classifier is set
+        final DependencyStatusSets status;
+        if (StringUtils.isNotEmpty(copyDepClassifier)) {
+            status = getClassifierTranslatedDependencies(artifacts, stopOnFailure);
+        } else {
+            status = filterMarkedDependencies(artifacts);
+        }
+
+        return status;
+    }
+
+    protected DependencyStatusSets getClassifierTranslatedDependencies(Set artifacts, boolean stopOnFailure) throws MojoExecutionException {
+        Set unResolvedArtifacts = new HashSet();
+        Set resolvedArtifacts = artifacts;
+        DependencyStatusSets status = new DependencyStatusSets();
+
+        // possibly translate artifacts into a new set of artifacts based on the
+        // classifier and packageType
+        // if this did something, we need to resolve the new artifacts
+        if (StringUtils.isNotEmpty(copyDepClassifier)) {
+            ArtifactTranslator translator = new ClassifierTypeTranslator(this.copyDepClassifier, this.packageType, this.factory);
+            artifacts = translator.translate(artifacts, getLog());
+
+            status = filterMarkedDependencies(artifacts);
+
+            // the unskipped artifacts are in the resolved set.
+            artifacts = status.getResolvedDependencies();
+
+            // resolve the rest of the artifacts
+            ArtifactsResolver artifactsResolver = new DefaultArtifactsResolver(this.resolver, this.local,
+                    this.remoteRepos, stopOnFailure);
+            resolvedArtifacts = artifactsResolver.resolve(artifacts, getLog());
+
+            // calculate the artifacts not resolved.
+            unResolvedArtifacts.addAll(artifacts);
+            unResolvedArtifacts.removeAll(resolvedArtifacts);
+        }
+
+        // return a bean of all 3 sets.
+        status.setResolvedDependencies(resolvedArtifacts);
+        status.setUnResolvedDependencies(unResolvedArtifacts);
+
+        return status;
+    }
+
+    protected DependencyStatusSets filterMarkedDependencies(Set artifacts) throws MojoExecutionException {
+        // remove files that have markers already
+        FilterArtifacts filter = new FilterArtifacts();
+        filter.clearFilters();
+        filter.addFilter(getMarkedArtifactFilter());
+
+        Set unMarkedArtifacts;
+        try {
+            unMarkedArtifacts = filter.filter(artifacts);
+        } catch (ArtifactFilterException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+
+        // calculate the skipped artifacts
+        Set skippedArtifacts = new HashSet();
+        skippedArtifacts.addAll(artifacts);
+        skippedArtifacts.removeAll(unMarkedArtifacts);
+
+        return new DependencyStatusSets(unMarkedArtifacts, null, skippedArtifacts);
+    }
+
+    protected void copyFile(File artifact, File destFile) throws MojoExecutionException {
+        try {
+            getLog().info("Copying " + (this.outputAbsoluteArtifactFilename ? artifact.getAbsolutePath() : artifact.getName()) + " to " + destFile);
+            FileUtils.copyFile(artifact, destFile);
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error copying artifact from " + artifact + " to " + destFile, e);
+        }
+    }
+
+    private File getClassesDirectory() {
+        final File outputDirectory = projectBuildDirectory;
+        return new File(outputDirectory, "classes");
+    }
+
+    private File getDependenciesDirectory() {
+        return new File(getClassesDirectory(), "META-INF/bundled-dependencies");
+    }
+
+    private void makeBundle() throws MojoExecutionException {
+        File bundleFile = createArchive();
+
+        if (classifier != null) {
+            projectHelper.attachArtifact(project, "bundle", classifier, bundleFile);
+        } else {
+            project.getArtifact().setFile(bundleFile);
+        }
+    }
+
+    public File createArchive() throws MojoExecutionException {
+        final File outputDirectory = projectBuildDirectory;
+        File bundleFile = getBundleFile(outputDirectory, finalName, classifier);
+        MavenArchiver archiver = new MavenArchiver();
+        archiver.setArchiver(jarArchiver);
+        archiver.setOutputFile(bundleFile);
+        archive.setForced(forceCreation);
+
+        try {
+            File contentDirectory = getClassesDirectory();
+            if (!contentDirectory.exists()) {
+                getLog().warn("BUNDLE will be empty - no content was marked for inclusion!");
+            } else {
+                archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
+            }
+
+            File existingManifest = defaultManifestFile;
+            if (useDefaultManifestFile && existingManifest.exists() && archive.getManifestFile() == null) {
+                getLog().info("Adding existing MANIFEST to archive. Found under: " + existingManifest.getPath());
+                archive.setManifestFile(existingManifest);
+            }
+
+            // automatically add the artifact id, group id, and version to the manifest
+            archive.addManifestEntry(packageIDPrefix + "-Id", bundleId);
+            archive.addManifestEntry(packageIDPrefix + "-Group", bundleGroup);
+            archive.addManifestEntry(packageIDPrefix + "-Version", bundleVersion);
+
+            // look for a bundle dependency
+            BundleDependency bundleDependency = getBundleDependency();
+            if (bundleDependency != null) {
+                final String bundleDependencyGroup = notEmpty(this.bundleDependencyGroup) ? this.bundleDependencyGroup : bundleDependency.getGroupId();
+                final String bundleDependencyId = notEmpty(this.bundleDependencyId) ? this.bundleDependencyId : bundleDependency.getArtifactId();
+                final String bundleDependencyVersion = notEmpty(this.bundleDependencyVersion) ? this.bundleDependencyVersion : bundleDependency.getVersion();
+
+                archive.addManifestEntry(packageIDPrefix + "-Dependency-Group", bundleDependencyGroup);
+                archive.addManifestEntry(packageIDPrefix + "-Dependency-Id", bundleDependencyId);
+                archive.addManifestEntry(packageIDPrefix + "-Dependency-Version", bundleDependencyVersion);
+            }
+
+            // add build information when available
+
+            if (notEmpty(buildTag)) {
+                archive.addManifestEntry("Build-Tag", buildTag);
+            }
+            if (notEmpty(buildBranch)) {
+                archive.addManifestEntry("Build-Branch", buildBranch);
+            }
+            if (notEmpty(buildRevision)) {
+                archive.addManifestEntry("Build-Revision", buildRevision);
+            }
+
+            SimpleDateFormat dateFormat = new SimpleDateFormat(BUILD_TIMESTAMP_FORMAT);
+            archive.addManifestEntry("Build-Timestamp", dateFormat.format(new Date()));
+
+            archive.addManifestEntry("Clone-During-Instance-Class-Loading", String.valueOf(cloneDuringInstanceClassLoading));
+
+            archiver.createArchive(session, project, archive);
+            return bundleFile;
+        } catch (ArchiverException | MojoExecutionException | ManifestException | IOException | DependencyResolutionRequiredException e) {
+            throw new MojoExecutionException("Error assembling BUNDLE", e);
+        }
+    }
+
+    private boolean notEmpty(String value) {
+        return value != null && !value.isEmpty();
+    }
+
+    private String[] getIncludes() {
+        if (includes != null && includes.length > 0) {
+            return includes;
+        }
+        return DEFAULT_INCLUDES;
+    }
+
+    private String[] getExcludes() {
+        if (excludes != null && excludes.length > 0) {
+            return excludes;
+        }
+        return DEFAULT_EXCLUDES;
+    }
+
+    protected File getBundleFile(File basedir, String finalName, String classifier) {
+        if (classifier == null) {
+            classifier = "";
+        } else if (classifier.trim().length() > 0 && !classifier.startsWith("-")) {
+            classifier = "-" + classifier;
+        }
+
+        return new File(basedir, finalName + classifier + "." + packageType);
+    }
+
+    private BundleDependency getBundleDependency() throws MojoExecutionException {
+        BundleDependency bundleDependency = null;
+
+        // get bundle dependencies
+        FilterArtifacts filter = new FilterArtifacts();
+        filter.addFilter(new TypeFilter(packageType, ""));
+
+        // start with all artifacts.
+        Set artifacts = project.getArtifacts();
+
+        // perform filtering
+        try {
+            artifacts = filter.filter(artifacts);
+        } catch (ArtifactFilterException e) {
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+
+        // ensure there is a single bundle dependency
+        if (artifacts.size() > 1) {
+            throw new MojoExecutionException("Each Bundle represents a ClassLoader. A Bundle dependency allows that Bundle's ClassLoader to be "
+                    + "used as the parent of this Bundle's ClassLoader. As a result, only a single Bundle dependency is allowed.");
+        } else if (artifacts.size() == 1) {
+            final Artifact artifact = (Artifact) artifacts.iterator().next();
+
+            bundleDependency = new BundleDependency(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
+        }
+
+        return bundleDependency;
+    }
+
+    private static class BundleDependency {
+
+        final String groupId;
+        final String artifactId;
+        final String version;
+
+        public BundleDependency(String groupId, String artifactId, String version) {
+            this.groupId = groupId;
+            this.artifactId = artifactId;
+            this.version = version;
+        }
+
+        public String getGroupId() {
+            return groupId;
+        }
+
+        public String getArtifactId() {
+            return artifactId;
+        }
+
+        public String getVersion() {
+            return version;
+        }
+    }
+
+}


Mime
View raw message