Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: "temurin:17"
version: "2.1.0"
- run: ./mill -i __.compile

test:
Expand Down Expand Up @@ -60,6 +61,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: ${{ matrix.JDK }}
version: "2.1.0"
- run: sudo apt-get install -y nailgun
if: runner.os == 'Linux'
# - run: .github/scripts/scala-native-setup.sh
Expand Down Expand Up @@ -94,6 +96,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: npm install && ./mill -i jsTests "$SCALA_VERSION"
shell: bash
env:
Expand All @@ -111,6 +114,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: ./mill -i __.mimaReportBinaryIssues

website-check:
Expand All @@ -133,6 +137,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: ./mill -i doc.generate --npm-install --yarn-run-build
env:
COURSIER_JNI: force
Expand All @@ -149,6 +154,7 @@ jobs:
with:
jvm: 8
apps: scalafmt:3.0.0
version: "2.1.0"
- run: scalafmt --check

publish:
Expand All @@ -167,6 +173,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: |
mv .mill-jvm-opts .mill-jvm-opts.bak
cat .mill-jvm-opts.bak | grep -v -- '-Xmx' > .mill-jvm-opts
Expand All @@ -186,7 +193,6 @@ jobs:

generate-native-launchers:
name: Test and upload native launcher ${{ matrix.OS }}
needs: test
runs-on: ${{ matrix.OS }}
strategy:
fail-fast: false
Expand All @@ -201,6 +207,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: sudo apt-get install -y nailgun
if: runner.os == 'Linux'
- run: .github/scripts/maybe-with-graalvm-home.sh nativeTests
Expand All @@ -220,7 +227,6 @@ jobs:

generate-native-static-launcher:
name: Test and upload native static launcher
needs: test
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
Expand All @@ -231,6 +237,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: sudo apt-get install -y nailgun
if: runner.os == 'Linux'
- run: .github/scripts/maybe-with-graalvm-home.sh nativeStaticTests
Expand All @@ -247,7 +254,6 @@ jobs:

