Skip to content

Commit

Permalink
Add more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Mar 12, 2024
1 parent e03fb22 commit 5990b49
Showing 1 changed file with 48 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,44 @@ public final class JavaLanguage implements Language {
public static final String NAME = "java";

public enum MavenLevel {
Maven3,
Maven4
Maven2(true, true, true, false),
Maven3(true, false, true, false),
Maven4(false, false, false, true);

private final boolean systemScope;

private final boolean systemScopeTransitive;

private final boolean brokenRuntimeResolution;

private final boolean newDependencyScopes;

MavenLevel(
boolean systemScope,
boolean systemScopeTransitive,
boolean brokenRuntimeResolution,
boolean newDependencyScopes) {
this.systemScope = systemScope;
this.systemScopeTransitive = systemScopeTransitive;
this.brokenRuntimeResolution = brokenRuntimeResolution;
this.newDependencyScopes = newDependencyScopes;
}

public boolean isSystemScope() {
return systemScope;
}

public boolean isSystemScopeTransitive() {
return systemScopeTransitive;
}

public boolean isBrokenRuntimeResolution() {
return brokenRuntimeResolution;
}

public boolean isNewDependencyScopes() {
return newDependencyScopes;
}
}

private static final String DS_NONE = "none";
Expand Down Expand Up @@ -54,9 +90,11 @@ private Map<String, JavaDependencyScope> buildDependencyScopes() {
result.put(DS_COMPILE, new JavaDependencyScope(DS_COMPILE, this, true));
result.put(DS_RUNTIME, new JavaDependencyScope(DS_RUNTIME, this, true));
result.put(DS_PROVIDED, new JavaDependencyScope(DS_PROVIDED, this, false));
result.put(DS_SYSTEM, new JavaDependencyScope(DS_SYSTEM, this, mavenLevel == MavenLevel.Maven3));
result.put(DS_TEST, new JavaDependencyScope(DS_TEST, this, false));
if (mavenLevel == MavenLevel.Maven4) {
if (mavenLevel.isSystemScope()) {
result.put(DS_SYSTEM, new JavaDependencyScope(DS_SYSTEM, this, mavenLevel.isSystemScopeTransitive()));
}
if (mavenLevel.isNewDependencyScopes()) {
result.put(DS_NONE, new JavaDependencyScope(DS_NONE, this, false));
result.put(DS_COMPILE_ONLY, new JavaDependencyScope(DS_COMPILE_ONLY, this, false));
result.put(DS_TEST_RUNTIME, new JavaDependencyScope(DS_TEST_RUNTIME, this, false));
Expand Down Expand Up @@ -105,15 +143,19 @@ private Map<String, JavaResolutionScope> buildResolutionScopes() {
new JavaResolutionScope(
RS_MAIN_RUNTIME,
this,
mavenLevel == MavenLevel.Maven4 ? ResolutionScope.Mode.REMOVE : ResolutionScope.Mode.ELIMINATE,
mavenLevel.isBrokenRuntimeResolution()
? ResolutionScope.Mode.ELIMINATE
: ResolutionScope.Mode.REMOVE,
Arrays.asList(dependencyScopes.get(DS_COMPILE), dependencyScopes.get(DS_RUNTIME)),
nonTransitiveScopes));
result.put(
RS_MAIN_RUNTIME_PLUS_SYSTEM,
new JavaResolutionScope(
RS_MAIN_RUNTIME_PLUS_SYSTEM,
this,
mavenLevel == MavenLevel.Maven4 ? ResolutionScope.Mode.REMOVE : ResolutionScope.Mode.ELIMINATE,
mavenLevel.isBrokenRuntimeResolution()
? ResolutionScope.Mode.ELIMINATE
: ResolutionScope.Mode.REMOVE,
Arrays.asList(
dependencyScopes.get(DS_COMPILE),
dependencyScopes.get(DS_RUNTIME),
Expand Down

0 comments on commit 5990b49

Please sign in to comment.