-
Notifications
You must be signed in to change notification settings - Fork 38
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
[MBUILDCACHE-22] added flag to force rebuild per project or globally #24
[MBUILDCACHE-22] added flag to force rebuild per project or globally #24
Conversation
added possibility to skip generated sources restore on per-project level added some logging
(https://issues.apache.org/jira/browse/MBUILDCACHE-22) Basically this PR is about adding 2 new features which are required to use this extension in yet another complex multi-module project in Deutsche Bank
|
@eltsovalex https://issues.apache.org/jira/projects/MBUILDCACHE for this project |
@@ -87,6 +87,16 @@ public class CacheConfigImpl implements org.apache.maven.buildcache.xml.CacheCon | |||
public static final String RESTORE_GENERATED_SOURCES_PROPERTY_NAME = "maven.build.cache.restoreGeneratedSources"; | |||
public static final String ALWAYS_RUN_PLUGINS = "maven.build.cache.alwaysRunPlugins"; | |||
|
|||
/** | |||
* Flag to control if we should skip lookup for cached artifacts globally r for a particular project even if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
is it possible to add a note in documentation about this feature and how to use it, please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, please fix the typo in the javadoc in CacheConfigImpl.java
and document its usage in the documentation.
Typos fixed in javadoc + new parameters described in documentation |
{ | ||
result = cacheController.findCachedBuild( session, project, mojoExecutions ); | ||
result = cacheController.findCachedBuild( session, project, mojoExecutions, skipCacheLookup ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right now cache could be accessed when no initialized (it seems). not sure if it could cause any issues but in terms of naming and contract clarity it is not so clear . skipCache
should work better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin renamed to skipCache
@@ -96,6 +97,7 @@ public void execute( List<MojoExecution> mojoExecutions, | |||
// execute clean bound goals before restoring to not interfere/slowdown clean | |||
CacheState cacheState = DISABLED; | |||
CacheResult result = CacheResult.empty(); | |||
boolean skipCacheLookup = cacheConfig.isSkipLookup() || MavenProjectInput.shouldSkipCacheLookup( project ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regarding the naming - lets call it skipCache
. Gradle has similar parameter to force rebuild named --no-build-cache
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin renamed
result = localBuild; | ||
} | ||
else | ||
// remote build first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please change this comment to something like Central repository build first
remote and local notation is confusing here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not my comment - just part of code by @gnodet that I've moved inside a block
@@ -123,10 +127,16 @@ private List<Plugin> normalizePlugins( List<Plugin> plugins ) | |||
{ | |||
Plugin copy = plugin.clone(); | |||
List<String> excludeProperties = cacheConfig.getEffectivePomExcludeProperties( copy ); | |||
removeBlacklistedAttributes( copy.getConfiguration(), excludeProperties ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin the code is still there - just after debug output
filteredOutPaths.add( Paths.get( properties.getProperty( propertyName ) ) ); | ||
} | ||
} | ||
CacheUtils.debugPrintCollection( LOGGER, filteredOutPaths, | ||
"List of excluded paths (checked either by fileName or by startsWith prefix)", | ||
"Pah entry" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo. Pah entry
is a medical term likely ¯_(ツ)_/¯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin fixed
src/site/markdown/parameters.md
Outdated
@@ -32,6 +32,7 @@ This documents contains various configuration parameters supported by cache engi | |||
| `-Dmaven.build.cache.lazyRestore=(true/false)` | Restore artifacts from remote cache lazily | Performance optimization | | |||
| `-Dmaven.build.cache.restoreGeneratedSources=(true/false)` | Do not restore generated sources and directly attached files | Performance optimization | | |||
| `-Dmaven.build.cache.alwaysRunPlugins=<list of plugins>` | Comma seprated list of plugins to always run regardless of cache state. An example: `maven-deploy-plugin:*,maven-install-plugin:install` | Remote cache setup/tuning/troubleshooting | | |||
| `-Dmaven.build.cache.skipLookup=(true/false)` | Skip looking up artifacts in caches. Does not affect writing artifacts to caches, disables only reading when set to `true` | May be used to trigger a forced rebuild when maching artifatcs do exist in caches| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From command line and pom perspective -Dorg.maven.build.cache.rerun
is more expressive because it assumes that cache will be invalidated and rebuilt. Another option is which is also look better is -Dorg.maven.build.cache.skipCache
just seems more expressive to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin renamed to -Dorg.maven.build.cache.skipCache
LOGGER.debug( "Adding an excludePath from property '{}', values is '{}', path is '{}' ", | ||
propertyName, propertyValue, path ); | ||
} | ||
|
||
filteredOutPaths.add( Paths.get( properties.getProperty( propertyName ) ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer need this line, to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin thanks, fixed
@@ -819,4 +833,22 @@ public int compare( Path f1, Path f2 ) | |||
} | |||
} | |||
|
|||
public static boolean shouldSkipCacheLookup( MavenProject project ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipCache
or isSkipCache
will be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin fixed
I would rename this pr into "flag to force rebuild" which better describes new functionality |
src/site/markdown/parameters.md
Outdated
@@ -32,7 +32,7 @@ This documents contains various configuration parameters supported by cache engi | |||
| `-Dmaven.build.cache.lazyRestore=(true/false)` | Restore artifacts from remote cache lazily | Performance optimization | | |||
| `-Dmaven.build.cache.restoreGeneratedSources=(true/false)` | Do not restore generated sources and directly attached files | Performance optimization | | |||
| `-Dmaven.build.cache.alwaysRunPlugins=<list of plugins>` | Comma seprated list of plugins to always run regardless of cache state. An example: `maven-deploy-plugin:*,maven-install-plugin:install` | Remote cache setup/tuning/troubleshooting | | |||
| `-Dmaven.build.cache.skipLookup=(true/false)` | Skip looking up artifacts in caches. Does not affect writing artifacts to caches, disables only reading when set to `true` | May be used to trigger a forced rebuild when maching artifatcs do exist in caches| | |||
| `-Dmaven.build.cache.skip=(true/false)` | Skip looking up artifacts in caches. Does not affect writing artifacts to caches, disables only reading when set to `true` | May be used to trigger a forced rebuild when maching artifatcs do exist in caches| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo. maching -> matching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexanderAshitkin - thx, fixed
@gnodet please merge |
added possibility to skip generated sources restore on per-project level
added some logging
Following this checklist to help us incorporate your
contribution quickly and easily:
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.
[MNG-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MNG-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement 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
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
In any other case, please file an Apache Individual Contributor License Agreement.