Skip to content
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
- name: Build and test
if: ${{ matrix.jobtype == 1 }}
shell: bash
run: sbt -v '++ 2.12.x' scripted
run: sbt -v '++ 2.12.x' 'scripted agent/issue73'
- name: Scala 3
if: ${{ matrix.jobtype == 2 }}
shell: bash
run: sbt -v '++ 3.x' 'scripted agent/*'
run: sbt -v '++ 3.x' 'scripted agent/issue73'
12 changes: 12 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ scalacOptions ++= Seq(
)
javacOptions ++= Seq("-encoding", "UTF-8")

lazy val maxwellLib = project
.in(file("maxwell-lib"))
.settings(
name := "maxwell-lib",
organization := "sbt.javaagent.test",
autoScalaLibrary := false,
crossPaths := false,
publish := {}
)

// test agent
lazy val maxwell = project
.in(file("maxwell"))
Expand All @@ -35,6 +45,7 @@ lazy val maxwell = project
.ManifestAttributes("Premain-Class" -> "maxwell.Maxwell"),
publish := {}
)
.dependsOn(maxwellLib)

// plugin module
lazy val `sbt-javaagent` = (project.in(file(".")))
Expand All @@ -57,6 +68,7 @@ lazy val `sbt-javaagent` = (project.in(file(".")))
),
scriptedDependencies := {
(maxwell / publishLocal).value
(maxwellLib / publishLocal).value
publishLocal.value
},
(pluginCrossBuild / sbtVersion) := {
Expand Down
7 changes: 7 additions & 0 deletions maxwell-lib/src/main/java/maxwell/MaxwellLib.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package maxwell;

public final class MaxwellLib {
public static String value() {
return "maxwell lib";
}
}
1 change: 1 addition & 0 deletions maxwell/src/main/java/maxwell/Maxwell.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

public class Maxwell {
public static void premain(String agentArgs, Instrumentation instrumentation) {
System.out.println(MaxwellLib.value());
String[] output = new String[] { "Agent 86" };
if (agentArgs != null) {
output = agentArgs.split(Pattern.quote(";"));
Expand Down
9 changes: 9 additions & 0 deletions src/sbt-test/agent/issue73/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
val maxwell = "sbt.javaagent.test" % "maxwell" % sys.props("project.version") % Test

libraryDependencies += maxwell

libraryDependencies += "org.scalatest" %% "scalatest-funspec" % "3.2.20" % Test

enablePlugins(JavaAgent)

javaAgents += maxwell
1 change: 1 addition & 0 deletions src/sbt-test/agent/issue73/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.github.sbt" % "sbt-javaagent" % sys.props("project.version"))
8 changes: 8 additions & 0 deletions src/sbt-test/agent/issue73/src/test/scala/Test1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example

import org.scalatest.funspec.AnyFunSpec

class Test1 extends AnyFunSpec {
it("test 1") {
}
}
1 change: 1 addition & 0 deletions src/sbt-test/agent/issue73/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> test
Loading