Skip to content

Commit

Permalink
refactor: Put MIMA in action (#1604)
Browse files Browse the repository at this point in the history
* Put MIMA in action

Re-use MIMA in ArtifactResolver, and properly handle repoSys shutdown.

* Fix shading

* A bit bigger commit

8 tests are failing, will figure out later.

* Use released, fix tests

* Revert "A bit bigger commit"

This reverts commit 903b9a9.

* refactor: created alternative way for getting local maven repo path

* Update and use static-uber runtime

As sisu is not good candidate for minification...

* Use 1.1.2 MIMA

As older did not honor maven.repo.local in same way
as Maven would.

* Remove as it is unneeded

The static-uber behaves under minimization, unlike
sisu as there are code refs.

* LoggingEnabled was still false

No need for private member, just setup logging if needed, otherwise dont

* Disable shaded jar minimization

As it is plain broken it seems. No way to NOT remove
org.slf4j.spi package (the one we KNOW about) but who
knows what else it removes down the road.

* Simplify

* Use MIMA 2.0.0

* Add --verbose to 1st invocation

* Use MIMA 2.1.0

That has several crypto related bugs fixed:
https://github.com/maveniverse/mima/releases/tag/release-2.1.0

* fix: explicit exclude standalone static from minimization

* Update MIMA, add required dep (httpClient)

* By default non-HTTPS reposes are disabled so assertions failed.

* One more http->https

* Move off from deprecated methods

* Align minimize config w/ changes

* Up to Mima 2.3.5

That is Maven 3.9.5 + Resolver 1.9.16
Remove embedded-maven (JBang will not run within Maven embedded)
and remove unneeded append command as sisu index is already merged
in static.

* Upgrade to MIMA 2.4.0

* Upgrade MIMA to 2.4.2

* Use default it no repo given

The semantics of .repositories() changed, as it was
not possible to configure MIMA without remote repositories
but sometimes you need that. Before, it always prepended
Central.

Also, there is new "op" what to do with provided list,
when repositories discovered from settings.xml are considered
as well.

* Simplify and better express intenty

* Ignore settings.xml discovered repositories, JBang drives this

* Update ot MIMA 2.4.3

It picks up latest Resolver 1.9.18 that causes
less surprises to Windows users.

---------

Co-authored-by: Tako Schotanus <[email protected]>
Co-authored-by: Max Rydahl Andersen <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2023
1 parent 4c1221a commit 443bcce
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 404 deletions.
15 changes: 5 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,11 @@ dependencies {
implementation 'org.codejive:java-properties:0.0.5'

implementation "org.slf4j:slf4j-nop:1.7.30"
implementation "org.slf4j:jcl-over-slf4j:1.7.30"
implementation "org.jboss:jandex:2.2.3.Final"

implementation "org.apache.maven:maven-model:3.8.6"
implementation "org.apache.maven:maven-settings:3.8.6"
implementation "org.apache.maven:maven-settings-builder:3.8.6"
implementation "org.apache.maven:maven-resolver-provider:3.8.6"
implementation "org.apache.maven.resolver:maven-resolver-api:1.8.2"
implementation "org.apache.maven.resolver:maven-resolver-spi:1.8.2"
implementation "org.apache.maven.resolver:maven-resolver-impl:1.8.2"
implementation "org.apache.maven.resolver:maven-resolver-connector-basic:1.8.2"
implementation "org.apache.maven.resolver:maven-resolver-transport-file:1.8.2"
implementation "org.apache.maven.resolver:maven-resolver-transport-http:1.8.2"
implementation "eu.maveniverse.maven.mima:context:2.4.3"
runtimeOnly "eu.maveniverse.maven.mima.runtime:standalone-static:2.4.3"

testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.9.0"
testImplementation "org.junit.jupiter:junit-jupiter:5.9.0"
Expand Down Expand Up @@ -242,6 +235,8 @@ compileJava9Java {
shadowJar {
minimize() {
//exclude(dependency('org.slf4j:slf4j-api:.*'))
exclude(dependency('eu.maveniverse.maven.mima.runtime:standalone-static:.*'))
exclude(dependency('org.slf4j:jcl-over-slf4j:.*'))
exclude(dependency('org.slf4j:slf4j-nop:.*'))
exclude(dependency('org.jboss.logging:jboss-logging:.*'))
}
Expand Down
2 changes: 1 addition & 1 deletion itests/test_suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ rm -rf ~/.jbang/cache
echo Testing with `which jbang`

## init ##
assert "jbang init $SCRATCH/test.java"
assert "jbang --verbose init $SCRATCH/test.java"
assert_raises "test -f $SCRATCH/test.java" 0

assert "jbang $SCRATCH/test.java" "Hello World"
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/dev/jbang/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ public class Settings {
final public static String CONFIG_CACHE_EVICT = "cache-evict";
final public static String DEFAULT_CACHE_EVICT = "PT12H";

public static Path getLocalMavenRepo() {
return Paths.get(System .getenv()
.getOrDefault(JBANG_REPO,
(String) System .getProperties()
.getOrDefault("maven.repo.local",
System.getProperty("user.home")
+ File.separator + ".m2" + File.separator
+ "repository")))
.toAbsolutePath();
public static Path getJBangLocalMavenRepoOverride() {
String jbangRepo = System.getenv().get(JBANG_REPO);
if (jbangRepo != null) {
return Paths.get(jbangRepo);
} else {
return null;
}
}

public static Path getCacheDependencyFile() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/jbang/cli/Export.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;

import dev.jbang.Settings;
import dev.jbang.catalog.Alias;
import dev.jbang.catalog.CatalogUtil;
import dev.jbang.dependencies.ArtifactInfo;
import dev.jbang.dependencies.ArtifactResolver;
import dev.jbang.dependencies.MavenCoordinate;
import dev.jbang.source.BuildContext;
import dev.jbang.source.Project;
Expand Down Expand Up @@ -203,7 +203,7 @@ int apply(BuildContext ctx) throws IOException {
Path outputPath = exportMixin.outputFile;

if (outputPath == null) {
outputPath = Settings.getLocalMavenRepo();
outputPath = ArtifactResolver.getLocalMavenRepo();
}
// Copy the JAR
Path source = ctx.getJarFile();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/jbang/cli/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.PrintWriter;

import dev.jbang.Settings;
import dev.jbang.dependencies.ArtifactResolver;
import dev.jbang.util.Util;
import dev.jbang.util.VersionChecker;

Expand Down Expand Up @@ -39,7 +40,7 @@ public Integer doCall() {
PrintWriter out = spec.commandLine().getOut();
out.println("Cache: " + Settings.getCacheDir());
out.println("Config: " + Settings.getConfigDir());
out.println("Repository:" + Settings.getLocalMavenRepo());
out.println("Repository: " + ArtifactResolver.getLocalMavenRepo());
}

return EXIT_OK;
Expand Down
Loading

0 comments on commit 443bcce

Please sign in to comment.