@@ -269,6 +269,13 @@ object Build {
269269 // If someone puts a source file at the root (e.g., for manual testing),
270270 // don't pick it up as part of any project.
271271 sourcesInBase := false ,
272+
273+ // For compatibility with Java 9+ module system;
274+ // without Automatic-Module-Name, the module name is derived from the jar file which is invalid because of the _3 suffix.
275+ Compile / packageBin / packageOptions +=
276+ Package .ManifestAttributes (
277+ " Automatic-Module-Name" -> s " ${dottyOrganization.replaceAll(" -" ," ." )}. ${moduleName.value.replaceAll(" -" ," ." )}"
278+ )
272279 )
273280
274281 // Settings used for projects compiled only with Java
@@ -751,18 +758,9 @@ object Build {
751758 def dottyCompilerSettings (implicit mode : Mode ): sbt.Def .SettingsDefinition =
752759 if (mode == NonBootstrapped ) nonBootstrapedDottyCompilerSettings else bootstrapedDottyCompilerSettings
753760
754- lazy val `scala3-compiler` = project.in(file(" compiler" )).
755- asDottyCompiler(NonBootstrapped ).
756- settings(
757- Compile / packageBin / packageOptions +=
758- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
759- )
760- lazy val `scala3-compiler-bootstrapped` = project.in(file(" compiler" )).
761- asDottyCompiler(Bootstrapped ).
762- settings(
763- Compile / packageBin / packageOptions +=
764- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
765- )
761+ lazy val `scala3-compiler` = project.in(file(" compiler" )).asDottyCompiler(NonBootstrapped )
762+ lazy val `scala3-compiler-bootstrapped` = project.in(file(" compiler" )).asDottyCompiler(Bootstrapped )
763+
766764 def dottyCompiler (implicit mode : Mode ): Project = mode match {
767765 case NonBootstrapped => `scala3-compiler`
768766 case Bootstrapped => `scala3-compiler-bootstrapped`
@@ -776,18 +774,8 @@ object Build {
776774 ),
777775 )
778776
779- lazy val `scala3-library` = project.in(file(" library" )).
780- asDottyLibrary(NonBootstrapped ).
781- settings(
782- Compile / packageBin / packageOptions +=
783- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
784- )
785- lazy val `scala3-library-bootstrapped` : Project = project.in(file(" library" )).
786- asDottyLibrary(Bootstrapped ).
787- settings(
788- Compile / packageBin / packageOptions +=
789- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
790- )
777+ lazy val `scala3-library` = project.in(file(" library" )).asDottyLibrary(NonBootstrapped )
778+ lazy val `scala3-library-bootstrapped` : Project = project.in(file(" library" )).asDottyLibrary(Bootstrapped )
791779
792780 def dottyLibrary (implicit mode : Mode ): Project = mode match {
793781 case NonBootstrapped => `scala3-library`
@@ -811,8 +799,6 @@ object Build {
811799 (" org.scala-js" %% " scalajs-library" % scalaJSVersion).cross(CrossVersion .for3Use2_13),
812800 Compile / unmanagedSourceDirectories ++=
813801 (`scala3-library-bootstrapped` / Compile / unmanagedSourceDirectories).value,
814- Compile / packageBin / packageOptions +=
815- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" ),
816802
817803 // Configure the source maps to point to GitHub for releases
818804 scalacOptions ++= {
@@ -834,24 +820,9 @@ object Build {
834820 scalacOptions += " -source:3.0-migration"
835821 )
836822
837- lazy val `tasty-core` = project.in(file(" tasty" )).
838- asTastyCore(NonBootstrapped ).
839- settings(
840- Compile / packageBin / packageOptions +=
841- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
842- )
843- lazy val `tasty-core-bootstrapped` : Project = project.in(file(" tasty" )).
844- asTastyCore(Bootstrapped ).
845- settings(
846- Compile / packageBin / packageOptions +=
847- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
848- )
849- lazy val `tasty-core-scala2` : Project = project.in(file(" tasty" )).
850- asTastyCoreScala2.
851- settings(
852- Compile / packageBin / packageOptions +=
853- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
854- )
823+ lazy val `tasty-core` = project.in(file(" tasty" )).asTastyCore(NonBootstrapped )
824+ lazy val `tasty-core-bootstrapped` : Project = project.in(file(" tasty" )).asTastyCore(Bootstrapped )
825+ lazy val `tasty-core-scala2` : Project = project.in(file(" tasty" )).asTastyCoreScala2
855826
856827 def tastyCore (implicit mode : Mode ): Project = mode match {
857828 case NonBootstrapped => `tasty-core`
@@ -865,9 +836,7 @@ object Build {
865836 // but we always need it to be present on the JVM classpath at runtime.
866837 dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
867838 settings(
868- javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
869- Compile / packageBin / packageOptions +=
870- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
839+ javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
871840 )
872841
873842 lazy val `scala3-tasty-inspector` = project.in(file(" tasty-inspector" )).
@@ -877,9 +846,7 @@ object Build {
877846 // but we always need it to be present on the JVM classpath at runtime.
878847 dependsOn(dottyCompiler(Bootstrapped ) % " provided; compile->runtime; test->test" ).
879848 settings(
880- javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
881- Compile / packageBin / packageOptions +=
882- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" )
849+ javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value
883850 )
884851
885852 /** Scala library compiled by dotty using the latest published sources of the library */
@@ -1039,8 +1006,6 @@ object Build {
10391006 // Work around https://github.com/eclipse/lsp4j/issues/295
10401007 dependencyOverrides += " org.eclipse.xtend" % " org.eclipse.xtend.lib" % " 2.16.0" ,
10411008 javaOptions := (`scala3-compiler-bootstrapped` / javaOptions).value,
1042- Compile / packageBin / packageOptions +=
1043- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" ),
10441009
10451010 run := Def .inputTaskDyn {
10461011 val inputArgs = spaceDelimited(" <arg>" ).parsed
@@ -1344,8 +1309,6 @@ object Build {
13441309 Compile / mainClass := Some (" dotty.tools.scaladoc.Main" ),
13451310 Compile / buildInfoKeys := Seq [BuildInfoKey ](version),
13461311 Compile / buildInfoPackage := " dotty.tools.scaladoc" ,
1347- Compile / packageBin / packageOptions +=
1348- Package .ManifestAttributes (" Automatic-Module-Name" -> s " $dottyOrganization- ${name.value}" ),
13491312 BuildInfoPlugin .buildInfoScopedSettings(Compile ),
13501313 BuildInfoPlugin .buildInfoDefaultSettings,
13511314
0 commit comments