summaryrefslogtreecommitdiffstats
path: root/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/Artifacts.scala
diff options
context:
space:
mode:
Diffstat (limited to 'bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/Artifacts.scala')
-rw-r--r--bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/Artifacts.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/Artifacts.scala b/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/Artifacts.scala
new file mode 100644
index 00000000000..3b2e52be8c4
--- /dev/null
+++ b/bundle-plugin/src/main/scala/com/yahoo/container/plugin/mojo/Artifacts.scala
@@ -0,0 +1,30 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.container.plugin.mojo
+
+
+import scala.collection.JavaConversions._
+import org.apache.maven.project.MavenProject
+import org.apache.maven.artifact.Artifact
+
+
+/**
+ * @author tonytv
+ */
+object Artifacts {
+ def getArtifacts(project : MavenProject) = {
+ type artifactSet = java.util.Set[Artifact]
+ val artifacts = project.getArtifacts.asInstanceOf[artifactSet].groupBy(_.getScope)
+
+ def isTypeJar(artifact : Artifact) = artifact.getType == "jar"
+ def getByScope(scope: String) =
+ artifacts.getOrElse(scope, Iterable.empty).partition(isTypeJar)
+
+
+ val (jarArtifactsToInclude, nonJarArtifactsToInclude) = getByScope(Artifact.SCOPE_COMPILE)
+ val (jarArtifactsProvided, nonJarArtifactsProvided) = getByScope(Artifact.SCOPE_PROVIDED)
+
+ (jarArtifactsToInclude, jarArtifactsProvided, nonJarArtifactsToInclude ++ nonJarArtifactsProvided)
+ }
+
+ def getArtifactsToInclude(project: MavenProject) = getArtifacts(project)._1
+}