diff --git a/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/ArtifactInfo.groovy b/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/ArtifactInfo.groovy
index d6d854d..622072d 100644
--- a/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/ArtifactInfo.groovy
+++ b/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/ArtifactInfo.groovy
@@ -16,7 +16,7 @@
 
 package com.google.android.gms.oss.licenses.plugin
 
-class ArtifactInfo {
+class ArtifactInfo implements Comparable<ArtifactInfo> {
     private String group
     private String name
     private String fileLocation
@@ -47,4 +47,13 @@ class ArtifactInfo {
     String getVersion() {
         return version
     }
+
+    String toString() {
+        return "$group:$name:$version"
+    }
+
+    @Override
+    int compareTo(ArtifactInfo other) {
+        return toString().compareTo(other.toString())
+    }
 }
diff --git a/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/DependencyTask.groovy b/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/DependencyTask.groovy
index 75f6527..26a9bf7 100644
--- a/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/DependencyTask.groovy
+++ b/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/DependencyTask.groovy
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory
  */
 class DependencyTask extends DefaultTask {
     protected Set<String> artifactSet = []
-    protected Set<ArtifactInfo> artifactInfos = []
+    protected TreeSet<ArtifactInfo> artifactInfos = []
     protected static final String LOCAL_LIBRARY_VERSION = "unspecified"
     private static final String TEST_PREFIX = "test"
     private static final String ANDROID_TEST_PREFIX = "androidTest"
