2017-02-27 16:15:15 +01:00
|
|
|
#!/usr/bin/env bash
|
Add json report to fetch and local exclusion option (#692)
This patch introduces changes for cli with json output #659. Format as follows:
```
{
"conflict_resolution": {
"org:name:version" (requested): "org:name:version" (reconciled)
},
"dependencies": [
{
"coord": "orgA:nameA:versionA",
"files": [
[
<classifier>,
<path>
]
],
"dependencies": [ // coodinates for its transitive dependencies
<orgX:nameX:versionX>,
<orgY:nameY:versionY>,
]
},
{
"coord": "orgB:nameB:versionB",
"files": [
[
<classifier>,
<path>
]
],
"dependencies": [ // coodinates for its transitive dependencies
<orgX:nameX:versionX>,
<orgZ:nameZ:versionZ>,
]
},
]
}
```
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": [
[
"",
"/Users/yic/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": [
[
"",
"/Users/yic/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": [
[
"",
"/Users/yic/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": [
[
"",
"/Users/yic/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": [
[
"",
"/Users/yic/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": []
}
]
}
```
2017-12-26 19:46:35 +01:00
|
|
|
set -evx
|
2015-06-16 20:17:07 +02:00
|
|
|
|
2017-08-06 16:23:48 +02:00
|
|
|
SCALA_VERSION="${SCALA_VERSION:-${TRAVIS_SCALA_VERSION:-2.12.4}}"
|
2017-02-27 16:15:15 +01:00
|
|
|
PULL_REQUEST="${PULL_REQUEST:-${TRAVIS_PULL_REQUEST:-false}}"
|
|
|
|
|
BRANCH="${BRANCH:-${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}}"
|
|
|
|
|
PUBLISH="${PUBLISH:-0}"
|
|
|
|
|
SCALA_JS="${SCALA_JS:-0}"
|
2015-06-16 20:17:07 +02:00
|
|
|
|
2017-12-15 18:02:24 +01:00
|
|
|
VERSION="$(grep -oP '(?<=")[^"]*(?!<")' < version.sbt)"
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
JARJAR_VERSION="${JARJAR_VERSION:-1.0.1-coursier-SNAPSHOT}"
|
2015-06-16 20:17:07 +02:00
|
|
|
|
2017-07-08 14:18:03 +02:00
|
|
|
is210() {
|
|
|
|
|
echo "$SCALA_VERSION" | grep -q "^2\.10"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is211() {
|
|
|
|
|
echo "$SCALA_VERSION" | grep -q "^2\.11"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is212() {
|
|
|
|
|
echo "$SCALA_VERSION" | grep -q "^2\.12"
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
setupCoursierBinDir() {
|
|
|
|
|
mkdir -p bin
|
|
|
|
|
cp coursier bin/
|
|
|
|
|
export PATH="$(pwd)/bin:$PATH"
|
2015-06-16 20:17:07 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
downloadInstallSbtExtras() {
|
2017-07-08 14:18:03 +02:00
|
|
|
mkdir -p bin
|
2017-02-27 16:15:15 +01:00
|
|
|
curl -L -o bin/sbt https://github.com/paulp/sbt-extras/raw/9ade5fa54914ca8aded44105bf4b9a60966f3ccd/sbt
|
|
|
|
|
chmod +x bin/sbt
|
2015-06-16 20:17:07 +02:00
|
|
|
}
|
|
|
|
|
|
2017-03-23 15:19:07 +01:00
|
|
|
launchTestRepo() {
|
|
|
|
|
./scripts/launch-test-repo.sh "$@"
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-31 18:49:48 +02:00
|
|
|
launchProxyRepos() {
|
2017-06-05 18:57:29 +02:00
|
|
|
if [ "$(uname)" != "Darwin" ]; then
|
|
|
|
|
./scripts/launch-proxies.sh
|
|
|
|
|
fi
|
2017-05-31 18:49:48 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
integrationTestsRequirements() {
|
|
|
|
|
# Required for ~/.ivy2/local repo tests
|
2018-01-22 01:12:59 +01:00
|
|
|
sbt ++2.11.12 coreJVM/publishLocal ++2.12.4 cli/publishLocal
|
2017-05-15 15:32:51 +02:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
# Required for HTTP authentication tests
|
2017-03-23 15:19:07 +01:00
|
|
|
launchTestRepo --port 8080 --list-pages
|
|
|
|
|
|
|
|
|
|
# Required for missing directory listing tests (no --list-pages)
|
|
|
|
|
launchTestRepo --port 8081
|
2015-06-16 20:17:07 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
isScalaJs() {
|
|
|
|
|
[ "$SCALA_JS" = 1 ]
|
|
|
|
|
}
|
2016-05-06 13:53:55 +02:00
|
|
|
|
2017-05-04 15:25:49 +02:00
|
|
|
sbtCoursier() {
|
|
|
|
|
[ "$SBT_COURSIER" = 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sbtShading() {
|
|
|
|
|
[ "$SBT_SHADING" = 1 ]
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
runSbtCoursierTests() {
|
2017-06-06 19:51:38 +02:00
|
|
|
addPgpKeys
|
2017-06-16 18:16:47 +02:00
|
|
|
sbt ++$SCALA_VERSION sbt-plugins/publishLocal
|
2017-05-03 19:09:59 +02:00
|
|
|
if [ "$SCALA_VERSION" = "2.10" ]; then
|
2017-06-16 18:16:47 +02:00
|
|
|
sbt ++$SCALA_VERSION "sbt-coursier/scripted sbt-coursier/*" "sbt-coursier/scripted sbt-coursier-0.13/*"
|
|
|
|
|
else
|
|
|
|
|
sbt ++$SCALA_VERSION "sbt-coursier/scripted sbt-coursier/simple" # full scripted suite currently taking too long on Travis CI...
|
2017-05-03 19:09:59 +02:00
|
|
|
fi
|
2017-06-16 18:16:47 +02:00
|
|
|
sbt ++$SCALA_VERSION sbt-pgp-coursier/scripted
|
2017-02-27 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
runSbtShadingTests() {
|
2017-12-11 01:25:50 +01:00
|
|
|
sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal extra/publishLocal sbt-shared/publishLocal sbt-coursier/publishLocal "sbt-shading/scripted sbt-shading/*"
|
2017-05-03 19:09:59 +02:00
|
|
|
if [ "$SCALA_VERSION" = "2.10" ]; then
|
|
|
|
|
sbt ++$SCALA_VERSION "sbt-shading/scripted sbt-shading-0.13/*"
|
|
|
|
|
fi
|
2017-02-27 16:15:15 +01:00
|
|
|
}
|
2015-06-17 19:36:53 +02:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
jsCompile() {
|
|
|
|
|
sbt ++$SCALA_VERSION js/compile js/test:compile coreJS/fastOptJS fetch-js/fastOptJS testsJS/test:fastOptJS js/test:fastOptJS
|
|
|
|
|
}
|
2016-04-06 22:38:10 +02:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
jvmCompile() {
|
|
|
|
|
sbt ++$SCALA_VERSION jvm/compile jvm/test:compile
|
|
|
|
|
}
|
2017-01-30 22:57:24 +01:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
runJsTests() {
|
|
|
|
|
sbt ++$SCALA_VERSION js/test
|
|
|
|
|
}
|
2017-01-30 22:57:24 +01:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
runJvmTests() {
|
2017-06-05 18:57:29 +02:00
|
|
|
if [ "$(uname)" == "Darwin" ]; then
|
|
|
|
|
IT="testsJVM/it:test" # don't run proxy-tests in particular
|
|
|
|
|
else
|
|
|
|
|
IT="jvm/it:test"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sbt ++$SCALA_VERSION jvm/test $IT
|
2017-02-27 16:15:15 +01:00
|
|
|
}
|
2017-01-30 22:57:24 +01:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
validateReadme() {
|
2017-06-01 09:19:06 +02:00
|
|
|
# check that tut runs fine, and that the README doesn't change after a `sbt tut`
|
|
|
|
|
mv README.md README.md.orig
|
|
|
|
|
|
2017-11-01 00:34:02 +01:00
|
|
|
|
|
|
|
|
if is212; then
|
|
|
|
|
TUT_SCALA_VERSION="2.12.1" # Later versions seem to make tut not see the coursier binaries
|
|
|
|
|
else
|
|
|
|
|
TUT_SCALA_VERSION="$SCALA_VERSION"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sbt ++${TUT_SCALA_VERSION} tut
|
2017-06-01 09:19:06 +02:00
|
|
|
|
|
|
|
|
if cmp -s README.md.orig README.md; then
|
|
|
|
|
echo "README.md doesn't change"
|
|
|
|
|
else
|
|
|
|
|
echo "Error: README.md not the same after a \"sbt tut\":"
|
|
|
|
|
diff -u README.md.orig README.md
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2017-02-27 16:15:15 +01:00
|
|
|
}
|
2017-01-30 22:57:24 +01:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
checkBinaryCompatibility() {
|
|
|
|
|
sbt ++${SCALA_VERSION} coreJVM/mimaReportBinaryIssues cache/mimaReportBinaryIssues
|
|
|
|
|
}
|
2017-01-30 22:57:24 +01:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
testSbtCoursierJava6() {
|
2017-05-11 23:54:52 +02:00
|
|
|
sbt ++${SCALA_VERSION} coreJVM/publishLocal cache/publishLocal extra/publishLocal sbt-coursier/publishLocal
|
2017-04-21 14:06:32 +02:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
git clone https://github.com/alexarchambault/scalacheck-shapeless.git
|
|
|
|
|
cd scalacheck-shapeless
|
2018-01-09 14:32:14 +01:00
|
|
|
git checkout e11ec8b2b069ee598b20ae3f3ad6e00f5edfd7ac
|
2017-02-27 16:15:15 +01:00
|
|
|
cd project
|
|
|
|
|
clean_plugin_sbt
|
|
|
|
|
cd project
|
|
|
|
|
clean_plugin_sbt
|
|
|
|
|
cd ../..
|
|
|
|
|
docker run -it --rm \
|
|
|
|
|
-v $HOME/.ivy2/local:/root/.ivy2/local \
|
|
|
|
|
-v $(pwd):/root/project \
|
|
|
|
|
-v $(pwd)/../bin:/root/bin \
|
|
|
|
|
-e CI=true \
|
|
|
|
|
openjdk:6-jre \
|
|
|
|
|
/bin/bash -c "cd /root/project && /root/bin/sbt update"
|
|
|
|
|
cd ..
|
2017-04-21 14:06:32 +02:00
|
|
|
|
|
|
|
|
# ensuring resolution error doesn't throw NoSuchMethodError
|
|
|
|
|
mkdir -p foo/project
|
|
|
|
|
cd foo
|
|
|
|
|
echo 'libraryDependencies += "foo" % "bar" % "1.0"' >> build.sbt
|
2017-12-15 18:02:24 +01:00
|
|
|
echo 'addSbtPlugin("io.get-coursier" % "sbt-coursier" % "'"$VERSION"'")' >> project/plugins.sbt
|
2017-04-21 14:06:32 +02:00
|
|
|
echo 'sbt.version=0.13.15' >> project/build.properties
|
|
|
|
|
docker run -it --rm \
|
|
|
|
|
-v $HOME/.ivy2/local:/root/.ivy2/local \
|
|
|
|
|
-v $(pwd):/root/project \
|
|
|
|
|
-v $(pwd)/../bin:/root/bin \
|
|
|
|
|
-e CI=true \
|
|
|
|
|
openjdk:6-jre \
|
|
|
|
|
/bin/bash -c "cd /root/project && /root/bin/sbt update || true" | tee -a output
|
|
|
|
|
grep "coursier.ResolutionException: Encountered 1 error" output
|
|
|
|
|
echo "Ok, found ResolutionException in output"
|
|
|
|
|
cd ..
|
2017-02-27 16:15:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clean_plugin_sbt() {
|
|
|
|
|
mv plugins.sbt plugins.sbt0
|
|
|
|
|
grep -v coursier plugins.sbt0 > plugins.sbt || true
|
|
|
|
|
echo '
|
2017-12-15 18:02:24 +01:00
|
|
|
addSbtPlugin("io.get-coursier" % "sbt-coursier" % "'"$VERSION"'")
|
2017-02-27 16:15:15 +01:00
|
|
|
' >> plugins.sbt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
publish() {
|
|
|
|
|
sbt ++${SCALA_VERSION} publish
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-05 18:04:20 +02:00
|
|
|
testBootstrap() {
|
2018-01-22 01:12:59 +01:00
|
|
|
if is212; then
|
2017-12-26 23:56:02 +01:00
|
|
|
sbt ++${SCALA_VERSION} "project cli" pack
|
2017-12-15 18:02:24 +01:00
|
|
|
cli/target/pack/bin/coursier bootstrap -o cs-echo io.get-coursier:echo:1.0.0
|
2017-05-05 18:04:20 +02:00
|
|
|
if [ "$(./cs-echo foo)" != foo ]; then
|
|
|
|
|
echo "Error: unexpected output from bootstrapped echo command." 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-08 14:18:03 +02:00
|
|
|
testNativeBootstrap() {
|
2018-01-22 01:12:59 +01:00
|
|
|
if is212 && [ "$NATIVE" = "1" ]; then
|
2017-10-21 02:50:08 +02:00
|
|
|
sbt ++${SCALA_VERSION} "project cli" pack
|
2017-07-11 19:40:50 +02:00
|
|
|
cli/target/pack/bin/coursier bootstrap -S -o native-test io.get-coursier.scala-native::sandbox_native0.3:0.3.0-coursier-1
|
2017-07-08 14:18:03 +02:00
|
|
|
if [ "$(./native-test)" != "Hello, World!" ]; then
|
|
|
|
|
echo "Error: unexpected output from native test bootstrap." 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-06 19:51:38 +02:00
|
|
|
addPgpKeys() {
|
|
|
|
|
for key in b41f2bce 9fa47a44 ae548ced b4493b94 53a97466 36ee59d9 dc426429 3b80305d 69e0a56c fdd5c0cd 35543c27 70173ee5 111557de 39c263a9; do
|
|
|
|
|
gpg --keyserver keyserver.ubuntu.com --recv "$key"
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
|
|
|
|
|
# TODO Add coverage once https://github.com/scoverage/sbt-scoverage/issues/111 is fixed
|
|
|
|
|
|
|
|
|
|
downloadInstallSbtExtras
|
2017-07-08 14:18:03 +02:00
|
|
|
setupCoursierBinDir
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
if isScalaJs; then
|
|
|
|
|
jsCompile
|
|
|
|
|
runJsTests
|
|
|
|
|
else
|
2017-07-08 14:18:03 +02:00
|
|
|
testNativeBootstrap
|
|
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
integrationTestsRequirements
|
|
|
|
|
jvmCompile
|
|
|
|
|
|
2017-05-04 15:25:49 +02:00
|
|
|
if sbtCoursier; then
|
|
|
|
|
if is210 || is212; then
|
|
|
|
|
runSbtCoursierTests
|
|
|
|
|
fi
|
2016-04-06 22:38:10 +02:00
|
|
|
|
2017-05-04 15:25:49 +02:00
|
|
|
if is210; then
|
|
|
|
|
testSbtCoursierJava6
|
|
|
|
|
fi
|
|
|
|
|
elif sbtShading; then
|
|
|
|
|
if is210 || is212; then
|
|
|
|
|
runSbtShadingTests
|
|
|
|
|
fi
|
|
|
|
|
else
|
2017-05-31 18:49:48 +02:00
|
|
|
# Required for the proxy tests (currently CentralNexus2ProxyTests and CentralNexus3ProxyTests)
|
|
|
|
|
launchProxyRepos
|
|
|
|
|
|
2017-05-04 15:25:49 +02:00
|
|
|
runJvmTests
|
2016-04-06 22:38:10 +02:00
|
|
|
|
2017-05-05 18:04:20 +02:00
|
|
|
testBootstrap
|
|
|
|
|
|
2017-05-04 15:25:49 +02:00
|
|
|
validateReadme
|
|
|
|
|
checkBinaryCompatibility
|
2017-02-27 16:15:15 +01:00
|
|
|
fi
|
2016-11-27 13:44:14 +01:00
|
|
|
|
2017-05-04 15:25:49 +02:00
|
|
|
# Not using a jdk6 matrix entry with Travis as some sources of coursier require Java 7 to compile
|
|
|
|
|
# (even though it won't try to call Java 7 specific methods if it detects it runs under Java 6).
|
|
|
|
|
# The tests here check that coursier is nonetheless fine when run under Java 6.
|
2015-06-16 20:17:07 +02:00
|
|
|
fi
|
2015-06-17 19:36:53 +02:00
|
|
|
|
2017-02-27 16:15:15 +01:00
|
|
|
|
|
|
|
|
if [ "$PUBLISH" = 1 -a "$PULL_REQUEST" = false -a "$BRANCH" = master ]; then
|
|
|
|
|
publish
|
|
|
|
|
|
|
|
|
|
if is211 && isScalaJs; then
|
|
|
|
|
#"$(dirname "$0")/push-gh-pages.sh" "$SCALA_VERSION"
|
|
|
|
|
:
|
2015-06-18 01:00:03 +02:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|