Skip to content

Commit 69081e6

Browse files
authored
Faster scripted test (#18116)
2 parents 574cff1 + 0c8dfae commit 69081e6

File tree

2 files changed

+78
-10
lines changed

2 files changed

+78
-10
lines changed

project/Build.scala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import complete.DefaultParsers._
1111
import pl.project13.scala.sbt.JmhPlugin
1212
import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh
1313
import sbt.Package.ManifestAttributes
14+
import sbt.PublishBinPlugin.autoImport._
1415
import sbt.plugins.SbtPlugin
1516
import sbt.ScriptedPlugin.autoImport._
1617
import xerial.sbt.pack.PackPlugin
@@ -1655,16 +1656,16 @@ object Build {
16551656
},
16561657
scriptedBufferLog := true,
16571658
scripted := scripted.dependsOn(
1658-
(`scala3-sbt-bridge` / publishLocal),
1659-
(`scala3-interfaces` / publishLocal),
1660-
(`scala3-compiler-bootstrapped` / publishLocal),
1661-
(`scala3-library-bootstrapped` / publishLocal),
1662-
(`scala3-library-bootstrappedJS` / publishLocal),
1663-
(`tasty-core-bootstrapped` / publishLocal),
1664-
(`scala3-staging` / publishLocal),
1665-
(`scala3-tasty-inspector` / publishLocal),
1666-
(`scaladoc` / publishLocal),
1667-
(`scala3-bootstrapped` / publishLocal) // Needed because sbt currently hardcodes the dotty artifact
1659+
(`scala3-sbt-bridge` / publishLocalBin),
1660+
(`scala3-interfaces` / publishLocalBin),
1661+
(`scala3-compiler-bootstrapped` / publishLocalBin),
1662+
(`scala3-library-bootstrapped` / publishLocalBin),
1663+
(`scala3-library-bootstrappedJS` / publishLocalBin),
1664+
(`tasty-core-bootstrapped` / publishLocalBin),
1665+
(`scala3-staging` / publishLocalBin),
1666+
(`scala3-tasty-inspector` / publishLocalBin),
1667+
(`scaladoc` / publishLocalBin),
1668+
(`scala3-bootstrapped` / publishLocalBin) // Needed because sbt currently hardcodes the dotty artifact
16681669
).evaluated
16691670
)
16701671

project/PublishBinPlugin.scala

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package sbt
2+
3+
import java.nio.charset.StandardCharsets.UTF_8
4+
import java.nio.file.{ FileAlreadyExistsException, Files }
5+
6+
import org.apache.ivy.core.module.id.ModuleRevisionId
7+
import sbt.Keys._
8+
import sbt.internal.librarymanagement.{ IvySbt, IvyXml }
9+
10+
/** This local plugin provides ways of publishing just the binary jar. */
11+
object PublishBinPlugin extends AutoPlugin {
12+
override def trigger = allRequirements
13+
14+
object autoImport {
15+
val publishLocalBin = taskKey[Unit]("")
16+
val publishLocalBinConfig = taskKey[PublishConfiguration]("")
17+
}
18+
import autoImport._
19+
20+
private val dummyDoc = taskKey[File]("").withRank(Int.MaxValue)
21+
override val globalSettings = Seq(publishLocalBin := (()))
22+
23+
override val projectSettings: Seq[Def.Setting[_]] = Def settings (
24+
publishLocalBin := Classpaths.publishTask(publishLocalBinConfig).value,
25+
publishLocalBinConfig := Classpaths.publishConfig(
26+
false, // publishMavenStyle.value,
27+
Classpaths.deliverPattern(crossTarget.value),
28+
if (isSnapshot.value) "integration" else "release",
29+
ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector,
30+
(publishLocalBin / packagedArtifacts).value.toVector,
31+
(publishLocalBin / checksums).value.toVector,
32+
logging = ivyLoggingLevel.value,
33+
overwrite = isSnapshot.value
34+
),
35+
publishLocalBinConfig := publishLocalBinConfig
36+
.dependsOn(
37+
// Copied from sbt.internal.
38+
Def.taskDyn {
39+
val doGen = useCoursier.value
40+
if (doGen)
41+
Def.task {
42+
val currentProject = {
43+
val proj = csrProject.value
44+
val publications = csrPublications.value
45+
proj.withPublications(publications)
46+
}
47+
IvyXml.writeFiles(currentProject, None, ivySbt.value, streams.value.log)
48+
} else
49+
Def.task(())
50+
}
51+
)
52+
.value,
53+
dummyDoc := {
54+
val dummyFile = streams.value.cacheDirectory / "doc.jar"
55+
try {
56+
Files.createDirectories(dummyFile.toPath.getParent)
57+
Files.createFile(dummyFile.toPath)
58+
} catch { case _: FileAlreadyExistsException => }
59+
dummyFile
60+
},
61+
dummyDoc / packagedArtifact := (Compile / packageDoc / artifact).value -> dummyDoc.value,
62+
publishLocalBin / packagedArtifacts :=
63+
Classpaths
64+
.packaged(Seq(Compile / packageBin, Compile / packageSrc, makePom, dummyDoc))
65+
.value
66+
)
67+
}

0 commit comments

Comments
 (0)