Skip to content

[JENKINS-70153] Add support for gradle build-tools warnings (w:) #1145

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

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/edu/hm/hafner/analysis/parser/JavacParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ public class JavacParser extends AbstractMavenLogParser {

private static final String JAVAC_WARNING_PATTERN
= "^(?:\\S+\\s+)?" // optional preceding arbitrary number of characters that are not a
// whitespace followed by whitespace. This can be used for timestamps.
// whitespace followed by whitespace. This can be used for timestamps.
+ "(?:(?:\\[(WARNING|ERROR)\\]|w:|e:)\\s+)" // optional [WARNING] or [ERROR] or w: or e:
+ "(?:"
// --- Matches filename/line ---
+ "(((\\/?[a-zA-Z]|file):)?[^\\[\\(:]*):" // group 2: filename starting path with C:\ or /C:\ or file:/// or /
+ "(" // start group 5
+ "(\\s*[\\[\\(]?)?" // optional ( or [
Expand All @@ -39,7 +41,11 @@ public class JavacParser extends AbstractMavenLogParser {
+ "[\\]\\)]?\\s*:?\\s?" // optional ) or ] or whitespace or :
+ ")" // end group 5
+ "(?:\\[(\\w+)\\])?" // group 9: optional category
+ "\\s*(.*)$"; // group 10: message
+ "\\s*(.*)" // group 10: message
+ "|"
// --- Matches quoted messages ---
+ "(['\"])(.*?)\\11\\s*(.*)" // group 11: opening quote; group 12: quoted text; group 13: rest of message
+ ")$";

private static final String SEVERITY_ERROR = "ERROR";
private static final String SEVERITY_ERROR_SHORT = "e:";
Expand Down
38 changes: 38 additions & 0 deletions src/test/java/edu/hm/hafner/analysis/parser/JavacParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,42 @@ void kotlinAndCmakeDirectoryOutput() {
.hasFileName("file:///project/src/main/java/com/app/ui/model/Activity.kt")
.hasMessage("'PackageStats' is deprecated. Deprecated in Java");
}

/**
* Parses gradle build-tools warnings.
*
* @see <a href="https://issues.jenkins.io/browse/JENKINS-70153">Issue 70153</a>
*/
@Test
void issue70153() {
var warnings = parse("issue70153.txt");

assertThat(warnings).hasSize(4);

assertThat(warnings.get(0))
.hasSeverity(Severity.WARNING_NORMAL)
.hasLineStart(0)
.hasColumnStart(0);

assertThat(warnings.get(1))
.hasSeverity(Severity.WARNING_NORMAL)
.hasLineStart(35)
.hasColumnStart(35)
.hasFileName("/var/lib/jenkins/workspace/.../CountryFavoriteRepositoryImpl.kt")
.hasMessage("Type mismatch: inferred type is CountryFavoriteDto? but CountryFavoriteDto was expected");

assertThat(warnings.get(2))
.hasSeverity(Severity.WARNING_NORMAL)
.hasLineStart(86)
.hasColumnStart(39)
.hasFileName("/var/lib/jenkins/workspace/.../CountryFavoriteUseCase.kt")
.hasMessage("Name shadowed: favoriteCountry");

assertThat(warnings.get(3))
.hasSeverity(Severity.WARNING_NORMAL)
.hasLineStart(48)
.hasColumnStart(30)
.hasFileName("/var/lib/jenkins/workspace/.../CountryDetailActivity.kt")
.hasMessage("'getParcelableExtra(String!): T?' is deprecated. Deprecated in Java");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
> Task :travel:compileDebugKotlin
w: '-Xjvm-default=compatibility' is deprecated, please use '-Xjvm-default=all|all-compatibility'
w: /var/lib/jenkins/workspace/.../CountryFavoriteRepositoryImpl.kt: (35, 35): Type mismatch: inferred type is CountryFavoriteDto? but CountryFavoriteDto was expected
w: /var/lib/jenkins/workspace/.../CountryFavoriteUseCase.kt: (86, 39): Name shadowed: favoriteCountry
w: /var/lib/jenkins/workspace/.../CountryDetailActivity.kt: (48, 30): 'getParcelableExtra(String!): T?' is deprecated. Deprecated in Java
Loading