Skip to content

Commit

Permalink
Add real backing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Mar 14, 2024
1 parent c3af9de commit 44d66d8
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 129 deletions.
1 change: 1 addition & 0 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<name>${project.groupId}:${project.artifactId}</name>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<mainClass>eu.maveniverse.maven.toolbox.cli.Main</mainClass>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<properties>
<project.build.outputTimestamp>2024-03-08T16:26:15Z</project.build.outputTimestamp>

<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.release>8</maven.compiler.release>

<!--
Build time: latest Maven and LTS Java.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
Expand All @@ -20,149 +21,143 @@
public final class CommonBuilds {
private CommonBuilds() {}

/**
* A common "main" project path.
*/
public static final ProjectPath PROJECT_PATH_MAIN = new ProjectPath() {
@Override
public String getId() {
return "main";
}
private abstract static class Label {
private final String id;

@Override
public int order() {
return 1;
protected Label(String id) {
this.id = id;
}

@Override
public int reverseOrder() {
return 3;
public String getId() {
return id;
}
};

/**
* A common "test" project path.
*/
public static final ProjectPath PROJECT_PATH_TEST = new ProjectPath() {
@Override
public String getId() {
return "test";
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Label label = (Label) o;
return Objects.equals(id, label.id);
}

@Override
public int order() {
return 2;
public int hashCode() {
return Objects.hash(id);
}

@Override
public int reverseOrder() {
return 1;
public String toString() {
return id;
}
};
}

/**
* A common "it" project path.
*/
public static final ProjectPath PROJECT_PATH_IT = new ProjectPath() {
@Override
public String getId() {
return "it";
private static final class ProjectPathImpl extends Label implements ProjectPath {
private final int order;
private final int reverseOrder;

private ProjectPathImpl(String id, int order, int reverseOrder) {
super(id);
this.order = order;
this.reverseOrder = reverseOrder;
}

@Override
public int order() {
return 3;
return order;
}

@Override
public int reverseOrder() {
return 2;
return reverseOrder;
}
};
}

/**
* A common "preprocess" build path.
*/
public static final BuildPath BUILD_PATH_PREPROCESS = new BuildPath() {
@Override
public String getId() {
return "preprocess";
private static final class BuildPathImpl extends Label implements BuildPath {
private final boolean reverse;
private final int order;

private BuildPathImpl(String id, boolean reverse, int order) {
super(id);
this.reverse = reverse;
this.order = order;
}

@Override
public boolean isReverse() {
return false;
return reverse;
}

@Override
public int order() {
return 1;
return order;
}
}

private static final class BuildScopeImpl extends Label implements BuildScope {
private final Set<ProjectPath> projectPaths;
private final Set<BuildPath> buildPaths;
private final int order;

private BuildScopeImpl(String id, Set<ProjectPath> projectPaths, Set<BuildPath> buildPaths, int order) {
super(id);
this.projectPaths = projectPaths;
this.buildPaths = buildPaths;
this.order = order;
}
};

/**
* A common "compile" build path.
*/
public static final BuildPath BUILD_PATH_COMPILE = new BuildPath() {
@Override
public String getId() {
return "compile";
public Set<ProjectPath> getProjectPaths() {
return projectPaths;
}

@Override
public boolean isReverse() {
return false;
public Set<BuildPath> getBuildPaths() {
return buildPaths;
}

@Override
public int order() {
return 2;
return order;
}
};
}

/**
* A common "runtime" build path.
* A common "main" project path.
*/
public static final BuildPath BUILD_PATH_RUNTIME = new BuildPath() {
@Override
public String getId() {
return "runtime";
}
public static final ProjectPath PROJECT_PATH_MAIN = new ProjectPathImpl("main", 1, 3);

@Override
public boolean isReverse() {
return true;
}
/**
* A common "test" project path.
*/
public static final ProjectPath PROJECT_PATH_TEST = new ProjectPathImpl("test", 2, 1);

@Override
public int order() {
return 3;
}
};
/**
* A common "it" project path.
*/
public static final ProjectPath PROJECT_PATH_IT = new ProjectPathImpl("it", 3, 2);

/**
* Maven2/Maven3 special build scope: it did not distinguish between "test compile"
* and "test runtime", but lumped both together into "test".
* A common "preprocess" build path.
*/
public static final BuildScope MAVEN_TEST_BUILD_SCOPE = new BuildScope() {
@Override
public String getId() {
return "test";
}
public static final BuildPath BUILD_PATH_PREPROCESS = new BuildPathImpl("preprocess", false, 1);

@Override
public Set<ProjectPath> getProjectPaths() {
return Collections.singleton(PROJECT_PATH_TEST);
}
/**
* A common "compile" build path.
*/
public static final BuildPath BUILD_PATH_COMPILE = new BuildPathImpl("compile", false, 2);

@Override
public Set<BuildPath> getBuildPaths() {
return new HashSet<>(Arrays.asList(BUILD_PATH_COMPILE, BUILD_PATH_RUNTIME));
}
/**
* A common "runtime" build path.
*/
public static final BuildPath BUILD_PATH_RUNTIME = new BuildPathImpl("runtime", true, 3);

@Override
public int order() {
return 10;
}
};
/**
* Maven2/Maven3 special build scope: it did not distinguish between "test compile"
* and "test runtime", but lumped both together into "test".
*/
public static final BuildScope MAVEN_TEST_BUILD_SCOPE = new BuildScopeImpl(
"test",
Collections.singleton(PROJECT_PATH_TEST),
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(BUILD_PATH_COMPILE, BUILD_PATH_RUNTIME))),
10);
}
Loading

0 comments on commit 44d66d8

Please sign in to comment.