Skip to content

Commit 56270a6

Browse files
fix for <param>groupId:artifactId</param> syntax
1 parent 1af1f4c commit 56270a6

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Add this to the `<plugins>` section of your `pom.xml`:
4040
<plugin>
4141
<groupId>io.github.makingthematrix</groupId>
4242
<artifactId>scala-suffix-maven-plugin</artifactId>
43-
<version>0.1.0</version>
43+
<version>0.2.1</version>
4444
<configuration>
4545
<libraries>
4646
<param>your-scala-dependency</param>
@@ -56,6 +56,11 @@ Add this to the `<plugins>` section of your `pom.xml`:
5656
</plugin>
5757
```
5858
where `your-scala-dependency` is a name of your Scala dependency **without** the version suffix (if there are more than one, just add them with more `<param>` tags). This should be the same as `artifactId` in your `<dependency>` section.
59+
Or you can use:
60+
```
61+
<param>groupId:artifactId</param>
62+
```
63+
if there are more than one dependency with the same `artifactId` in your project (I noticed that `core` is a popular name).
5964

6065
The plugin modifies the dependency's JAR file in your local Maven repository. It opens the jar, reads `META-INF/MANIFEST.MF` and adds to it a line:
6166
```
@@ -89,6 +94,6 @@ Here's [a small Scala+JavaFX project, built with Maven](https://github.com/makin
8994
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`:
9095
```
9196
Compile / packageBin / packageOptions +=
92-
Package.ManifestAttributes("Automatic-Module-Name" -> name.value)
97+
Package.ManifestAttributes("Automatic-Module-Name" -> NAME)
9398
```
94-
(`name` here is the name of the library, without the version suffix).
99+
(`NAME` here is the name of the library, without the version suffix).

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>io.github.makingthematrix</groupId>
55
<artifactId>scala-suffix-maven-plugin</artifactId>
66
<packaging>maven-plugin</packaging>
7-
<version>0.2.0</version>
7+
<version>0.2.1</version>
88
<name>Scala SufFix Maven Plugin</name>
99
<url>https://github.com/makingthematrix/scala-suffix</url>
1010
<organization>

src/main/java/io/github/makingthematrix/ManifestToFix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ManifestToFix(@NotNull final File artifactFile, @NotNull final File outpu
3333
this.manifestFile = new File(outputDir, MANIFEST_MF);
3434
}
3535

36-
public boolean fixLib(@NotNull String libraryName) throws IOException {
36+
public boolean fix(@NotNull String libraryName) throws IOException {
3737
if (manifestFile.exists()) {
3838
return fixManifestFile(libraryName);
3939
} else {

src/main/java/io/github/makingthematrix/SufFixMojo.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ private Optional<Tuple2<File, String>> findManifestToFix(String libraryName) {
6565
final var groupId = split[0].trim();
6666
final var artifactId = split[1].trim();
6767
return artifacts.get().stream()
68-
.filter(art -> art.getGroupId().equals(groupId) && art.getArtifactId().equals(artifactId))
68+
.filter(art -> art.getGroupId().toLowerCase().contains(groupId) && art.getArtifactId().toLowerCase().contains(artifactId))
6969
.findAny()
7070
.map(art -> Tuple.of(art.getFile(), libraryName));
7171
} else {
72+
error("scala-suffix invalid param: " + libraryName);
7273
return Optional.empty();
7374
}
7475
} else {
7576
return artifacts.get().stream()
76-
.filter(art -> art.getArtifactId().trim().equals(libraryName))
77+
.filter(art -> art.getArtifactId().trim().toLowerCase().contains(libraryName))
7778
.findAny()
7879
.map(art -> Tuple.of(art.getFile(), libraryName));
7980
}
@@ -90,8 +91,8 @@ private void fixManifest(Tuple2<File, String> tuple) {
9091
clean();
9192
try {
9293
final var manifestToFix = new ManifestToFix(tuple._1, tempDir.get());
93-
if (manifestToFix.fixLib(tuple._2)) {
94-
info("The manifest file fixed for: " + tuple._2);
94+
if (manifestToFix.fix(tuple._2)) {
95+
info("scala-suffix: the manifest file fixed for: " + tuple._2);
9596
}
9697
} catch (IOException ex) {
9798
error(ex);

0 commit comments

Comments
 (0)