Skip to content

Commit

Permalink
Add props program
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Apr 29, 2018
1 parent 2ef72e1 commit 805b87a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
12 changes: 11 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ lazy val native = project
Publish.settings
)

lazy val props = project
.enablePlugins(PackPlugin)
.settings(
crossPaths := false,
autoScalaLibrary := false,
name := "props",
Publish.settings
)

lazy val echo = project
.in(file("."))
.aggregate(
jvm,
native
native,
props
)
.settings(
publishArtifact := false,
Expand Down
19 changes: 19 additions & 0 deletions props/src/main/java/coursier/props/Props.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package coursier.props;

public class Props {

public static void main(String[] args) {

for (String arg: args) {
String value = System.getProperty(arg);

if (value == null) {
System.err.println("Property " + arg + " is not defined.");
System.exit(-1);
}

System.out.println(value);
}
}

}
21 changes: 21 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ if [ ! -e jvm/target/pack/bin/echo ]; then
sbt jvm/pack
fi

if [ ! -e props/target/pack/bin/props ]; then
sbt props/pack
fi


runEcho() {
jvm/target/pack/bin/echo "$@"
}

runProps() {
props/target/pack/bin/props "$@"
}

RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'
Expand All @@ -35,5 +43,18 @@ echoTest1() {
fi
}

propsTest1() {
local EXPECTED="$(pwd)"
local OUTPUT="$(runProps user.dir)"
if [ "$OUTPUT" = "$EXPECTED" ]; then
passed propsTest1
else
echo "Expected $EXPECTED, got $OUTPUT"
failed propsTest1
fi
}


echoTest1

propsTest1

0 comments on commit 805b87a

Please sign in to comment.