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

[MINSTALL-115] Install At End feature (no extension) #15

Merged
merged 17 commits into from Jul 3, 2022
Merged

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Oct 7, 2021

This PR makes installAtEnd work as expected even
if maven-install-plugin is not used as extension.

How it works: it uses mojo Contexts to store "state markers":

  • presence of marker means project was "processed"
  • value of state marker tells what should be done

UTs adjusted to provide plugin context (was null before).
Plugin updated (as required by maven-plugin-testing-harness) and
cleaned up.


https://issues.apache.org/jira/browse/MINSTALL-115

This PR makes installAtEnd work as expected even
if maven-install-plugin is not used as extension.

How it works: it uses mojo Context to store "markers":
* presence of marker means project was "processed"
* value of marker tells what should be done (true = install, false = skipped)

UTs adjusted to provide plugin context (was null before).
@cstamas cstamas mentioned this pull request Oct 7, 2021
@gnodet
Copy link

gnodet commented Dec 2, 2021

@cstamas This should not be affected by apache/maven#625. The reason is that when the session is cloned (this is already the case currently), the map containing the plugin contexts [1] is simply copied into the new session, so that they are actually shared.

[1] https://github.com/apache/maven/blob/31954b441b3cc9eabe3f8566669928cf91fe824a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java#L86-L87

pom.xml Outdated Show resolved Hide resolved
{
getLog().info(
"Project " + getProjectReferenceId( reactorProject ) + " skipped install"
);
Copy link

Choose a reason for hiding this comment

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

This looks redundant with the log statement printed earlier "Skipping artifact installation". This will print lots of line when the artifacts are actually installed for no benefit imho.

Copy link
Member Author

Choose a reason for hiding this comment

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

The message you refers to is when maven is invoked with -Dmaven.install.skip, when whole m-install-p is skipped.

addedInstallRequest = true;
}
}

boolean projectsReady = READYPROJECTSCOUNTER.incrementAndGet() == reactorProjects.size();
if ( projectsReady )
if ( allProjectsMarked() )
Copy link

Choose a reason for hiding this comment

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

Does this work if the last project being built does not have a standard lifecycle ? Or maybe this does not exist ?

Copy link
Member Author

Choose a reason for hiding this comment

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

If m-install-p is not present, will not, but all "standard" life-cycle has them. But true, if no m-install-p not present, will not work. Was thinking about org.apache.maven.execution.MavenSession#getResult (and use org.apache.maven.execution.MavenExecutionResult#getBuildSummary to check "is it done"), wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

Neglect that above. Instead: this does NOT modify the existing feature (when it forced you to use plugin as extension), and will fix this in some newer PR

Copy link
Member

@hboutemy hboutemy Jul 3, 2022

Choose a reason for hiding this comment

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

if the last project being built does not have a standard lifecycle ?

is this a pure theoretical question (legit when thinking, but...)? Or do you know any concrete case?

IMHO, the best we can do is to add a note in plugins' parameter documentation (and it's not really about "standard lifecycle" but having install goal also run in the last reactor project)

@cstamas
Copy link
Member Author

cstamas commented Jun 25, 2022

@gnodet @michael-o ping, Guillaume, you have change requests here (unsure what). But let's agree all this PR does is:

  • not changing existing behaviour (re last module)
  • but removes the requirement for extension

So IMHO is def an improvement

@michael-o
Copy link
Member

Will check on train tomorrow

@cstamas cstamas requested review from gnodet and michael-o June 29, 2022 12:01
Still, we MUST use String as these are spanning across projects,
hence due classloader, there is no single State enum.
getLog().info( "Skipping artifact installation" );
getPluginContext().put( INSTALL_PROCESSED_MARKER, State.SKIPPED.name() );
Copy link
Member

Choose a reason for hiding this comment

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

If we have objects, why not retain the enum, why use name?

Copy link
Member Author

@cstamas cstamas Jun 29, 2022

Choose a reason for hiding this comment

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

These span across several classloaders, there is no single enum.

@cstamas cstamas requested a review from hboutemy July 2, 2022 20:03
addedInstallRequest = true;
}
}

boolean projectsReady = READYPROJECTSCOUNTER.incrementAndGet() == reactorProjects.size();
if ( projectsReady )
if ( allProjectsMarked() )
Copy link
Member

@hboutemy hboutemy Jul 3, 2022

Choose a reason for hiding this comment

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

if the last project being built does not have a standard lifecycle ?

is this a pure theoretical question (legit when thinking, but...)? Or do you know any concrete case?

IMHO, the best we can do is to add a note in plugins' parameter documentation (and it's not really about "standard lifecycle" but having install goal also run in the last reactor project)

@cstamas cstamas merged commit 9fa9fd5 into master Jul 3, 2022
@cstamas cstamas deleted the install-at-end branch July 3, 2022 18:18
@cstamas cstamas mentioned this pull request Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants