Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8120] Refactor ModelBuilder and ProjectBuilder #1700

Merged
merged 64 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
eb9b69f
[MNG-8120] Remove WorkspaceModelResolver
gnodet Aug 31, 2024
281977d
[MNG-8120] Deprecate some API
gnodet Aug 31, 2024
5b8c56b
Record problems during reactor loading
gnodet Sep 4, 2024
0cafe79
Move mappedSources into the ModelTransformerContext and use GAKey
gnodet Sep 4, 2024
622ba9e
Inline ModelTransformer inside DefaultModelBuilder
gnodet Sep 4, 2024
f5f4d85
Do not return ModelData for readRawModel
gnodet Sep 4, 2024
adea1c5
Use SessionData.Key, use immutable ModelTransformerContext during con…
gnodet Sep 4, 2024
ba23863
Fix possible IllegalArgumentException self-causation
gnodet Sep 4, 2024
7920794
Use constructor injection for DefaultConsumerPomBuilder
gnodet Sep 4, 2024
ae40578
Remove unused fields from DefaultArtifactDescriptorReader
gnodet Sep 4, 2024
815c8e6
Remove ModelRepositoryHolder interface
gnodet Sep 4, 2024
3d6533f
Use request.isProjectBuild() instead of source.getPath() != null
gnodet Sep 5, 2024
86738c0
Remove ModelTransformerContextBuilder and ModelTransformerContext int…
gnodet Sep 5, 2024
b4ac776
Replace ModelBuilderRequest validationLevel,projectBuild,processPlugi…
gnodet Sep 5, 2024
4cd8f4e
Restrict `Project` to the buildable projects, i.e. from the filesyste…
gnodet Sep 6, 2024
4abc430
Introduce ModelBuilderSession
gnodet Sep 6, 2024
9aa7099
Move DefaultModelBuildingListener into DefaultProjectBuilder
gnodet Sep 6, 2024
61cec5b
Get rid of DefaultModelRepositoryHolder
gnodet Sep 6, 2024
7804f2a
Cleanup
gnodet Sep 6, 2024
bd81690
Add sanity checks
gnodet Sep 7, 2024
56cfdda
Rename method
gnodet Sep 7, 2024
e153026
Clean up raw -> build transformation
gnodet Sep 19, 2024
dbd2bb9
Create proper session
gnodet Sep 20, 2024
e041b99
Make ModelResolver a component of ModelBuilder
gnodet Sep 20, 2024
181186d
Move the recursive project load into the ModelBuilder
gnodet Sep 23, 2024
31dce4e
fix
gnodet Sep 23, 2024
8a398da
Cleanup
gnodet Sep 23, 2024
ac18d88
Support non explicit root directories
gnodet Sep 24, 2024
1b22e5f
Fix
gnodet Sep 24, 2024
dbe400b
Better fix
gnodet Sep 24, 2024
22f0a9f
Fixes
gnodet Sep 24, 2024
b253adb
Improve model resolution
gnodet Sep 24, 2024
151645b
wip
gnodet Sep 24, 2024
6fdbfff
Fix
gnodet Sep 24, 2024
d967e1b
Remove remaining references to the two phase building
gnodet Sep 24, 2024
61004e0
Get rid of ModelBuildingListener
gnodet Sep 24, 2024
88ab310
Small fixes
gnodet Sep 24, 2024
fa1c107
Make ModelBuilder threaded
gnodet Sep 24, 2024
9ecb6c1
Fixes
gnodet Sep 25, 2024
0ab6729
Fix dots on javadoc
gnodet Sep 25, 2024
3d6ab6f
wip
gnodet Sep 25, 2024
8e784fc
tmp
gnodet Sep 25, 2024
eb13d71
Fix
gnodet Sep 26, 2024
7114374
Fix threading issues with the executor
gnodet Sep 26, 2024
7b2f4db
Merge remote-tracking branch 'origin/master' into project-builder
gnodet Sep 26, 2024
a2a68fd
Fix javadoc
gnodet Sep 26, 2024
0c62b2d
Fix javadoc
gnodet Sep 26, 2024
e8f217d
Restore injected profiles ids
gnodet Sep 26, 2024
03e48aa
Move modelVersion inferrence down to file model
gnodet Sep 27, 2024
f5b2f3d
Fix UT which rely on file -> raw transformation for build poms
gnodet Sep 27, 2024
7443273
Restore repositories support
gnodet Sep 27, 2024
dee4667
Refactor a bit
gnodet Sep 27, 2024
483818b
Do not wrap non build exceptions
gnodet Sep 27, 2024
0731a21
Fix order
gnodet Sep 27, 2024
5ecb637
Fix lost plugin version resolution
gnodet Sep 27, 2024
8986109
Fix project root directory
gnodet Sep 27, 2024
12d2977
Cleanup
gnodet Sep 27, 2024
6d78b75
Cleanup
gnodet Sep 27, 2024
be716a4
Minor fixes
gnodet Sep 27, 2024
fad0f36
Remove unused class
gnodet Sep 27, 2024
e3943fe
Keep the result order deterministic
gnodet Sep 27, 2024
5315e27
Default to 1 thread for model builder
gnodet Sep 27, 2024
cf27eef
Restore multi threaded builder
gnodet Sep 27, 2024
86ef905
Fix possible ConcurrentException
gnodet Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@Immutable
public interface Artifact {
/**
* {@return a unique identifier for this artifact}.
* {@return a unique identifier for this artifact}
* The identifier is composed of groupId, artifactId, extension, classifier, and version.
*
* @see ArtifactCoordinates#getId()
Expand All @@ -58,23 +58,24 @@ default String key() {
}

/**
* {@return the group identifier of the artifact}.
* {@return the group identifier of the artifact}
*
* @see ArtifactCoordinates#getGroupId()
*/
@Nonnull
String getGroupId();

/**
* {@return the identifier of the artifact}.
* {@return the identifier of the artifact}
*
* @see ArtifactCoordinates#getArtifactId()
*/
@Nonnull
String getArtifactId();

/**
* {@return the version of the artifact}. Contrarily to {@link ArtifactCoordinates},
* {@return the version of the artifact}
* Contrarily to {@link ArtifactCoordinates},
* each {@code Artifact} is associated to a specific version instead of a range of versions.
* If the {@linkplain #getBaseVersion() base version} contains a meta-version such as {@code SNAPSHOT},
* those keywords are replaced by, for example, the actual timestamp.
Expand All @@ -85,7 +86,7 @@ default String key() {
Version getVersion();

/**
* {@return the version or meta-version of the artifact}.
* {@return the version or meta-version of the artifact}
* A meta-version is a version suffixed with the {@code SNAPSHOT} keyword.
* Meta-versions are represented in a base version by their symbols (e.g., {@code SNAPSHOT}),
* while they are replaced by, for example, the actual timestamp in the {@linkplain #getVersion() version}.
Expand Down Expand Up @@ -121,7 +122,7 @@ default String key() {
boolean isSnapshot();

/**
* {@return coordinates with the same identifiers as this artifact}.
* {@return coordinates with the same identifiers as this artifact}
* This is a shortcut for {@code session.createArtifactCoordinates(artifact)}.
*
* @see org.apache.maven.api.Session#createArtifactCoordinates(Artifact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
@Immutable
public interface ArtifactCoordinates {
/**
* {@return the group identifier of the artifact}.
* {@return the group identifier of the artifact}
*/
@Nonnull
String getGroupId();

/**
* {@return the identifier of the artifact}.
* {@return the identifier of the artifact}
*/
@Nonnull
String getArtifactId();
Expand All @@ -53,7 +53,7 @@ public interface ArtifactCoordinates {
String getClassifier();

/**
* {@return the specific version, range of versions or meta-version of the artifact}.
* {@return the specific version, range of versions or meta-version of the artifact}
* A meta-version is a version suffixed with the {@code SNAPSHOT} keyword.
*/
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public final class Constants {
* @since 4.0.0
*/
@Config(type = "java.lang.Integer", defaultValue = "cores/2 + 1")
public static final String MAVEN_PROJECT_BUILDER_PARALLELISM = "maven.projectBuilder.parallelism";
public static final String MAVEN_MODEL_BUILDER_PARALLELISM = "maven.modelBuilder.parallelism";

/**
* User property for enabling/disabling the consumer POM feature.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
@Immutable
public interface Dependency extends Artifact {
/**
* {@return the type of the dependency}. A dependency can be a <abbr>JAR</abbr> file,
* {@return the type of the dependency}
* A dependency can be a <abbr>JAR</abbr> file,
* a modular-<abbr>JAR</abbr> if it is intended to be placed on the module-path,
* a <abbr>JAR</abbr> containing test classes, <i>etc.</i>
*
Expand All @@ -46,7 +47,7 @@ public interface Dependency extends Artifact {
Type getType();

/**
* {@return the time at which the dependency will be used}.
* {@return the time at which the dependency will be used}
* If may be, for example, at compile time only, at run time or at test time.
*
* @see DependencyCoordinates#getScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
@Immutable
public interface DependencyCoordinates extends ArtifactCoordinates {
/**
* {@return the type of the dependency}. A dependency can be a <abbr>JAR</abbr> file,
* {@return the type of the dependency}
* A dependency can be a <abbr>JAR</abbr> file,
* a modular-<abbr>JAR</abbr> if it is intended to be placed on the module-path,
* a <abbr>JAR</abbr> containing test classes, <i>etc.</i>
*/
@Nonnull
Type getType();

/**
* {@return the time at which the dependency will be used}.
* {@return the time at which the dependency will be used}
* If may be, for example, at compile time only, at run time or at test time.
*/
@Nonnull
Expand All @@ -62,7 +63,7 @@ public interface DependencyCoordinates extends ArtifactCoordinates {
Boolean getOptional();

/**
* {@return transitive dependencies to exclude}.
* {@return transitive dependencies to exclude}
*/
@Nonnull
Collection<Exclusion> getExclusions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public String[] option(Iterable<? extends Path> paths) {
String name();

/**
* {@return a string representation for this extensible enum describing a path type}.
* {@return a string representation for this extensible enum describing a path type}
* For example {@code "PathType[PATCH_MODULE:foo.bar]"}.
*/
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ default String getId() {

/**
* Returns project parent project, if any.
* <p>
* Note that the model may have a parent defined, but an empty parent
* project may be returned if the parent comes from a remote repository,
* as a {@code Project} must refer to a buildable project.
*
* @return an optional containing the parent project
* @see Model#getParent()
*/
@Nonnull
Optional<Project> getParent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@Provider
public interface Log {
/**
* {@return true if the <b>debug</b> error level is enabled}.
* {@return true if the <b>debug</b> error level is enabled}
*/
boolean isDebugEnabled();

Expand Down Expand Up @@ -70,7 +70,7 @@ public interface Log {
void debug(Supplier<String> content, Throwable error);

/**
* {@return true if the <b>info</b> error level is enabled}.
* {@return true if the <b>info</b> error level is enabled}
*/
boolean isInfoEnabled();

Expand Down Expand Up @@ -103,7 +103,7 @@ public interface Log {
void info(Supplier<String> content, Throwable error);

/**
* {@return true if the <b>warn</b> error level is enabled}.
* {@return true if the <b>warn</b> error level is enabled}
*/
boolean isWarnEnabled();

Expand Down Expand Up @@ -136,7 +136,7 @@ public interface Log {
void warn(Supplier<String> content, Throwable error);

/**
* {@return true if the <b>error</b> error level is enabled}.
* {@return true if the <b>error</b> error level is enabled}
*/
boolean isErrorEnabled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public interface DependencyResolverResult {
Map<PathType, List<Path>> getDispatchedPaths();

/**
* {@return all dependencies associated to their paths}.
* {@return all dependencies associated to their paths}
* Some dependencies may be associated to a null value if there is no path available.
*/
@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ public interface ModelBuilder extends Service {

List<String> VALID_MODEL_VERSIONS = List.of(MODEL_VERSION_4_0_0, MODEL_VERSION_4_1_0);

ModelBuilderResult build(ModelBuilderRequest request) throws ModelBuilderException;
ModelBuilderSession newSession();

ModelTransformerContextBuilder newTransformerContextBuilder();
interface ModelBuilderSession {

ModelBuilderResult build(ModelBuilderRequest request) throws ModelBuilderException;
}

Model buildRawModel(ModelBuilderRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ public ModelBuilderResult getResult() {
* @return The identifier of the POM or an empty string if not known, never {@code null}.
*/
public String getModelId() {
if (result == null || result.getModelIds().isEmpty()) {
if (result == null) {
return "";
} else if (result.getEffectiveModel() != null) {
return result.getEffectiveModel().getId();
} else if (result.getRawModel() != null) {
return result.getRawModel().getId();
} else if (result.getFileModel() != null) {
return result.getFileModel().getId();
} else {
return "";
}
return result.getModelIds().get(0);
}

/**
Expand Down
Loading