Skip to content

Commit

Permalink
Enable spotless - code reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed May 11, 2023
1 parent 3b80a09 commit 835a015
Show file tree
Hide file tree
Showing 34 changed files with 1,900 additions and 2,392 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<url>https://www.mojohaus.org/build-helper-maven-plugin/</url>

<name>Build Helper Maven Plugin</name>
<description>This plugin contains various small independent goals to assist with Maven build lifecycle</description>
<url>https://www.mojohaus.org/build-helper-maven-plugin/</url>
<inceptionYear>2005</inceptionYear>
<licenses>
<license>
Expand Down Expand Up @@ -59,8 +59,8 @@
<scm>
<connection>scm:git:https://github.com/mojohaus/build-helper-maven-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/mojohaus/build-helper-maven-plugin.git</developerConnection>
<url>https://github.com/mojohaus/build-helper-maven-plugin/tree/master</url>
<tag>HEAD</tag>
<url>https://github.com/mojohaus/build-helper-maven-plugin/tree/master</url>
</scm>

<issueManagement>
Expand Down Expand Up @@ -115,9 +115,9 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>file-management</artifactId>
<version>3.1.0</version>
<groupId>org.apache.maven.shared</groupId>
<artifactId>file-management</artifactId>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,33 @@
/**
* Abstract Mojo for adding Resources
*/
public abstract class AbstractAddResourceMojo
extends AbstractMojo
{
public abstract class AbstractAddResourceMojo extends AbstractMojo {
/**
* Additional resource directories.
*/
@Parameter( required = true )
@Parameter(required = true)
private Resource[] resources;

/**
* The maven project
*/
@Parameter( readonly = true, defaultValue = "${project}" )
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;

/**
* Main plugin execution
*/
public void execute()
{
for ( Resource resource : resources )
{
public void execute() {
for (Resource resource : resources) {
// Check for relative paths in the resource configuration.
// http://maven.apache.org/plugin-developers/common-bugs.html#Resolving_Relative_Paths
File resourceDir = new File( resource.getDirectory() );
if ( !resourceDir.isAbsolute() )
{
resourceDir = new File( project.getBasedir(), resource.getDirectory() );
resource.setDirectory( resourceDir.getAbsolutePath() );
File resourceDir = new File(resource.getDirectory());
if (!resourceDir.isAbsolute()) {
resourceDir = new File(project.getBasedir(), resource.getDirectory());
resource.setDirectory(resourceDir.getAbsolutePath());
}

addResource( resource );
addResource(resource);
}
}

Expand All @@ -74,15 +69,14 @@ public void execute()
*
* @param resource the resource to add
*/
public abstract void addResource( Resource resource );
public abstract void addResource(Resource resource);

/**
* Get the current project instance.
*
* @return the project
*/
public MavenProject getProject()
{
public MavenProject getProject() {
return this.project;
}
}
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
package org.codehaus.mojo.buildhelper;

/*
* The MIT License
*
* Copyright (c) 2004, The Codehaus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

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

public abstract class AbstractDefinePropertyMojo
extends AbstractMojo
{
/**
* The maven project
*/
@Parameter( readonly = true, defaultValue = "${project}" )
protected MavenProject project;

protected void defineProperty( String name, String value )
{
if ( getLog().isDebugEnabled() )
{
getLog().debug( "define property " + name + " = \"" + value + "\"" );
}

project.getProperties().put( name, value );
}

/**
* Get the current project instance.
*
* @return the project
*/
public MavenProject getProject()
{
return this.project;
}
}
package org.codehaus.mojo.buildhelper;

/*
* The MIT License
*
* Copyright (c) 2004, The Codehaus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

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

public abstract class AbstractDefinePropertyMojo extends AbstractMojo {
/**
* The maven project
*/
@Parameter(readonly = true, defaultValue = "${project}")
protected MavenProject project;

protected void defineProperty(String name, String value) {
if (getLog().isDebugEnabled()) {
getLog().debug("define property " + name + " = \"" + value + "\"");
}

project.getProperties().put(name, value);
}

/**
* Get the current project instance.
*
* @return the project
*/
public MavenProject getProject() {
return this.project;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.codehaus.mojo.buildhelper;

import java.util.Locale;

/*
* The MIT License
*
Expand All @@ -26,6 +24,7 @@
* SOFTWARE.
*/

import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
Expand All @@ -34,64 +33,47 @@
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.StringUtils;

public abstract class AbstractRegexPropertyMojo
extends AbstractDefinePropertyMojo
{
public abstract class AbstractRegexPropertyMojo extends AbstractDefinePropertyMojo {

protected void execute( RegexPropertySetting config )
throws MojoExecutionException, MojoFailureException
{
try
{
protected void execute(RegexPropertySetting config) throws MojoExecutionException, MojoFailureException {
try {
config.validate();
}
catch ( IllegalArgumentException e )
{
throw new MojoExecutionException( e.getMessage(), e );
} catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage(), e);
}

Pattern pattern;
try
{
pattern = Pattern.compile( config.getRegex() );
try {
pattern = Pattern.compile(config.getRegex());
} catch (PatternSyntaxException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
catch ( PatternSyntaxException e )
{
throw new MojoExecutionException( e.getMessage(), e );
}
Matcher matcher = pattern.matcher( config.getValue() );
Matcher matcher = pattern.matcher(config.getValue());

if ( matcher.find() )
{
if (matcher.find()) {
// if the string replacement is empty, we define the value replacement to empty.
config.setValue( ( StringUtils.isNotEmpty( config.getReplacement() )
? matcher.replaceAll( config.getReplacement() ) : matcher.replaceAll( "" ) ) );
}
else
{
if ( config.isFailIfNoMatch() )
{
throw new MojoFailureException( "No match to regex '" + config.getRegex() + "' found in '"
+ config.getValue() + "'." );
}
else
{
getLog().info( "No match to regex '" + config.getRegex() + "' found in '" + config.getValue() + "'. "
+ "The initial value '" + config.getValue() + "' is left as-is..." );
config.setValue(
(StringUtils.isNotEmpty(config.getReplacement())
? matcher.replaceAll(config.getReplacement())
: matcher.replaceAll("")));
} else {
if (config.isFailIfNoMatch()) {
throw new MojoFailureException(
"No match to regex '" + config.getRegex() + "' found in '" + config.getValue() + "'.");
} else {
getLog().info("No match to regex '" + config.getRegex() + "' found in '" + config.getValue() + "'. "
+ "The initial value '" + config.getValue() + "' is left as-is...");
}
}

if ( config.isToLowerCase() )
{
config.setValue( config.getValue().toLowerCase( Locale.getDefault() ) );
if (config.isToLowerCase()) {
config.setValue(config.getValue().toLowerCase(Locale.getDefault()));
}

if ( config.isToUpperCase() )
{
config.setValue( config.getValue().toUpperCase( Locale.getDefault() ) );
if (config.isToUpperCase()) {
config.setValue(config.getValue().toUpperCase(Locale.getDefault()));
}

defineProperty( config.getName(), config.getValue() );

defineProperty(config.getName(), config.getValue());
}
}

0 comments on commit 835a015

Please sign in to comment.