-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0e38181
Showing
13 changed files
with
554 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*" | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v1 | ||
|
||
- name: coursier cache | ||
uses: actions/cache@v1 | ||
if: runner.OS == 'Linux' | ||
with: | ||
path: ~/.cache/coursier | ||
key: ${{ runner.OS }}-coursier-cache-${{ hashFiles('**/*.sbt') }} # -${{ hashFiles('project/**.scala') }} (fails for now) | ||
restore-keys: | | ||
${{ runner.OS }}-coursier-cache-${{ hashFiles('**/*.sbt') }}- | ||
${{ runner.OS }}-coursier-cache- | ||
- uses: olafurpg/setup-scala@v7 | ||
with: | ||
java-version: [email protected] | ||
|
||
- name: Compile | ||
run: csbt test | ||
|
||
publish: | ||
needs: test | ||
if: github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@v1 | ||
|
||
- name: coursier cache (Linux) | ||
uses: actions/cache@v1 | ||
if: runner.OS == 'Linux' | ||
with: | ||
path: ~/.cache/coursier | ||
key: ${{ runner.OS }}-coursier-cache-${{ hashFiles('**/*.sbt') }} # -${{ hashFiles('project/**.scala') }} (fails for now) | ||
restore-keys: | | ||
${{ runner.OS }}-coursier-cache-${{ hashFiles('**/*.sbt') }}- | ||
${{ runner.OS }}-coursier-cache- | ||
- uses: olafurpg/setup-scala@v7 | ||
|
||
- uses: olafurpg/setup-gpg@v2 | ||
|
||
- name: Release | ||
run: csbt ci-release | ||
env: | ||
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} | ||
PGP_SECRET: ${{ secrets.PGP_SECRET }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
inThisBuild(List( | ||
organization := "io.get-coursier.sbt", | ||
homepage := Some(url("https://github.com/coursier/sbt-runner")), | ||
licenses := Seq("Apache 2.0" -> url("http://opensource.org/licenses/Apache-2.0")), | ||
developers := List( | ||
Developer( | ||
"alexarchambault", | ||
"Alexandre Archambault", | ||
"", | ||
url("https://github.com/alexarchambault") | ||
) | ||
) | ||
)) | ||
|
||
// publishing | ||
sonatypeProfileName := "io.get-coursier" | ||
|
||
// pure Java | ||
crossPaths := false | ||
autoScalaLibrary := false | ||
|
||
name := "sbt-runner" | ||
|
||
resolvers += Resolver.jcenterRepo | ||
libraryDependencies += "net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") | ||
addSbtPlugin("net.aichler" % "sbt-jupiter-interface" % "0.8.3") | ||
|
||
resolvers += Resolver.jcenterRepo // for sbt-jupiter-interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package sbtrunner; | ||
|
||
import sbtrunner.args.HelpAskedException; | ||
import sbtrunner.args.ParsedArgs; | ||
import sbtrunner.args.ParsingArgumentsException; | ||
|
||
import java.io.*; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.*; | ||
|
||
public class SbtRunner { | ||
|
||
public static void main(String[] args) { | ||
Iterator<String> it = Arrays.asList(args).iterator(); | ||
ParsedArgs parsedArgs = null; | ||
try { | ||
parsedArgs = ParsedArgs.process(it); | ||
} catch (HelpAskedException ex) { | ||
try { | ||
HelpAskedException.printHelp(); | ||
System.exit(0); | ||
} catch (IOException ex0) { | ||
throw new RuntimeException(ex0); | ||
} | ||
} catch (ParsingArgumentsException | IOException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
|
||
parsedArgs.setSystemProperties(); | ||
|
||
Class<?> cls; | ||
try { | ||
cls = Class.forName("xsbt.boot.Boot"); | ||
} catch (ClassNotFoundException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
|
||
Method main; | ||
try { | ||
main = cls.getMethod("main", String[].class); | ||
} catch (NoSuchMethodException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
|
||
String[] sbtArgs = parsedArgs.getArgs(); | ||
|
||
try { | ||
main.invoke(null, (Object) sbtArgs); | ||
} catch (InvocationTargetException ex) { | ||
Throwable cause = ex.getCause(); | ||
if (cause == null) { | ||
System.err.println("Something went wrong: " + ex); | ||
ex.printStackTrace(System.err); | ||
} else | ||
throw new RuntimeException(cause); | ||
} catch (IllegalAccessException ex) { | ||
System.err.println("Something went wrong: " + ex); | ||
ex.printStackTrace(System.err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package sbtrunner.args; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class HelpAskedException extends ParsingArgumentsException { | ||
|
||
static final String helpResourcePath = "sbtrunner/help.txt"; | ||
|
||
public static void printHelp() throws IOException { | ||
try (InputStream is = Thread.currentThread() | ||
.getContextClassLoader() | ||
.getResourceAsStream(helpResourcePath)) { | ||
if (is == null) { | ||
System.err.println("[" + helpResourcePath + " resource not found]"); | ||
return; | ||
} | ||
|
||
BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); | ||
|
||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
if (!line.startsWith("#")) | ||
System.out.println(line); | ||
} | ||
} | ||
} | ||
|
||
public HelpAskedException() { | ||
super(null, 0); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/sbtrunner/args/MissingArgumentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package sbtrunner.args; | ||
|
||
public class MissingArgumentException extends ParsingArgumentsException { | ||
|
||
private final String type; | ||
private final String opt; | ||
|
||
public MissingArgumentException(String type, String opt) { | ||
super(opt + " requires <" + type + "> argument", 1); | ||
this.type = type; | ||
this.opt = opt; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
public String getOpt() { | ||
return opt; | ||
} | ||
} |
Oops, something went wrong.