Skip to content

Commit

Permalink
Support "*" entries in the Artifact Manifest for includeBuild depende…
Browse files Browse the repository at this point in the history
…ncy substitution (#53)

This is needed to make NFRT use Gradle supplied dependencies even if the
version numbers mismatch (i.e. in includeBuild scenarios).
  • Loading branch information
shartte authored Jan 2, 2025
1 parent 09a8714 commit 42dbe83
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ path for that artifact as the value. For example:

`com.google.guava\:guava\:32.1.2-jre=C\:\\path\\to\\file.jar`

If a specific version is not found in the manifest, NFRT will also check for an entry with the version `*` to support
dependency replacement scenarios.

To aid with detecting missing entries to fully cover all required artifacts, the `--warn-on-artifact-manifest-miss`
option
enables warnings when an artifact is being looked up, but not found in the manifest.
option enables warnings when an artifact is being looked up, but not found in the manifest.
NFRT will continue to download the artifact remotely in this case.

### Mojang Launcher Manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,14 @@ private Artifact getFromExternalManifest(MavenCoordinate artifactCoordinate) {
return artifact;
}

// Fall back to looking up a wildcard version for dependency replacement in includeBuild scenarios
if (!"*".equals(artifactCoordinate.version())) {
artifact = externallyProvided.get(artifactCoordinate.withVersion("*"));
if (artifact != null) {
return artifact;
}
}

if (warnOnArtifactManifestMiss && !externallyProvided.isEmpty()) {
LOG.println(" " + AnsiColor.YELLOW + "WARNING: " + AnsiColor.RESET + artifactCoordinate + " is not present in the artifact manifest");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,14 @@ public MavenCoordinate withClassifier(String classifier) {
version
);
}

public MavenCoordinate withVersion(String version) {
return new MavenCoordinate(
groupId,
artifactId,
extension,
classifier,
version
);
}
}

0 comments on commit 42dbe83

Please sign in to comment.