Skip to content
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

Enable spotless plugin - automatic code formatting #346

Merged
merged 2 commits into from Mar 18, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 39 additions & 24 deletions pom.xml
Expand Up @@ -33,10 +33,8 @@

<name>Maven Flatten Plugin</name>

<description>
Plugin to generate flattened POM (reduced and resolved information required for consumers of maven repositories)
and to use (install, sign, deploy) it instead of original pom.xml.
</description>
<description>Plugin to generate flattened POM (reduced and resolved information required for consumers of maven repositories)
and to use (install, sign, deploy) it instead of original pom.xml.</description>

<url>https://www.mojohaus.org/flatten-maven-plugin/</url>

Expand Down Expand Up @@ -64,10 +62,10 @@
<id>rfscholte</id>
<name>Robert Scholte</name>
<email>rfscholte@apache.org</email>
<timezone>Europe/Amsterdam</timezone>
<roles>
<role>developer</role>
</roles>
<timezone>Europe/Amsterdam</timezone>
</developer>
<developer>
<id>khmarbaise</id>
Expand All @@ -80,10 +78,10 @@
<id>sjaranowski</id>
<name>Slawomir Jaranowski</name>
<email>sjaranowski@apache.org</email>
<timezone>Europe/Warsaw</timezone>
<roles>
<role>developer</role>
</roles>
<timezone>Europe/Warsaw</timezone>
</developer>
</developers>

Expand Down Expand Up @@ -124,12 +122,13 @@
<scm>
<connection>scm:git:https://github.com/mojohaus/flatten-maven-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/mojohaus/flatten-maven-plugin.git</developerConnection>
<url>https://github.com/mojohaus/flatten-maven-plugin/tree/master</url>
<tag>HEAD</tag>
<url>https://github.com/mojohaus/flatten-maven-plugin/tree/master</url>
</scm>

<properties>
<mavenVersion>3.2.5</mavenVersion>
<recommendedJavaBuildVersion>11</recommendedJavaBuildVersion>
<project.build.outputTimestamp>2022-08-16T21:49:15Z</project.build.outputTimestamp>
</properties>

Expand Down Expand Up @@ -227,6 +226,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>${checkstyle.spotless.config}</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -242,7 +244,6 @@
</plugins>
</build>


<reporting>
<plugins>
<plugin>
Expand All @@ -259,22 +260,27 @@
</reporting>

<profiles>
<profile>
<id>java11+</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>run-its</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<debug>true</debug>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
Expand All @@ -293,19 +299,20 @@
<postBuildHookScript>verify</postBuildHookScript>
<preBuildHookScript>setup</preBuildHookScript>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
<goal>install</goal>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<configuration>
<propertyName>repository.proxy.url</propertyName>
<repositories>
Expand All @@ -318,6 +325,14 @@
<proxyRepo />
</repositories>
</configuration>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
155 changes: 74 additions & 81 deletions src/main/java/org/codehaus/mojo/flatten/AbstractFlattenMojo.java
@@ -1,81 +1,74 @@
package org.codehaus.mojo.flatten;

/*
* 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 java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
* This is the abstract base class for {@link AbstractMojo MOJOs} that realize the different goals of this plugin.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
*/
public abstract class AbstractFlattenMojo
extends AbstractMojo
{

/**
* The directory where the generated flattened POM file will be written to.
*/
@Parameter( defaultValue = "${project.basedir}" )
private File outputDirectory;

/**
* The filename of the generated flattened POM file.
*/
@Parameter( property = "flattenedPomFilename", defaultValue = ".flattened-pom.xml" )
private String flattenedPomFilename;

/**
* The constructor.
*/
public AbstractFlattenMojo()
{

super();
}

/**
* @return the filename of the generated flattened POM file.
*/
public String getFlattenedPomFilename()
{
return this.flattenedPomFilename;
}

/**
* @return the directory where the generated flattened POM file will be written to.
*/
public File getOutputDirectory()
{
return this.outputDirectory;
}

/**
* @return a {@link File} instance pointing to the flattened POM.
*/
protected File getFlattenedPomFile()
{
return new File( getOutputDirectory(), getFlattenedPomFilename() );
}

}
package org.codehaus.mojo.flatten;

/*
* 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 java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;

/**
* This is the abstract base class for {@link AbstractMojo MOJOs} that realize the different goals of this plugin.
*
* @author Joerg Hohwiller (hohwille at users.sourceforge.net)
*/
public abstract class AbstractFlattenMojo extends AbstractMojo {

/**
* The directory where the generated flattened POM file will be written to.
*/
@Parameter(defaultValue = "${project.basedir}")
private File outputDirectory;

/**
* The filename of the generated flattened POM file.
*/
@Parameter(property = "flattenedPomFilename", defaultValue = ".flattened-pom.xml")
private String flattenedPomFilename;

/**
* The constructor.
*/
public AbstractFlattenMojo() {

super();
}

/**
* @return the filename of the generated flattened POM file.
*/
public String getFlattenedPomFilename() {
return this.flattenedPomFilename;
}

/**
* @return the directory where the generated flattened POM file will be written to.
*/
public File getOutputDirectory() {
return this.outputDirectory;
}

/**
* @return a {@link File} instance pointing to the flattened POM.
*/
protected File getFlattenedPomFile() {
return new File(getOutputDirectory(), getFlattenedPomFilename());
}
}