[
https://issues.apache.org/jira/browse/MBUILDCACHE-25?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17626354#comment-17626354
]
ASF GitHub Bot commented on MBUILDCACHE-25:
-------------------------------------------
AlexanderAshitkin opened a new pull request, #34:
URL: https://github.com/apache/maven-build-cache-extension/pull/34
Forked execution should be thought as a part of originating mojo internal
implementation. If forkedExecution is detected, it means that originating mojo
is not cached so fork should rerun too. If originating mojo is cached, it is
cached altogether, with forks. The fix detects forked execution and disables
cache processing if forked project entered cache.
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Make sure there is a [JIRA
issue](https://issues.apache.org/jira/browse/MNG) filed
for the change (usually before you start working on it). Trivial
changes like typos do not
require a JIRA issue. Your pull request should address just this
issue, without
pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line
and body.
- [ ] Format the pull request title like `[MNG-XXX] - Fixes bug in
ApproximateQuantiles`,
where you replace `MNG-XXX` with the appropriate JIRA issue. Best
practice
is to use the JIRA issue title in the pull request title and in the
first line of the
commit message.
- [ ] Write a pull request description that is detailed enough to
understand what the pull request does, how, and why.
- [ ] Run `mvn clean verify` to make sure basic checks pass. A more
thorough check will
be performed on your pull request automatically.
- [ ] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January
2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
> Project processed multiple time in presence of forked executions
> ----------------------------------------------------------------
>
> Key: MBUILDCACHE-25
> URL: https://issues.apache.org/jira/browse/MBUILDCACHE-25
> Project: Maven Build Cache Extension
> Issue Type: Bug
> Reporter: Alexander Ashitkin
> Priority: Minor
>
> In forked executions present in build, project goes through full lifecycle
> multiple times - one time for project itself + 1 time for each forked
> execution (could be 5, 10 - depends on configuration):
> * checksum will be calculated multiple times
> * artifacts uploaded multiple times
> The issue is manifested by multiple cache calculation log records for the
> same project:
> {noformat}
> LOGGER.info( "Going to calculate checksum for project [groupId=" +
> project.getGroupId()
> + ", artifactId=" + project.getArtifactId() + "]" );{noformat}
> The issue initially observed with PMD and Spotbugs plugins
> h3. Impact
> No functional impact observed, just unnecessary performance penalty on cache
> h3. Cause
> For every forked execution MojoExecutor clones project per forked execution.
> Each forked project goes through full cache lifecycle:
> {code:java}
> // public List<MavenProject> executeForkedExecutions( MojoExecution
> mojoExecution, MavenSession session,
> ProjectIndex projectIndex )
> throws LifecycleExecutionException
> {
> ...
> Map<String, List<MojoExecution>> forkedExecutions =
> mojoExecution.getForkedExecutions();
> if ( !forkedExecutions.isEmpty() )
> {
> ...
> try
> {
> for ( Map.Entry<String, List<MojoExecution>> fork :
> forkedExecutions.entrySet() )
> {
> MavenProject executedProject = forkedProject.clone();
> forkedProject.setExecutionProject( executedProject );
> List<MojoExecution> mojoExecutions = fork.getValue();
> ...
> try
> {
> ...
> // here cloned project enters cache as a standalone
> project
> execute( session, mojoExecutions, projectIndex );{code}
> Additional notes: the cloning doesn't affect effective pome, so checksum is
> stable and the same in all calculations
> Proposed solution: reuse calculated inputs from cache
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)