Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala-js 1.0.6 does not contains classes #119

Closed
etorreborre opened this issue Jul 4, 2017 · 19 comments
Closed

Scala-js 1.0.6 does not contains classes #119

etorreborre opened this issue Jul 4, 2017 · 19 comments

Comments

@etorreborre
Copy link

1.0.6 is published as a bundle and does not contain classes like 1.0.5

image

image

Could you please publish the latest version as a normal jar?

@lrytz
Copy link
Member

lrytz commented Jul 4, 2017

This might be my bad, I'm taking a look.

@lrytz
Copy link
Member

lrytz commented Jul 4, 2017

My observations: if I run

> clean
[success] Total time: 0 s, completed Jul 4, 2017 11:04:55 AM
> scala-parser-combinatorsJS/publishLocal
...

$ unzip -l js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
Archive:  js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
      387  07-04-2017 11:05   META-INF/MANIFEST.MF
      122  07-04-2017 11:04   scala-parser-combinators-js.properties
---------                     -------
      509                     2 files

However, with package, the content is there:

> clean
[success] Total time: 0 s, completed Jul 4, 2017 11:05:48 AM
> scala-parser-combinatorsJS/package
...

$ unzip -l js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
Archive:  js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
      396  07-04-2017 11:05   META-INF/MANIFEST.MF
...
     4168  07-04-2017 11:05   scala/util/parsing/combinator/Parsers$Parser$$anon$5.sjsir
     2429  07-04-2017 11:05   scala/util/parsing/combinator/Parsers$$tilde$.sjsir
     2184  07-04-2017 11:05   scala/util/parsing/json/JSONObject$.sjsir
     2784  07-04-2017 11:05   scala/util/parsing/combinator/token/Tokens$ErrorToken$.sjsir
     1404  07-04-2017 11:05   scala/util/parsing/json/JSONType.class
    11781  07-04-2017 11:05   scala/util/parsing/combinator/RegexParsers.class
...

I have very little experience with Scala.js. @sjrd, is the above expected?

@lrytz
Copy link
Member

lrytz commented Jul 4, 2017

Potentially relevant changes between 1.0.5 and 1.0.6:

@sjrd
Copy link
Member

sjrd commented Jul 4, 2017

is the above expected?

Definitely not. Scala.js jars published on Maven/Bintray/etc. look very much like JVM jars. They just have .sjsir files in addition to .class files. They should not be virtually empty like in your listing above.

@lrytz
Copy link
Member

lrytz commented Jul 4, 2017

OK, thanks, I'll have to do some digging in sbt :)

@lrytz
Copy link
Member

lrytz commented Jul 4, 2017

I didn't find the issue. show scala-parser-combinatorsJS/packageBin::mappings (which is shows up as a dependency of package) looks right, but i couldn't figure out from the dependencies of publishLocal how the published jar is biult.

