Skip to content

Commit c10162f

Browse files
joroKr21hubertp
andauthored
Generate Automatic-Module-Name attribute (#1375) (#1400)
* Generate `Automatic-Module-Name` attribute As it stands, Java 9 Platform Module System cannot infer module name from shapeless' jars due to cross compilation (underscores in `_2.xx`). This simple change adds an `Automatic-Module-Name` attribute to MANIFEST, making it possible to require `shapeless` modules, rather than going through various repackaaging hacks. A proper modularization would include definition of `module-info.java` but that's outside the scope. * Use shapeless Java module name for core --------- Co-authored-by: Hubert Plociniczak <[email protected]>
1 parent 6adaa1c commit c10162f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

build.sbt

+5-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ lazy val commonSettings = crossVersionSharedSources ++ Seq(
112112
)
113113
)
114114

115+
lazy val javaModuleName = settingKey[String]("Java module name")
115116
lazy val jsSourceMapSettings = Def.settings(
116117
scalacOptions += {
117118
val tagOrHash =
@@ -160,7 +161,7 @@ lazy val coreTestMacros = crossProject(JSPlatform, JVMPlatform, NativePlatform)
160161
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
161162
.crossType(CrossType.Full)
162163
.configureCross(configureJUnit)
163-
.settings(moduleName := "shapeless")
164+
.settings(moduleName := "shapeless", javaModuleName := "shapeless")
164165
.settings(commonSettings)
165166
.settings(publishSettings)
166167
.configureCross(buildInfoSetup)
@@ -180,7 +181,7 @@ lazy val scratch = crossProject(JSPlatform, JVMPlatform, NativePlatform)
180181
.crossType(CrossType.Pure)
181182
.configureCross(configureJUnit)
182183
.dependsOn(core)
183-
.settings(moduleName := "scratch")
184+
.settings(moduleName := "scratch", javaModuleName := "shapeless.scratch")
184185
.settings(commonSettings)
185186
.settings(noPublishSettings)
186187

@@ -238,7 +239,8 @@ lazy val publishSettings = Seq(
238239
developers := List(
239240
Developer("milessabin", "Miles Sabin", "", url("http://milessabin.com/blog")),
240241
Developer("joroKr21", "Georgi Krastev", "[email protected]", url("https://twitter.com/Joro_Kr"))
241-
)
242+
),
243+
packageOptions += Package.ManifestAttributes("Automatic-Module-Name" -> javaModuleName.value),
242244
)
243245

244246
lazy val noPublishSettings =

0 commit comments

Comments
 (0)