You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/12/01 15:33:54 UTC
[26/48] tinkerpop git commit: TINKERPOP-1562 Deprecated Artifact
TINKERPOP-1562 Deprecated Artifact
Moved it to a new home as the hole plugin package is going to go away in 3.3.0
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/57ea7388
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/57ea7388
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/57ea7388
Branch: refs/heads/TINKERPOP-1562
Commit: 57ea73881076a6fb106d444f63f284c478714f1e
Parents: ce4d96c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Nov 29 09:39:10 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Dec 1 06:41:43 2016 -0500
----------------------------------------------------------------------
.../groovy/util/DependencyGrabber.groovy | 15 ++--
.../gremlin/groovy/plugin/Artifact.java | 2 +
.../tinkerpop/gremlin/groovy/util/Artifact.java | 86 ++++++++++++++++++++
.../gremlin/groovy/plugin/ArtifactTest.java | 2 -
.../gremlin/groovy/util/ArtifactTest.java | 85 +++++++++++++++++++
5 files changed, 182 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/57ea7388/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
index 6b5242d..38e926c 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
@@ -20,11 +20,14 @@ package org.apache.tinkerpop.gremlin.groovy.util
import groovy.grape.Grape
import org.apache.commons.lang3.SystemUtils
-import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact
import org.slf4j.Logger
import org.slf4j.LoggerFactory
-import java.nio.file.*
+import java.nio.file.DirectoryStream
+import java.nio.file.FileSystems
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.StandardCopyOption
import java.util.jar.JarFile
import java.util.jar.Manifest
@@ -118,9 +121,9 @@ class DependencyGrabber {
.findAll {!filesAlreadyInPath.collect { it.getFileName().toString() }.contains(it.fileName.toFile().name)}
.each(copyTo(targetPluginPath))
getAdditionalDependencies(targetPluginPath, artifact).collect(convertUriToPath(fs))
- .findAll { !(it.fileName.toFile().name ==~ /(slf4j|logback\-classic)-.*\.jar/) }
- .findAll { !filesAlreadyInPath.collect { it.getFileName().toString() }.contains(it.fileName.toFile().name)}
- .each(copyTo(targetPluginPath))
+ .findAll { !(it.fileName.toFile().name ==~ /(slf4j|logback\-classic)-.*\.jar/) }
+ .findAll { !filesAlreadyInPath.collect { it.getFileName().toString() }.contains(it.fileName.toFile().name)}
+ .each(copyTo(targetPluginPath))
// get dependencies for the lib path. the lib path should not filter out any jars - used for reference
dependencyLocations.collect(convertUriToPath(fs)).each(copyTo(targetLibPath))
@@ -162,7 +165,7 @@ class DependencyGrabber {
* Windows places a starting forward slash in the URI that needs to be stripped off or else the
* {@code FileSystem} won't properly resolve it.
*/
- private static Closure convertUriToPath(final FileSystem fs) {
+ private static Closure convertUriToPath(def fs) {
return { URI uri ->
def p = SystemUtils.IS_OS_WINDOWS ? uri.path.substring(1) : uri.path
return fs.getPath(p)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/57ea7388/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
index 29ce7d6..7fb0bd3 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/Artifact.java
@@ -22,7 +22,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin;
* A software artifact identified by its maven coordinates.
*
* @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.util.Artifact}
*/
+@Deprecated
public class Artifact {
private final String group;
private final String artifact;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/57ea7388/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java
new file mode 100644
index 0000000..2e2554b
--- /dev/null
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/util/Artifact.java
@@ -0,0 +1,86 @@
+/*
+ * 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.tinkerpop.gremlin.groovy.util;
+
+/**
+ * A software artifact identified by its maven coordinates.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class Artifact {
+ private final String group;
+ private final String artifact;
+ private final String version;
+
+ /**
+ * Create a new instance.
+ *
+ * @param group the {@code groupId}
+ * @param artifact the {@code artifactId}
+ * @param version the {@code version}
+ */
+ public Artifact(final String group, final String artifact, final String version) {
+ if (group == null || group.isEmpty())
+ throw new IllegalArgumentException("group cannot be null or empty");
+
+ if (artifact == null || artifact.isEmpty())
+ throw new IllegalArgumentException("artifact cannot be null or empty");
+
+ if (version == null || version.isEmpty())
+ throw new IllegalArgumentException("version cannot be null or empty");
+
+ this.group = group;
+ this.artifact = artifact;
+ this.version = version;
+ }
+
+ public String getGroup() {
+ return group;
+ }
+
+ public String getArtifact() {
+ return artifact;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final Artifact a = (Artifact) o;
+
+ if (group != null ? !group.equals(a.group) : a.group != null) return false;
+ if (artifact != null ? !artifact.equals(a.artifact) : a.artifact != null) return false;
+ if (version != null ? !version.equals(a.version) : a.version != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = group != null ? group.hashCode() : 0;
+ result = 31 * result + (artifact != null ? artifact.hashCode() : 0);
+ result = 31 * result + (version != null ? version.hashCode() : 0);
+ return result;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/57ea7388/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
index a876df8..f3c96f9 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/plugin/ArtifactTest.java
@@ -18,13 +18,11 @@
*/
package org.apache.tinkerpop.gremlin.groovy.plugin;
-
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
-
/**
* @author Nghia Tran (https://github.com/n-tran)
*/
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/57ea7388/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.java
new file mode 100644
index 0000000..0e0c283
--- /dev/null
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/ArtifactTest.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.tinkerpop.gremlin.groovy.util;
+
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * @author Nghia Tran (https://github.com/n-tran)
+ */
+public class ArtifactTest {
+ @Test
+ public void shouldBeEqualIfSame() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final Artifact b = a;
+
+ assertThat(a.equals(b), is(true));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfArgumentIsNull() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final Artifact b = null;
+
+ assertThat(a.equals(b), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfArgumentIsNotAnArtifact() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final String b = " ";
+
+ assertThat(a.equals(b), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfTheGroupIsNotEqual() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final Artifact b = new Artifact("com.apacheTest.tinkerpop2","tinkergraph-gremlin","3.0.0");
+
+ assertThat(a.equals(b), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfTheArtifactIsNotEqual() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-artifact","3.0.0");
+
+ assertThat(a.equals(b), is(false));
+ }
+
+ @Test
+ public void shouldNotBeEqualIfTheVersionIsNotEqual() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","4.0.0");
+
+ assertThat(a.equals(b), is(false));
+ }
+
+ @Test
+ public void shouldBeEqual() {
+ final Artifact a = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+ final Artifact b = new Artifact("org.apache.tinkerpop","tinkergraph-gremlin","3.0.0");
+
+ assertThat(a.equals(b), is(true));
+ }
+}