> show scala-parser-combinatorsJS/*:publishLocal::packagedArtifacts
... Artifact(scala-parser-combinators,bundle,jar,None,List(compile),None,Map()) -> /Users/luc/scala/scala-parser-combinators/js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar ...

$ unzip -l /Users/luc/scala/scala-parser-combinators/js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
Archive:  /Users/luc/scala/scala-parser-combinators/js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
      387  07-04-2017 14:55   META-INF/MANIFEST.MF
      122  07-04-2017 14:55   scala-parser-combinators-js.properties
---------                     -------
      509                     2 files

But then I don't know how that jar is built:

> inspect tree scala-parser-combinatorsJS/*:publishLocal::packagedArtifacts
[info] scala-parser-combinatorsJS/*:packagedArtifacts = Task[scala.collection.immutable.Map[sbt.Artifact, java.io.File]]
>

@dwijnand
Copy link
Member

dwijnand commented Jul 4, 2017

Some exploratory notes.

To summarise:

  • package
  • publishLocal

The reason looks like it's because:

  • package uses compile:packageBin, while
  • publishLocal uses compile:packageBin::packagedArtifact

Why are these different? Because of sbt-osgi - in version 0.7.0 it redefines packageBin::packagedArtifact:

packagedArtifact in (Compile, packageBin) <<=
  (artifact in (Compile, packageBin), OsgiKeys.bundle).identityMap

(source: https://github.com/sbt/sbt-osgi/blob/v0.7.0/src/main/scala/com/typesafe/sbt/osgi/SbtOsgi.scala#L29)

Indeed running compile:osgiBundle creates a osgi bundle with no classfiles or IR files:

$ unzip -l js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
Archive:  js/target/scala-2.12/scala-parser-combinators_sjs0.6_2.12-1.0.7-SNAPSHOT.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
      387  07-04-2017 14:39   META-INF/MANIFEST.MF
      121  07-04-2017 14:39   scala-parser-combinators-js.properties
---------                     -------
      508                     2 files

As a next step I've encouraged @lrytz to upgrade to a more modern sbt-osgi 0.8.0; perhaps it doesn't clash with sbt-scalajs.

@lrytz
Copy link
Member

lrytz commented Jul 5, 2017

I did my best here, but no success so far.

Here's the branch where I upgrade sbt-scala-module to sbt-osgi 0.9.1: https://github.com/scala/sbt-scala-module/compare/master...lrytz:sbt-osgi-0.9.1?expand=1

@dwijnand there's a strange thing happening: when I add && SbtOsgi to requires, then the buildSettings of my plugin are no longer applied (see comment in the diff above).

Here's a branch of this repo using that new plugin version: https://github.com/scala/scala-parser-combinators/compare/1.0.x...lrytz:sbt-osgi-0.9.1?expand=1

Without adding && SbtOsgi things seem to work. Running scala-parser-combinatorsJVM/publishLocal (the JVM project) gives a small diff in the generated manifest, but probably OK (the Bundle-Name changed for some reason).

diff -u -r b/META-INF/MANIFEST.MF a/META-INF/MANIFEST.MF
--- b/META-INF/MANIFEST.MF	2017-07-05 10:27:04.000000000 +0200
+++ a/META-INF/MANIFEST.MF	2017-07-05 08:26:12.000000000 +0200
@@ -1,8 +1,12 @@
 Manifest-Version: 1.0
-Bnd-LastModified: 1499243224337
+Bnd-LastModified: 1499243172774
+Bundle-Description: scala-parser-combinators
+Bundle-License: http://opensource.org/licenses/BSD-3-Clause;description=
+ BSD 3-clause
 Bundle-ManifestVersion: 2
-Bundle-Name: org.scala-lang.modules.scala-parser-combinators
+Bundle-Name: scala-parser-combinators
 Bundle-SymbolicName: org.scala-lang.modules.scala-parser-combinators
+Bundle-Vendor: org.scala-lang.modules
 Bundle-Version: 1.0.7.SNAPSHOT
 Created-By: 1.8.0_131 (Oracle Corporation)
 Export-Package: scala.util.parsing.combinator;version="1.0.7.SNAPSHOT";u
@@ -26,12 +30,12 @@
  til,scala.util.parsing.combinator,scala.util.parsing.combinator.lexical
  ,scala.util.parsing.combinator.syntactical,scala.util.parsing.combinato
  r.token,scala.util.parsing.input"
-Import-Package: scala;version="[2.12,3)",scala.collection;version="[2.12
- ,3)",scala.collection.generic;version="[2.12,3)",scala.collection.immut
- able;version="[2.12,3)",scala.collection.mutable;version="[2.12,3)",sca
- la.math;version="[2.12,3)",scala.reflect;version="[2.12,3)",scala.runti
- me;version="[2.12,3)",scala.runtime.java8;version="[2.12,3)",scala.sys;
- version="[2.12,3)",scala.util;version="[2.12,3)",scala.util.matching;ve
- rsion="[2.12,3)"
+Import-Package: scala,scala.collection;version="[2.12,3)",scala.collecti
+ on.generic;version="[2.12,3)",scala.collection.immutable;version="[2.12
+ ,3)",scala.collection.mutable;version="[2.12,3)",scala.math;version="[2
+ .12,3)",scala.reflect;version="[2.12,3)",scala.runtime;version="[2.12,3
+ )",scala.runtime.java8;version="[2.12,3)",scala.sys;version="[2.12,3)",
+ scala.util,scala.util.matching;version="[2.12,3)"
 Private-Package: scala-parser-combinators.properties
-Tool: Bnd-2.1.0.20130426-122213
+Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
+Tool: Bnd-2.4.0.201411031534

However, the initial bug is not fixed, running scala-parser-combinatorsJS/publishLocal (on the JS project) still leaves an empty jar.

@dwijnand
Copy link
Member

dwijnand commented Jul 5, 2017

SbtOsgi seems to have been authored to be an AutoPlugin that doesn't auto-trigger. There is no way to force the triggering of a plugin with another plugin. For more info there is a feature request for exactly this, as well as arguments against, at sbt/sbt#2093.

Here's a few possible solutions/notes (so you can pick and choose):

  • Enable SbtOsgi, so everything gets triggered.
  • Split the ScalaModulePlugin OSGI things into a ScalaModuleOsgiPlugin (with requires SbtOsgi), so that they get applied on any project that enables SbtOsgi.
  • Consider removing/splitting scalaModuleSettings to use projectSettings.
  • Consider introducing an autoImport so that some names are auto-imported (such as scalaModuleSettings).

@lrytz
Copy link
Member

lrytz commented Jul 6, 2017

@dwijnand as far as I can tell, the change I mentioned above (https://github.com/scala/sbt-scala-module/compare/master...lrytz:sbt-osgi-0.9.1?expand=1), the SbtOsgi plugin does its work when adding the sbt-scala-module plugin, I get a manifest with OSGi stuff.

What surprised me is that adding && SbtOsgi to requires broke the buildSettings of the sbt-scala-module plugin, but I just left that away and the osgi plugin seems to do its work.

@lrytz
Copy link
Member

lrytz commented Jul 6, 2017

So to summarize, I think we are fine with the new version of SbtOsgi, we just add its settings to the scalaModuleSettings of our plugin. However, upgrading SbtOsgi didn't solve the conflict with the Scala.js plugin, and we still end up with an (almost) empty sjs-jar.

@etorreborre
Copy link
Author

Thanks for still pushing on this issue @lrytz. Would it make sense to remove the Osgi plugin and do a normal release so that we can at least get the latest version of the code officially available?

@lrytz
Copy link
Member

lrytz commented Jul 6, 2017

I guess OSGi metadata is really unnecessary in an sjs-jar, so we could enable it on the JVM project only. That would be easy enough.

@sjrd
Copy link
Member

sjrd commented Jul 6, 2017

That would indeed make sense!

lrytz added a commit to lrytz/sbt-scala-module that referenced this issue Jul 6, 2017
Move jvm-specific settings from scalaModuleSettings to a new
scalaModuleSettingsJVM setting. This means that JVM projects in
scala modules now have to add bot `scalaModuleSettings` and
`scalaModuleSettingsJVM`.

Adding sbt-osgi settings in a scala-js project caused the published
jar to be empty (scala/scala-parser-combinators#119).
lrytz added a commit to lrytz/sbt-scala-module that referenced this issue Jul 6, 2017
Move jvm-specific settings from scalaModuleSettings to a new
scalaModuleSettingsJVM setting. This means that JVM projects in
scala modules now have to add bot `scalaModuleSettings` and
`scalaModuleSettingsJVM`.

Adding sbt-osgi settings in a scala-js project caused the published
jar to be empty (scala/scala-parser-combinators#119).

Upgrades sbt-osgi to the latest version.

Also anticipates the new optimizer settings in 2.12.3
(scala/scala#5964).
@lrytz
Copy link
Member

lrytz commented Jul 6, 2017

OK, that worked. PR scala/sbt-scala-module#27, will release a new version of the sbt-scala-module once it's merged.

lrytz added a commit to lrytz/sbt-scala-module that referenced this issue Jul 6, 2017
Move jvm-specific settings from scalaModuleSettings to a new
scalaModuleSettingsJVM setting. This means that JVM projects in
scala modules now have to add bot `scalaModuleSettings` and
`scalaModuleSettingsJVM`.

Adding sbt-osgi settings in a scala-js project caused the published
jar to be empty (scala/scala-parser-combinators#119).

Upgrades sbt-osgi to the latest version.

Also anticipates the new optimizer settings in 2.12.3
(scala/scala#5964).
lrytz added a commit to lrytz/sbt-scala-module that referenced this issue Jul 7, 2017
Move jvm-specific settings from scalaModuleSettings to a new
scalaModuleSettingsJVM setting. This means that JVM projects in
scala modules now have to add bot `scalaModuleSettings` and
`scalaModuleSettingsJVM`.

Adding sbt-osgi settings in a scala-js project caused the published
jar to be empty (scala/scala-parser-combinators#119).

Upgrades sbt-osgi to the latest version.

Also anticipates the new optimizer settings in 2.12.3
(scala/scala#5964).
lrytz added a commit to lrytz/scala-parser-combinators that referenced this issue Jul 11, 2017
Add osgi settings only to the `JVM` project. In the JS project they
caused the resulting jar to be empty.

Fixes scala#119

Adds MiMa checking to the JS jar.

Minor cleanups in the build definition. The scala-js sbt plugin is
no longer explicitly added, as it's already available through the
sbt-scala-module plugin.
lrytz added a commit to lrytz/scala-parser-combinators that referenced this issue Jul 11, 2017
Add osgi settings only to the `JVM` project. In the JS project they
caused the resulting jar to be empty.

Fixes scala#119

Adds MiMa checking to the JS jar.

Minor cleanups in the build definition. The scala-js sbt plugin is
no longer explicitly added, as it's already available through the
sbt-scala-module plugin.
lrytz added a commit to lrytz/scala-parser-combinators that referenced this issue Jul 11, 2017
Add osgi settings only to the `JVM` project. In the JS project they
caused the resulting jar to be empty.

Fixes scala#119

Adds MiMa checking to the JS jar.

Minor cleanups in the build definition.
lrytz added a commit to lrytz/scala-parser-combinators that referenced this issue Jul 11, 2017
Add osgi settings only to the `JVM` project. In the JS project they
caused the resulting jar to be empty.

Fixes scala#119

Adds MiMa checking to the JS jar.

Minor cleanups in the build definition.
lrytz added a commit to lrytz/scala-parser-combinators that referenced this issue Jul 11, 2017
Add osgi settings only to the `JVM` project. In the JS project they
caused the resulting jar to be empty.

Fixes scala#119

Adds MiMa checking to the JS jar.

Minor cleanups in the build definition.
lrytz added a commit to lrytz/scala-parser-combinators that referenced this issue Jul 11, 2017
Add osgi settings only to the `JVM` project. In the JS project they
caused the resulting jar to be empty.

Fixes scala#119

Adds MiMa checking to the JS jar.

Minor cleanups in the build definition.
@cheeseng
Copy link

cheeseng commented Dec 2, 2017

@lrytz any update on this? waiting for correct 2.13.0-M2 support in 1.0.7 :)

@SethTisue
Copy link
Member

@lrytz any update on this? waiting for correct 2.13.0-M2 support in 1.0.7 :)

see #130

@gourlaysama
Copy link
Member

1.0.7 has been released with working scala-js support for 2.13.0-M2, see #130.

@SethTisue
Copy link
Member

@cheeseng and 1.1.0 is coming soon with 2.13.0-M3 support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants