• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Ekryd / sortpom / 3807

15 Oct 2024 05:03PM CUT coverage: 99.841%. Remained the same
3807

push

circleci

web-flow
chore(deps): update dependency org.mockito:mockito-core to v5.14.2

1256 of 1258 relevant lines covered (99.84%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/maven-plugin/src/main/java/sortpom/VerifyMojo.java
1
package sortpom;
2

3
import org.apache.maven.plugin.MojoFailureException;
4
import org.apache.maven.plugins.annotations.LifecyclePhase;
5
import org.apache.maven.plugins.annotations.Mojo;
6
import org.apache.maven.plugins.annotations.Parameter;
7
import sortpom.exception.ExceptionConverter;
8
import sortpom.logger.SortPomLogger;
9
import sortpom.parameter.PluginParameters;
10

11
/**
12
 * Verifies that the pom.xml is sorted. If the verification fails then the pom.xml is sorted.
13
 *
14
 * @author Bjorn Ekryd
15
 */
16
@Mojo(name = "verify", threadSafe = true, defaultPhase = LifecyclePhase.VALIDATE)
17
@SuppressWarnings({"UnusedDeclaration"})
18
public class VerifyMojo extends AbstractParentMojo {
1✔
19

20
  /** What should happen if verification fails. Can be either 'sort', 'warn' or 'stop' */
21
  @Parameter(property = "sort.verifyFail", defaultValue = "sort")
22
  private String verifyFail;
23

24
  /**
25
   * What kind of differences should trigger verify failure. Can be either 'xmlElements' or
26
   * 'strict'. Can be combined with ignoreLineSeparators
27
   */
28
  @Parameter(property = "sort.verifyFailOn", defaultValue = "xmlElements")
29
  private String verifyFailOn;
30

31
  /**
32
   * Saves the verification failure to an external xml file, recommended filename is
33
   * 'target/sortpom_reports/violation.xml'.
34
   */
35
  @Parameter(property = "sort.violationFilename")
36
  private String violationFilename;
37

38
  public void setup(SortPomLogger mavenLogger) throws MojoFailureException {
39
    new ExceptionConverter(
1✔
40
            () -> {
41
              var pluginParameters =
42
                  PluginParameters.builder()
1✔
43
                      .setPomFile(pomFile)
1✔
44
                      .setFileOutput(
1✔
45
                          createBackupFile, backupFileExtension, violationFilename, keepTimestamp)
46
                      .setEncoding(encoding)
1✔
47
                      .setFormatting(
1✔
48
                          lineSeparator,
49
                          expandEmptyElements,
50
                          spaceBeforeCloseEmptyElement,
51
                          keepBlankLines,
52
                          endWithNewline)
53
                      .setIndent(
1✔
54
                          nrOfIndentSpace, indentBlankLines, indentSchemaLocation, indentAttribute)
55
                      .setSortOrder(sortOrderFile, predefinedSortOrder)
1✔
56
                      .setSortEntities(
1✔
57
                          sortDependencies,
58
                          sortDependencyExclusions,
59
                          sortDependencyManagement,
60
                          sortPlugins,
61
                          sortProperties,
62
                          sortModules,
63
                          sortExecutions)
64
                      .setIgnoreLineSeparators(ignoreLineSeparators)
1✔
65
                      .setVerifyFail(verifyFail, verifyFailOn)
1✔
66
                      .build();
1✔
67

68
              sortPomImpl.setup(mavenLogger, pluginParameters);
1✔
69
            })
1✔
70
        .executeAndConvertException();
1✔
71
  }
1✔
72

73
  protected void sortPom() throws MojoFailureException {
74
    new ExceptionConverter(sortPomImpl::verifyPom).executeAndConvertException();
1✔
75
  }
1✔
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc