You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "kbuntrock (via GitHub)" <gi...@apache.org> on 2023/10/11 21:23:04 UTC

[PR] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

kbuntrock opened a new pull request, #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103

   ### Description of this pull request
   
   Hello everyone,
   
   A small PR to suggest an evolution : a configuration option to make mandatory the use of the clean phase in order to cache the build result.
   
   The goal is to offer the possibility of denying as much as possible the possibility to cache a faulty build.
   
   What do you think of the idea? :)
   
   ### MR checklist
   
   Following this checklist to help us incorporate your 
   contribution quickly and easily:
   
    - [ ] Make sure there is a [MBUILDCACHE JIRA issue](https://issues.apache.org/jira/browse/MBUILDCACHE) 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.
    - [x] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[MBUILDCACHE-XXX] - Fixes bug in ApproximateQuantiles`,
          where you replace `MBUILDCACHE-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.
    - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [x] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will 
          be performed on your pull request automatically.
    - [x] 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.
   
    - [x] 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)
   
    - [x] 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/
   
   _NB: Not checked the lines about JIRA since getting rid of it is progress._
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MBUILDCACHE-90] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy merged PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MBUILDCACHE-90] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "jira-importer (via GitHub)" <gi...@apache.org>.
jira-importer commented on PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#issuecomment-2955466600

   Resolve #264


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PR-103] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "AlexanderAshitkin (via GitHub)" <gi...@apache.org>.
AlexanderAshitkin commented on code in PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#discussion_r1573412300


##########
src/main/java/org/apache/maven/buildcache/xml/CacheConfigImpl.java:
##########
@@ -503,6 +503,11 @@ public String getAlwaysRunPlugins() {
         return getProperty(ALWAYS_RUN_PLUGINS, null);
     }
 
+    @Override
+    public boolean isMandatoryClean() {
+        return getConfiguration().isMandatoryClean();

Review Comment:
   It might be handy to add a command line property as well



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MBUILDCACHE-90] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "kbuntrock (via GitHub)" <gi...@apache.org>.
kbuntrock commented on PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#issuecomment-2081973553

   @olamy: Merge conflicts are resolved. Please merge this one before [MBUILDCACHE-86] (which I will fix after this merge)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PR-103] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "maximilian-novikov-db (via GitHub)" <gi...@apache.org>.
maximilian-novikov-db commented on PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#issuecomment-1771455938

   have you hit any real problems after skipping Clean phase?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MBUILDCACHE-90] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "kbuntrock (via GitHub)" <gi...@apache.org>.
kbuntrock commented on code in PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#discussion_r1578481429


##########
src/test/java/org/apache/maven/buildcache/util/LogFileUtils.java:
##########
@@ -60,4 +61,32 @@ public static String findFirstLineContainingTextsInLogs(final Verifier verifier,
 
         return null;
     }
+
+    /**
+     * Find lines matching all the strings given as parameter in the log file attached to a verifier
+     * @param verifier the maven verifier instance
+     * @param texts all the matching strings to find
+     * @return a list of matching strings
+     * @throws VerificationException
+     */
+    public static List<String> findLinesContainingTextsInLogs(final Verifier verifier, final String... texts)
+            throws VerificationException {
+        List<String> lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false);
+        List<String> result = new ArrayList<>();
+        Iterator it = lines.iterator();
+
+        while (it.hasNext()) {
+            String line = verifier.stripAnsi((String) it.next());
+            boolean matches = true;
+            Iterator<String> toMatchIterator = Arrays.stream(texts).iterator();

Review Comment:
   Done. Slightly changed you proposal since the goal is to test the presence of all strings.



##########
src/main/java/org/apache/maven/buildcache/xml/CacheConfigImpl.java:
##########
@@ -503,6 +503,11 @@ public String getAlwaysRunPlugins() {
         return getProperty(ALWAYS_RUN_PLUGINS, null);
     }
 
+    @Override
+    public boolean isMandatoryClean() {
+        return getConfiguration().isMandatoryClean();

Review Comment:
   Done :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MBUILDCACHE-90] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "jira-importer (via GitHub)" <gi...@apache.org>.
jira-importer commented on PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#issuecomment-2955449323

   Resolve #264


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PR-103] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "kbuntrock (via GitHub)" <gi...@apache.org>.
kbuntrock commented on PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#issuecomment-1772694036

   > @kbuntrock have you hit any real problems after skipping Clean phase?
   
   Not yet since I'm waiting for my evolution suggestions on outputs + maybe the next official release to adopt it on my projects.
   
   But since going through a clean phase is necessary sometimes to insure nothing from an old build interfere with the current one, I don't want to deal with a clean phase not solving this kind of issues because the faulty build is cached. 
   Ideally, the use of this extension should be totally transparent for the vast majority of members of my team.
   
   I get that I'm not addressing a daily issue, but I suspect some waste of time from me or another senior dev to investigate the problem the days this occurs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PR-103] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "AlexanderAshitkin (via GitHub)" <gi...@apache.org>.
