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-8037] Restrict project to the entity being built and make it immutable #1389

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Jan 23, 2024

@gnodet gnodet changed the title Make POM and basedire required on the project Make POM and basedir required on the project Jan 23, 2024
Copy link
Member

@cstamas cstamas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this one, close out the other one

@cstamas
Copy link
Member

cstamas commented Jan 25, 2024

Just FTR as we discussed:

  • IMHO baseDir != "pom file parent"
  • especially as a project may (could) have baseDir but no POM file (but have model provided)
  • possible use case: generate some POM (ie is in tmp directory), create a Project that is "placed" on top of some existing module, and have it built?

@gnodet
Copy link
Contributor Author

gnodet commented Jan 25, 2024

Just FTR as we discussed:

  • IMHO baseDir != "pom file parent"
  • especially as a project may (could) have baseDir but no POM file (but have model provided)
  • possible use case: generate some POM (ie is in tmp directory), create a Project that is "placed" on top of some existing module, and have it built?

So we're looking at Maven being used as a library, right ? That's clearly not supported from the CLI.
Right, now, in the Maven 4 API (let's limit to that use case) the only way to obtain a Project is by using the ProjectBuilder and the only way to use it is to give either a Path, Source, Artifact or ArtifactCoordinate.
My understanding (it closely maps the v3 api) is that it you pass an ArtifactCoordinate (or Artifact), that artifact is resolved (it must point to a POM), then loaded. I need to double check, but this results in a Project which has no POM file and no BaseDir.
I think that's the current situation, i.e.: either you have both or none, but it's linked. The POM file cannot point to the local repository, it's always a build POM in your project file system, and it always define the base directory.

I'll also double check the DefaultMavenProjectBuilder. But I'm sure the use case you describe is currently supported.

In any case, the API is lacking some doc, especially this notion of "transient" projects which is not defined and very confusing/blurry.

The usual use case is to resolve dependencies transitively, but the API offers that.
We also need add a new ModelBuilder service to be able to build the models.
@gnodet
Copy link
Contributor Author

gnodet commented Jan 30, 2024

@cstamas I've removed the mutable bits from the Project, removed the optionals on pomPath and basedir. I think we'll miss a ModelBuilder service to get effective models for artifacts, but I'll add those in a separate PR.

@gnodet gnodet added this to the 4.0.0-alpha-13 milestone Jan 30, 2024
@gnodet gnodet changed the title Make POM and basedir required on the project [MNG-8037] Restrict project to the entity being build and make it immutable Jan 30, 2024
@gnodet gnodet changed the title [MNG-8037] Restrict project to the entity being build and make it immutable [MNG-8037] Restrict project to the entity being built and make it immutable Jan 30, 2024
@gnodet gnodet merged commit 16fc54d into apache:master Jan 30, 2024
18 checks passed
@gnodet gnodet deleted the make-basedir-required branch January 30, 2024 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants