diff --git a/README.md b/README.md index 09f85989c..ffd37a5aa 100644 --- a/README.md +++ b/README.md @@ -386,6 +386,15 @@ Welcome to the Ammonite Repl 0.7.0 @ ``` +Fetch with module level attributes, as opposed to e.g. `--classifier` is applied globally. +``` +$ ./coursier fetch org.apache.avro:avro:1.7.4,classifier=tests --artifact-type test-jar,jar +``` + +Fetch and generate a machine readable json report. [Json Report Documentation](/doc/cli.md) +``` +$ ./coursier fetch org.apache.avro:avro:1.7.4 --json-output-file report.json +``` diff --git a/cli/src/main/scala-2.11/coursier/cli/util/JsonReport.scala b/cli/src/main/scala-2.11/coursier/cli/util/JsonReport.scala index 75233c6e4..ecde1a281 100644 --- a/cli/src/main/scala-2.11/coursier/cli/util/JsonReport.scala +++ b/cli/src/main/scala-2.11/coursier/cli/util/JsonReport.scala @@ -16,12 +16,25 @@ final case class JsonPrintRequirement(fileByArtifact: Map[String, File], depToAr final case class DepNode(coord: String, files: Vector[(String, String)], dependencies: Set[String]) -final case class ReportNode(conflict_resolution: Map[String, String], dependencies: Vector[DepNode]) +final case class ReportNode(conflict_resolution: Map[String, String], dependencies: Vector[DepNode], version: String) +/** + * FORMAT_VERSION_NUMBER: Version number for identifying the export file format output. This + * version number should change when there is a change to the output format. + * + * Major Version 1.x.x : Increment this field when there is a major format change + * Minor Version x.1.x : Increment this field when there is a minor change that breaks backward + * compatibility for an existing field or a field is removed. + * Patch version x.x.1 : Increment this field when a minor format change that just adds information + * that an application can safely ignore. + * + * Note format changes in cli/README.md and update the Changelog section. + */ object ReportNode { import argonaut.ArgonautShapeless._ implicit val encodeJson = EncodeJson.of[ReportNode] implicit val decodeJson = DecodeJson.of[ReportNode] + val version = "0.0.1" } @@ -54,7 +67,7 @@ object JsonReport { DepNode(reconciledVersionStr(r), getFiles(r).toVector, acc.toSet) }) - val report = ReportNode(conflictResolutionForRoots, rootDeps.toVector) + val report = ReportNode(conflictResolutionForRoots, rootDeps.toVector, ReportNode.version) printer.pretty(report.asJson) } diff --git a/doc/cli.md b/doc/cli.md new file mode 100644 index 000000000..b134c5516 --- /dev/null +++ b/doc/cli.md @@ -0,0 +1,148 @@ +# CLI Documentation + +## Json Report + +When invoking coursier cli with +``` +fetch -t --json-output-file +``` + +The report will contain the info about resolved modules and their relationships. + +## Format and Version Change Log + +### 0.0.1 + +Add 'version' field to the report. + +``` +{ + "version": "0.0.1", + "conflict_resolution": { + ... + }, + "dependencies": [ + ... + ] +} +``` + +### Initial version (before we add the version to the report) + +``` +{ + "conflict_resolution": { + "org:name:version" (requested): "org:name:version" (reconciled) + }, + "dependencies": [ + { + "coord": "orgA:nameA:versionA", + "files": [ + [ + , + + ] + ], + "dependencies": [ // coodinates for its transitive dependencies + , + , + ] + }, + { + "coord": "orgB:nameB:versionB", + "files": [ + [ + , + + ] + ], + "dependencies": [ // coodinates for its transitive dependencies + , + , + ] + }, + ] +} +``` +For example: +``` +fetch -t org.apache.avro:trevni-avro:1.8.2 org.slf4j:slf4j-api:1.7.6 --json-output-file x.out + Result: +├─ org.apache.avro:trevni-avro:1.8.2 +│ ├─ org.apache.avro:trevni-core:1.8.2 +│ │ ├─ org.apache.commons:commons-compress:1.8.1 +│ │ ├─ org.slf4j:slf4j-api:1.7.7 +│ │ └─ org.xerial.snappy:snappy-java:1.1.1.3 +│ └─ org.slf4j:slf4j-api:1.7.7 +└─ org.slf4j:slf4j-api:1.7.6 -> 1.7.7 +``` +would produce the following json file: +``` +$ jq < x.out +{ + "conflict_resolution": { + "org.slf4j:slf4j-api:1.7.6": "org.slf4j:slf4j-api:1.7.7" + }, + "dependencies": [ + { + "coord": "org.apache.avro:trevni-core:1.8.2", + "files": [ + [ + "", + "/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/avro/trevni-core/1.8.2/trevni-core-1.8.2.jar" + ] + ], + "dependencies": [ + "org.slf4j:slf4j-api:1.7.7", + "org.xerial.snappy:snappy-java:1.1.1.3", + "org.apache.commons:commons-compress:1.8.1" + ] + }, + { + "coord": "org.apache.avro:trevni-avro:1.8.2", + "files": [ + [ + "", + "/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/avro/trevni-avro/1.8.2/trevni-avro-1.8.2.jar" + ] + ], + "dependencies": [ + "org.apache.avro:trevni-core:1.8.2", + "org.slf4j:slf4j-api:1.7.7", + "org.xerial.snappy:snappy-java:1.1.1.3", + "org.apache.commons:commons-compress:1.8.1" + ] + }, + { + "coord": "org.slf4j:slf4j-api:1.7.7", + "files": [ + [ + "", + "/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar" + ] + ], + "dependencies": [] + }, + { + "coord": "org.apache.commons:commons-compress:1.8.1", + "files": [ + [ + "", + "/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar" + ] + ], + "dependencies": [] + }, + { + "coord": "org.xerial.snappy:snappy-java:1.1.1.3", + "files": [ + [ + "", + "/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.1.3/snappy-java-1.1.1.3.jar" + ] + ], + "dependencies": [] + } + ] +} +``` \ No newline at end of file diff --git a/doc/readme/README.md b/doc/readme/README.md index a369a9d76..07dbf2ca7 100644 --- a/doc/readme/README.md +++ b/doc/readme/README.md @@ -414,6 +414,15 @@ Welcome to the Ammonite Repl 0.7.0 @ ``` +Fetch with module level attributes, as opposed to e.g. `--classifier` is applied globally. +``` +$ ./coursier fetch org.apache.avro:avro:1.7.4,classifier=tests --artifact-type test-jar,jar +``` + +Fetch and generate a machine readable json report. [Json Report Documentation](/doc/cli.md) +``` +$ ./coursier fetch org.apache.avro:avro:1.7.4 --json-output-file report.json +``` ```tut:invisible // TODO options: repositories, sources/javadoc, attributes