SDS
SDS

Reputation: 828

Add a new line between dependencies via google sort pom plugin

Is there a way to add a new line between each dependency via the google sort pom plugin or any other plugin.

Current POM, sorted via google sort pom plugin

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.8.5</version>
</dependency>
<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-core</artifactId>
    <version>1.4.10</version>
</dependency>

I'm trying to achieve

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.8.5</version>
</dependency>

<dependency>
    <groupId>org.powermock</groupId>
    <artifactId>powermock-core</artifactId>
    <version>1.4.10</version>
</dependency>

My current pom plugin

<plugin>
    <groupId>com.google.code.sortpom</groupId>
    <artifactId>maven-sortpom-plugin</artifactId>
    <version>${com.google.code.sortpom}</version>
    <configuration>
        <predefinedSortOrder>custom_1</predefinedSortOrder>
        <sortDependencies>groupId,artifactId</sortDependencies>
        <sortPlugins>groupId,artifactId</sortPlugins>
        <sortProperties>false</sortProperties>
        <createBackupFile>false</createBackupFile>
        <lineSeparator>\r\n</lineSeparator>
        <expandEmptyElements>false</expandEmptyElements>
        <keepBlankLines>true</keepBlankLines>
        <nrOfIndentSpace>-1</nrOfIndentSpace>
        <verifyFail>Warn</verifyFail>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>sort</goal>
            </goals>
            <phase>compile</phase>
        </execution>
    </executions>
</plugin>

Upvotes: 0

Views: 480

Answers (2)

user2381162
user2381162

Reputation: 36

At the moment the maven-sortpom-plugin does not have an automatic way of inserting blank lines between dependencies.

However, if you have a empty line between two existing dependencies, the plugin will not remove the line during sorting since you use the configuration option <keepBlankLines>true</keepBlankLines>

Upvotes: 1

user177800
user177800

Reputation:

Its just an XML file

Just use your IDE's built in XML formatter to format the pom.xml file however you want. Both Eclipse and Intellij IDEA have formatters for XML files.

Upvotes: 0

Related Questions