You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/02/01 16:06:36 UTC

[GitHub] [maven] mthmulders opened a new pull request #672: [MNG-7406] Better display of project building errors

mthmulders opened a new pull request #672:
URL: https://github.com/apache/maven/pull/672


   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [X] Make sure there is a [MNG-7406](https://issues.apache.org/jira/browse/MNG-7406) 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.
    - [X] Format the pull request title like `[MNG-XXX] SUMMARY`, where you replace `MNG-XXX`
          and `SUMMARY` 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.
    - [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 - running them on GitHub Actions as a line of first defence.
   
   ICLA and CCLA signed.
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
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



[GitHub] [maven] michael-o commented on pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #672:
URL: https://github.com/apache/maven/pull/672#issuecomment-1042293944


   > Apologies for the curly on new line noise... Should've seen that myself!
   
   No issue...


-- 
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



[GitHub] [maven] mthmulders commented on a change in pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
mthmulders commented on a change in pull request #672:
URL: https://github.com/apache/maven/pull/672#discussion_r807675659



##########
File path: maven-core/src/main/java/org/apache/maven/project/ProjectBuildingException.java
##########
@@ -72,7 +67,7 @@ protected ProjectBuildingException( String projectId, String message, File pomFi
 
     public ProjectBuildingException( List<ProjectBuildingResult> results )
     {
-        super( createMessage( results ) );
+        super( "Some problems were encountered while processing the POMs" );

Review comment:
       > I guess the message applies to the entire reactor, doesn't it?
   
   It does. I'll consider this resolved.




-- 
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



[GitHub] [maven] mthmulders commented on a change in pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
mthmulders commented on a change in pull request #672:
URL: https://github.com/apache/maven/pull/672#discussion_r803489049



##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithProblemMessageMatcher.java
##########
@@ -0,0 +1,81 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithProblemMessageMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final String problemMessage;
+
+    ProjectBuildingResultWithProblemMessageMatcher( String problemMessage ) {
+        this.problemMessage = problemMessage;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getMessage().contains( problemMessage ) );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText("a ProjectBuildingResult with message ")

Review comment:
       Fixed.

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithLocationMatcher.java
##########
@@ -0,0 +1,87 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithLocationMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final int columnNumber;
+    private final int lineNumber;
+
+    ProjectBuildingResultWithLocationMatcher( int columnNumber, int lineNumber ) {
+        this.columnNumber = columnNumber;
+        this.lineNumber = lineNumber;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getLineNumber() == lineNumber && p.getColumnNumber() == columnNumber );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText("a ProjectBuildingResult with location ")

Review comment:
       Fixed.

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
##########
@@ -103,9 +106,9 @@ public void testVersionlessManagedDependency()
 
         ProjectBuildingException e = assertThrows( ProjectBuildingException.class,
                       () -> getContainer().lookup( org.apache.maven.project.ProjectBuilder.class ).build( pomFile, configuration ) );
-        assertThat( e.getMessage(),
-                    containsString( "[ERROR] 'dependencies.dependency.version' for org.apache.maven.its:a:jar is missing. "
-                        + "@ line 9, column 17" ) );
+        assertThat( e.getResults(), contains( projectBuildingResultWithProblemMessage(
+                "'dependencies.dependency.version' for org.apache.maven.its:a:jar is missing" ) ) );
+        assertThat( e.getResults(), contains( projectBuildingResultWithLocation( 17, 9) ) );

Review comment:
       Fixed.

##########
File path: maven-core/src/main/java/org/apache/maven/project/ProjectBuildingException.java
##########
@@ -72,7 +67,7 @@ protected ProjectBuildingException( String projectId, String message, File pomFi
 
     public ProjectBuildingException( List<ProjectBuildingResult> results )
     {
-        super( createMessage( results ) );
+        super( "Some problems were encountered while processing the POMs" );

Review comment:
       That's what the original message said (see line 126 in the old code), it's a literal move.




-- 
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



[GitHub] [maven] michael-o commented on a change in pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
michael-o commented on a change in pull request #672:
URL: https://github.com/apache/maven/pull/672#discussion_r807665537



##########
File path: maven-core/src/main/java/org/apache/maven/project/ProjectBuildingException.java
##########
@@ -72,7 +67,7 @@ protected ProjectBuildingException( String projectId, String message, File pomFi
 
     public ProjectBuildingException( List<ProjectBuildingResult> results )
     {
-        super( createMessage( results ) );
+        super( "Some problems were encountered while processing the POMs" );

Review comment:
       I guess the message applies to the entire reactor, doesn't it? If so, leave as-is.




-- 
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



[GitHub] [maven] mthmulders commented on pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
mthmulders commented on pull request #672:
URL: https://github.com/apache/maven/pull/672#issuecomment-1042270427


   Apologies for the curly on new line noise... Should've seen that myself!


-- 
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



[GitHub] [maven] michael-o commented on a change in pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
michael-o commented on a change in pull request #672:
URL: https://github.com/apache/maven/pull/672#discussion_r800195086



##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuilderTest.java
##########
@@ -103,9 +106,9 @@ public void testVersionlessManagedDependency()
 
         ProjectBuildingException e = assertThrows( ProjectBuildingException.class,
                       () -> getContainer().lookup( org.apache.maven.project.ProjectBuilder.class ).build( pomFile, configuration ) );
-        assertThat( e.getMessage(),
-                    containsString( "[ERROR] 'dependencies.dependency.version' for org.apache.maven.its:a:jar is missing. "
-                        + "@ line 9, column 17" ) );
+        assertThat( e.getResults(), contains( projectBuildingResultWithProblemMessage(
+                "'dependencies.dependency.version' for org.apache.maven.its:a:jar is missing" ) ) );
+        assertThat( e.getResults(), contains( projectBuildingResultWithLocation( 17, 9) ) );

Review comment:
       Trailing space missing

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithLocationMatcher.java
##########
@@ -0,0 +1,87 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithLocationMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final int columnNumber;
+    private final int lineNumber;
+
+    ProjectBuildingResultWithLocationMatcher( int columnNumber, int lineNumber ) {
+        this.columnNumber = columnNumber;
+        this.lineNumber = lineNumber;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getLineNumber() == lineNumber && p.getColumnNumber() == columnNumber );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText("a ProjectBuildingResult with location ")

Review comment:
       space

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithProblemMessageMatcher.java
##########
@@ -0,0 +1,81 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithProblemMessageMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final String problemMessage;
+
+    ProjectBuildingResultWithProblemMessageMatcher( String problemMessage ) {
+        this.problemMessage = problemMessage;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getMessage().contains( problemMessage ) );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText("a ProjectBuildingResult with message ")

Review comment:
       space

##########
File path: maven-core/src/main/java/org/apache/maven/project/ProjectBuildingException.java
##########
@@ -72,7 +67,7 @@ protected ProjectBuildingException( String projectId, String message, File pomFi
 
     public ProjectBuildingException( List<ProjectBuildingResult> results )
     {
-        super( createMessage( results ) );
+        super( "Some problems were encountered while processing the POMs" );

Review comment:
       POMs? Not POM?




-- 
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



[GitHub] [maven] mthmulders commented on pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
mthmulders commented on pull request #672:
URL: https://github.com/apache/maven/pull/672#issuecomment-1042315625


   > A very nice improvement!
   
   Thanks! :-)


-- 
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



[GitHub] [maven] asfgit closed pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #672:
URL: https://github.com/apache/maven/pull/672


   


-- 
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



[GitHub] [maven] michael-o commented on pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #672:
URL: https://github.com/apache/maven/pull/672#issuecomment-1027022647


   Interesting, will happily review next couple of days...


-- 
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



[GitHub] [maven] michael-o commented on a change in pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
michael-o commented on a change in pull request #672:
URL: https://github.com/apache/maven/pull/672#discussion_r808411854



##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithLocationMatcher.java
##########
@@ -0,0 +1,87 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithLocationMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final int columnNumber;
+    private final int lineNumber;
+
+    ProjectBuildingResultWithLocationMatcher( int columnNumber, int lineNumber ) {
+        this.columnNumber = columnNumber;
+        this.lineNumber = lineNumber;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {

Review comment:
       curly on new line

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithProblemMessageMatcher.java
##########
@@ -0,0 +1,81 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithProblemMessageMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final String problemMessage;
+
+    ProjectBuildingResultWithProblemMessageMatcher( String problemMessage ) {

Review comment:
       curly on new line

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithProblemMessageMatcher.java
##########
@@ -0,0 +1,81 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithProblemMessageMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final String problemMessage;
+
+    ProjectBuildingResultWithProblemMessageMatcher( String problemMessage ) {
+        this.problemMessage = problemMessage;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getMessage().contains( problemMessage ) );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText( "a ProjectBuildingResult with message " )
+                .appendValue(problemMessage);
+    }
+
+    @Override
+    public void describeMismatch(final Object o, final Description description)
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            super.describeMismatch( o, description );
+        }
+        else
+        {
+            final ProjectBuildingResult r = (ProjectBuildingResult) o;
+            description.appendText( "was a ProjectBuildingResult with messages " );
+            String messages = r.getProblems().stream()
+                    .map( ModelProblem::getMessage )
+                    .map( m -> "\"" + m + "\"" + System.lineSeparator() )
+                    .collect( joining( ", ") );
+            description.appendText( messages );
+        }
+    }
+
+    static Matcher<ProjectBuildingResult> projectBuildingResultWithProblemMessage( String message ) {

Review comment:
       curly on new line

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithLocationMatcher.java
##########
@@ -0,0 +1,87 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithLocationMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final int columnNumber;
+    private final int lineNumber;
+
+    ProjectBuildingResultWithLocationMatcher( int columnNumber, int lineNumber ) {
+        this.columnNumber = columnNumber;
+        this.lineNumber = lineNumber;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getLineNumber() == lineNumber && p.getColumnNumber() == columnNumber );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText( "a ProjectBuildingResult with location " )
+                .appendText( formatLocation( columnNumber, lineNumber ) );
+    }
+
+    private String formatLocation( int columnNumber, int lineNumber )
+    {
+        return String.format( "line %d, column %d", lineNumber, columnNumber );
+    }
+
+    @Override
+    public void describeMismatch(final Object o, final Description description)
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            super.describeMismatch( o, description );
+        }
+        else
+        {
+            final ProjectBuildingResult r = (ProjectBuildingResult) o;
+            description.appendText( "was a ProjectBuildingResult with locations " );
+            String messages = r.getProblems().stream()
+                    .map( p -> formatLocation( p.getColumnNumber(), p.getLineNumber() ) )
+                    .collect( joining( ", ") );
+            description.appendText( messages );
+        }
+    }
+
+    static Matcher<ProjectBuildingResult> projectBuildingResultWithLocation( int columnNumber, int lineNumber ) {

Review comment:
       curly on new line

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithProblemMessageMatcher.java
##########
@@ -0,0 +1,81 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithProblemMessageMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final String problemMessage;
+
+    ProjectBuildingResultWithProblemMessageMatcher( String problemMessage ) {
+        this.problemMessage = problemMessage;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {
+            return false;
+        }
+
+        final ProjectBuildingResult r = (ProjectBuildingResult) o;
+
+        return r.getProblems().stream()
+                .anyMatch( p -> p.getMessage().contains( problemMessage ) );
+    }
+
+    @Override
+    public void describeTo( Description description )
+    {
+        description.appendText( "a ProjectBuildingResult with message " )
+                .appendValue(problemMessage);
+    }
+
+    @Override
+    public void describeMismatch(final Object o, final Description description)
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {

Review comment:
       curly on new line

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithLocationMatcher.java
##########
@@ -0,0 +1,87 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithLocationMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final int columnNumber;
+    private final int lineNumber;
+
+    ProjectBuildingResultWithLocationMatcher( int columnNumber, int lineNumber ) {

Review comment:
       curly on new line

##########
File path: maven-core/src/test/java/org/apache/maven/project/ProjectBuildingResultWithProblemMessageMatcher.java
##########
@@ -0,0 +1,81 @@
+package org.apache.maven.project;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.building.ModelProblem;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+
+import static java.util.stream.Collectors.joining;
+
+/**
+ * Hamcrest matcher to help create fluent assertions about {@link ProjectBuildingResult} instances.
+ */
+class ProjectBuildingResultWithProblemMessageMatcher extends BaseMatcher<ProjectBuildingResult>
+{
+    private final String problemMessage;
+
+    ProjectBuildingResultWithProblemMessageMatcher( String problemMessage ) {
+        this.problemMessage = problemMessage;
+    }
+
+    @Override
+    public boolean matches( Object o )
+    {
+        if ( !( o instanceof ProjectBuildingResult ) ) {

Review comment:
       curly on new line




-- 
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



[GitHub] [maven] mthmulders commented on a change in pull request #672: [MNG-7406] Better display of project building errors

Posted by GitBox <gi...@apache.org>.
mthmulders commented on a change in pull request #672:
URL: https://github.com/apache/maven/pull/672#discussion_r803489302



##########
File path: maven-core/src/main/java/org/apache/maven/project/ProjectBuildingException.java
##########
@@ -72,7 +67,7 @@ protected ProjectBuildingException( String projectId, String message, File pomFi
 
     public ProjectBuildingException( List<ProjectBuildingResult> results )
     {
-        super( createMessage( results ) );
+        super( "Some problems were encountered while processing the POMs" );

Review comment:
       That's what the original message said (see line 126 in the old code), it's a literal move. Happy to update if you feel it makes more sense to have the singular version.




-- 
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