generate-native-mostly-static-launcher:
name: Test and upload native mostly static launcher
needs: test
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
Expand All @@ -258,6 +264,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: sudo apt-get install -y nailgun
if: runner.os == 'Linux'
- run: .github/scripts/maybe-with-graalvm-home.sh nativeMostlyStaticTests
Expand Down Expand Up @@ -286,6 +293,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- name: Wait for sync to Central
run: ./mill -i waitForSync
- name: Copy artifacts
Expand All @@ -311,6 +319,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- uses: actions/download-artifact@v3
with:
name: launchers
Expand All @@ -333,6 +342,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: .github/scripts/scala-cli.sh .github/scripts/UpdateBrewFormula.scala
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Expand All @@ -354,6 +364,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: npm install && export PATH="$PATH:$(pwd)/node_modules/bower/bin" && ./mill -i updateWebsite
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
Expand All @@ -375,6 +386,7 @@ jobs:
- uses: coursier/[email protected]
with:
jvm: 8
version: "2.1.0"
- run: npm install && export PATH="$PATH:$(pwd)/node_modules/bower/bin" && ./mill -i updateWebsite
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
15 changes: 14 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,20 @@ object `bootstrap-launcher` extends BootstrapLauncher { self =>
`windows-ansi`.ps.sources()
}
def resources = T.sources {
super.resources() ++ directories.resources()
(super.resources() ++ directories.resources()).flatMap { ref =>
val dir = ref.path
if (os.exists(dir) && os.isDir(dir)) {
val nonIgnoredFiles = os.walk(dir)
.filter(os.isFile(_))
.map(_.relativeTo(dir))
.filter(!_.startsWith(os.sub / "META-INF" / "native-image"))
if (nonIgnoredFiles.isEmpty) Nil
else
sys.error(s"Resource directory $dir contains unexpected resources $nonIgnoredFiles")
}
else
Seq(ref)
}
}
def proguardClassPath = T {
proguard.runClasspath()
Expand Down
152 changes: 107 additions & 45 deletions modules/cli-tests/src/main/scala/coursier/clitests/BootstrapTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.util.{Locale, UUID}
import java.util.regex.Pattern
import java.util.zip.ZipFile

import scala.collection.JavaConverters._
import scala.concurrent.duration.Duration
import scala.io.{Codec, Source}
import scala.util.Properties
Expand All @@ -16,12 +17,10 @@ import coursier.clitests.util.TestAuthProxy
import coursier.dependencyString
import utest._

abstract class BootstrapTests extends TestSuite {
abstract class BootstrapTests extends TestSuite with LauncherOptions {

def launcher: String
def assembly: String
def acceptsDOptions: Boolean = true
def acceptsJOptions: Boolean = true

def overrideProguarded: Option[Boolean] =
None
Expand Down Expand Up @@ -231,34 +230,32 @@ abstract class BootstrapTests extends TestSuite {
}
}

test("java.class.path property in expansion") {
test("java_class_path property in expansion") {
TestUtil.withTempDir { tmpDir =>
LauncherTestUtil.run(
args = Seq(
launcher,
"bootstrap",
"-o",
"cs-props-1",
"--property",
"foo=${java.class.path}",
TestUtil.propsDepStr
) ++ extraOptions,
directory = tmpDir
)
val output = LauncherTestUtil.output(
Seq("./cs-props-1", "foo"),
keepErrorOutput = false,
directory = tmpDir
)
val pwd = if (Properties.isWin) os.Path(os.pwd.toIO.getCanonicalFile) else os.pwd
val tmpDir0 = os.Path(if (Properties.isWin) tmpDir.getCanonicalFile else tmpDir, pwd)
os.proc(
LauncherTestUtil.adaptCommandName(launcher, tmpDir),
"bootstrap",
"-o",
"cs-props-1",
"--property",
"foo=${java.class.path}__${java.class.path}",
TestUtil.propsDepStr,
extraOptions
).call(cwd = tmpDir0)
val output = os.proc(LauncherTestUtil.adaptCommandName("./cs-props-1", tmpDir), "foo")
.call(cwd = tmpDir0)
.out.text()
if (Properties.isWin) {
val outputElems = new File(tmpDir, "./cs-props-1").getCanonicalPath +: TestUtil.propsCp
val expectedOutput = outputElems.mkString(File.pathSeparator) + System.lineSeparator()
val outputElems =
((tmpDir0 / "cs-props-1").toString +: TestUtil.propsCp).mkString(File.pathSeparator)
val expectedOutput = outputElems + "__" + outputElems + System.lineSeparator()
assert(output.replace("\\\\", "\\") == expectedOutput)
}
else {
val expectedOutput =
("./cs-props-1" +: TestUtil.propsCp).mkString(File.pathSeparator) +
System.lineSeparator()
val cp = ("./cs-props-1" +: TestUtil.propsCp).mkString(File.pathSeparator)
val expectedOutput = cp + "__" + cp + System.lineSeparator()
assert(output == expectedOutput)
}
}
Expand Down Expand Up @@ -363,27 +360,36 @@ abstract class BootstrapTests extends TestSuite {
}
}

test("hybrid with shared dep java.class.path") {
test("hybrid with shared dep java class path") {
TestUtil.withTempDir { tmpDir =>
LauncherTestUtil.run(
args = Seq(
launcher,
"bootstrap",
"-o",
"cs-props-hybrid-shared",
TestUtil.propsDepStr,
"io.get-coursier:echo:1.0.2",
"--shared",
"io.get-coursier:echo",
"--hybrid"
) ++ extraOptions,
directory = tmpDir
)
val output = LauncherTestUtil.output(
Seq("./cs-props-hybrid-shared", "java.class.path"),
keepErrorOutput = false,
directory = tmpDir
val tmpDir0 = os.Path(tmpDir, os.pwd)
os.proc(
LauncherTestUtil.adaptCommandName(launcher, tmpDir),
"bootstrap",
"-o",
"cs-props-hybrid-shared",
TestUtil.propsDepStr,
"io.get-coursier:echo:1.0.2",
"--shared",
"io.get-coursier:echo",
"--hybrid",
extraOptions
).call(cwd = tmpDir0)

val zf = new ZipFile((tmpDir0 / "cs-props-hybrid-shared").toIO)
val nativeImageEntries = zf.entries()
.asScala
.filter(_.getName.startsWith("META-INF/native-image/"))
.toVector
zf.close()
assert(nativeImageEntries.isEmpty)

val output = os.proc(
LauncherTestUtil.adaptCommandName("./cs-props-hybrid-shared", tmpDir),
"java.class.path"
)
.call(cwd = tmpDir0)
.out.text(Codec.default)
if (Properties.isWin) {
val expectedOutput =
new File(tmpDir, "./cs-props-hybrid-shared").getCanonicalPath + System.lineSeparator()
Expand All @@ -396,6 +402,43 @@ abstract class BootstrapTests extends TestSuite {
}
}

test("hybrid with rules") {
TestUtil.withTempDir { tmpDir =>
val tmpDir0 = os.Path(tmpDir, os.pwd)

def generate(output: String, extraArgs: String*): Unit =
os.proc(
LauncherTestUtil.adaptCommandName(launcher, tmpDir),
"bootstrap",
"-o",
output,
TestUtil.propsDepStr,
"io.get-coursier:echo:1.0.2",
"--shared",
"io.get-coursier:echo",
"--hybrid",
extraArgs,
extraOptions
).call(cwd = tmpDir0)

generate("base")
generate("with-rule", "-R", "exclude:coursier/echo/Echo.class")

def hasEchoEntry(output: String): Boolean = {
val zf = new ZipFile((tmpDir0 / output).toIO)
try
zf.entries()
.asScala
.exists(_.getName == "coursier/echo/Echo.class")
finally
zf.close()
}

assert(hasEchoEntry("base"))
assert(!hasEchoEntry("with-rule"))
}
}

test("standalone") {
TestUtil.withTempDir { tmpDir =>
LauncherTestUtil.run(
Expand Down Expand Up @@ -1028,5 +1071,24 @@ abstract class BootstrapTests extends TestSuite {
}
}
}

test("hybrid with coursier dependency") {
TestUtil.withTempDir("hybrid-cs") { tmpDir =>
os.proc(
launcher,
"bootstrap",
"--hybrid",
"sh.almond:::scala-kernel:0.13.6",
"--shared",
"sh.almond:::scala-kernel-api",
"-r",
"jitpack",
"--scala",
"2.12.17",
"-o",
"almond212"
).call(cwd = os.Path(tmpDir, os.pwd))
}
}
}
}
Loading