AlexanderAshitkin commented on code in PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#discussion_r1573409460


##########
src/test/java/org/apache/maven/buildcache/util/LogFileUtils.java:
##########
@@ -60,4 +61,32 @@ public static String findFirstLineContainingTextsInLogs(final Verifier verifier,
 
         return null;
     }
+
+    /**
+     * Find lines matching all the strings given as parameter in the log file attached to a verifier
+     * @param verifier the maven verifier instance
+     * @param texts all the matching strings to find
+     * @return a list of matching strings
+     * @throws VerificationException
+     */
+    public static List<String> findLinesContainingTextsInLogs(final Verifier verifier, final String... texts)
+            throws VerificationException {
+        List<String> lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false);
+        List<String> result = new ArrayList<>();
+        Iterator it = lines.iterator();
+
+        while (it.hasNext()) {
+            String line = verifier.stripAnsi((String) it.next());
+            boolean matches = true;
+            Iterator<String> toMatchIterator = Arrays.stream(texts).iterator();

Review Comment:
   Not a critical piece of code, but it is more elegant and efficient to use [StringUtils#containsAny](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#containsAny-java.lang.CharSequence-java.lang.CharSequence...-) and [Stream#anyMatch](https://docs.oracle.com/en%2Fjava%2Fjavase%2F11%2Fdocs%2Fapi%2F%2F/java.base/java/util/stream/Stream.html#anyMatch(java.util.function.Predicate)):
   ```java
   return Files.lines(filePath) // or lines.stream()
       .anyMatch(line -> StringUtils.containsAny(line, texts));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [PR-103] A "mandatory clean" option to enable the caching functionnality [maven-build-cache-extension]

Posted by "AlexanderAshitkin (via GitHub)" <gi...@apache.org>.
AlexanderAshitkin commented on code in PR #103:
URL: https://github.com/apache/maven-build-cache-extension/pull/103#discussion_r1573409460


##########
src/test/java/org/apache/maven/buildcache/util/LogFileUtils.java:
##########
@@ -60,4 +61,32 @@ public static String findFirstLineContainingTextsInLogs(final Verifier verifier,
 
         return null;
     }
+
+    /**
+     * Find lines matching all the strings given as parameter in the log file attached to a verifier
+     * @param verifier the maven verifier instance
+     * @param texts all the matching strings to find
+     * @return a list of matching strings
+     * @throws VerificationException
+     */
+    public static List<String> findLinesContainingTextsInLogs(final Verifier verifier, final String... texts)
+            throws VerificationException {
+        List<String> lines = verifier.loadFile(verifier.getBasedir(), verifier.getLogFileName(), false);
+        List<String> result = new ArrayList<>();
+        Iterator it = lines.iterator();
+
+        while (it.hasNext()) {
+            String line = verifier.stripAnsi((String) it.next());
+            boolean matches = true;
+            Iterator<String> toMatchIterator = Arrays.stream(texts).iterator();

Review Comment:
   Not a critical piece of code, but it is more elegant and efficient to use [StringUtils#containsAny](https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#containsAny-java.lang.CharSequence-java.lang.CharSequence...-) and [Stream#anyMatch](https://docs.oracle.com/en%2Fjava%2Fjavase%2F11%2Fdocs%2Fapi%2F%2F/java.base/java/util/stream/Stream.html#anyMatch(java.util.function.Predicate)):
   ```java
   return Files.lines(filePath) // or lines.stream()
       .anyMatch(line -> StringUtils.containsAny(line, texts));
       .
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org