You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,13 @@ A Maven plugin which fixes Scala jars incompatibility with Java 9+.
5
5
### A bit of context
6
6
7
7
First of all, you need this plugin only in a corner case situation when:
8
+
8
9
1. You have Scala dependencies in your project.
9
10
2. You use Maven.
10
11
3. You use JDK 9 or newer.
11
12
4. At least one of your Scala dependencies lacks the `Automatic-Module-Name` property in its `MANIFEST.MF`.
12
-
13
-
If any of those points is not true, `scala-suffix-maven-plugin` will not help you. But if they are, and you're here, it's possible that it's because you have already been bitten by a problem similar to the following:
13
+
14
+
Using Maven with Scala libraries is rare, so there's not much demand to solve this issue. But if a project makes extensive use of Java libraries, it might make sense to build it with Maven instead - or if it uses a Maven plugin which has to sbt alternative, [as in my case](https://github.com/makingthematrix/scalaonandroid). So, if any of those points is not true, you will either not need `scala-suffix-maven-plugin` or it will not help you. But if they are, and you're here, it's possible that it's because you have already been bitten by a problem similar to the following:
14
15
15
16
You add a dependency to your `pom.xml` which looks somehow like this
16
17
```
@@ -31,6 +32,10 @@ You compile the project and you see this warning:
31
32
... and then when you run your program, it crashes when it tries to access the given Scala dependency.
32
33
Paraphrasing [this answer on Stack Overflow](https://stackoverflow.com/questions/48714633/automatic-module-name-containing-number/48714979#48714979), since Java 9, Java does not recognize suffixes in modules names like `_2.13` as version numbers and treat them as integral parts of modules names. So, when your project tries to use a class from the Scala dependency, it will look for `your.scala.dependency.2.13` instead of just `your.scala.dependency`, it will fail to do it, and it will crash.
33
34
35
+
### Installation
36
+
37
+
TBD. (I need some time to upload the plugin to Maven Central. Until then you would have to download the source code and compile the plugin manually, and I would prefer to spare you this).
38
+
34
39
### Usage
35
40
36
41
Add this to the `<plugins>` section of your `pom.xml`:
@@ -59,10 +64,31 @@ The plugin modifies the dependency's JAR file in your local Maven repository. It
59
64
```
60
65
Automatic-Module-Name: your-scala-dependency
61
66
```
62
-
if it is missing. If the property `Automatic-Module-Name` already exists, the plugin does nothing - we assume that in that case the dependency should already work. This prevents the plugin from modifying the same JAR file more than once.
67
+
If the property `Automatic-Module-Name` already exists, the plugin does nothing - we assume that in that case the dependency should already work. This prevents the plugin from modifying the same JAR file more than once.
63
68
64
-
####Potential problems
69
+
### Potential problems
65
70
66
71
1. If `Automatic-Module-Name` already exists but is set to a value that is still invalid for Java 9+, the plugin won't fix this.
67
72
2. The plugin changes the contents of the JAR file, but it does not update the checksum. If you check it later on, it won't match.
68
73
3. The plugin relies on that you don't need two versions of the same Scala library for different Scala versions. If you do (but... why?) it will modify only one of them and ignore the other.
If you are a creator of a Scala library, you can simply add the `Automatic-Module-Name` property to `META-INF/MANIFEST.MF` by yourself. In most cases, people will use your library with sbt and then this won't be necessary, but it won't hurt them either, and while doing this you will help people who use Maven. In case you use sbt for building your library, all you need to do is at these two lines somewhere in your `build.sbt`:
0 commit comments