Skip to content

Commit

Permalink
Apply spotless plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz committed Mar 17, 2024
1 parent e8db89e commit cf4c400
Show file tree
Hide file tree
Showing 155 changed files with 3,042 additions and 4,601 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@

import java.util.Map;

public abstract class AbstractEnvFactory
implements EnvFactory
{
public abstract class AbstractEnvFactory implements EnvFactory {

private static Map<String, String> envs;

@Override
public synchronized Map<String, String> getEnvironmentVariables()
throws NativeBuildException
{
if ( envs == null )
{
public synchronized Map<String, String> getEnvironmentVariables() throws NativeBuildException {
if (envs == null) {
envs = createEnvs();
}

return envs;
}

protected abstract Map<String, String> createEnvs()
throws NativeBuildException;

protected abstract Map<String, String> createEnvs() throws NativeBuildException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@
*/
package org.codehaus.mojo.natives;

public class ConfigurationBase
{
public class ConfigurationBase {
private EnvFactory envFactory;

public EnvFactory getEnvFactory()
{
public EnvFactory getEnvFactory() {
return envFactory;
}

public void setEnvFactory( EnvFactory envFactory )
{
public void setEnvFactory(EnvFactory envFactory) {
this.envFactory = envFactory;
}

}
162 changes: 58 additions & 104 deletions maven-native-api/src/main/java/org/codehaus/mojo/natives/Dependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
* @author <a href="mailto:dantran@gmail.com">Dan Tran</a>
* @version $Id$
*/

public class Dependency
{
public class Dependency {
/**
* Field source
*/
Expand All @@ -62,18 +60,15 @@ public class Dependency

Dependency parent;

public Dependency( Dependency parent, File source, Parser parser, File[] includePaths )
{
init( parent, source, parser, includePaths );
public Dependency(Dependency parent, File source, Parser parser, File[] includePaths) {
init(parent, source, parser, includePaths);
}

public Dependency( File source, Parser parser, File[] includePaths )
{
init( null, source, parser, includePaths );
public Dependency(File source, Parser parser, File[] includePaths) {
init(null, source, parser, includePaths);
}

private void init( Dependency parent, File source, Parser parser, File[] includePaths )
{
private void init(Dependency parent, File source, Parser parser, File[] includePaths) {
this.parent = parent;

this.source = source.getPath();
Expand All @@ -82,81 +77,63 @@ private void init( Dependency parent, File source, Parser parser, File[] include

this.parser = parser;

if ( includePaths == null )
{
if (includePaths == null) {
this.includePaths = new File[0];
}
else
{
} else {
this.includePaths = includePaths;
}
}

public void analyze()
throws IOException
{
public void analyze() throws IOException {
String[] includeNames = getIncludeNames();

File[] resolvedIncludeFiles = resolveIncludeNames( includeNames );
File[] resolvedIncludeFiles = resolveIncludeNames(includeNames);

for ( File fileName : resolvedIncludeFiles )
{
Dependency depend = new Dependency( this, fileName, this.parser, this.includePaths );
for (File fileName : resolvedIncludeFiles) {
Dependency depend = new Dependency(this, fileName, this.parser, this.includePaths);

if ( !this.getRoot().contains( depend ) )
{
this.addDependency( depend );
if (!this.getRoot().contains(depend)) {
this.addDependency(depend);
}
}

for ( int i = 0; i < this.getDependencies().size(); ++i )
{
Dependency depend = this.getDependencies().get( i );
for (int i = 0; i < this.getDependencies().size(); ++i) {
Dependency depend = this.getDependencies().get(i);
depend.analyze();
}

}

private Dependency getRoot()
{
private Dependency getRoot() {
Dependency root = this;

while ( root.getParent() != null )
{
while (root.getParent() != null) {
root = root.getParent();
}

return root;
}

public Dependency getParent()
{
public Dependency getParent() {
return this.parent;
}

public long getCompositeLastModified()
{
public long getCompositeLastModified() {
long currentLastModify = this.lastModified;

for ( Dependency dependency : this.getDependencies() )
{
for (Dependency dependency : this.getDependencies()) {
long lastModified = dependency.getCompositeLastModified();

if ( lastModified > currentLastModify )
{
if (lastModified > currentLastModify) {
currentLastModify = lastModified;
}
}

return currentLastModify;
}

private String[] getIncludeNames()
throws IOException
{
try ( Reader reader = new BufferedReader( new FileReader( this.source ) ) )
{
parser.parse( reader );
private String[] getIncludeNames() throws IOException {
try (Reader reader = new BufferedReader(new FileReader(this.source))) {
parser.parse(reader);
return parser.getIncludes();
}
}
Expand All @@ -166,26 +143,21 @@ private String[] getIncludeNames()
* @return
* @throws IOException
*/
private File[] resolveIncludeNames( String[] includeNames )
throws IOException
{
ArrayList<File> resolvedIncludeFiles = new ArrayList<>( includeNames.length );

for ( String includeName : includeNames )
{
File resolvedFile = resolveSingleIncludeName( includeName );

if ( resolvedFile != null )
{
resolvedIncludeFiles.add( resolvedFile );
private File[] resolveIncludeNames(String[] includeNames) throws IOException {
ArrayList<File> resolvedIncludeFiles = new ArrayList<>(includeNames.length);

for (String includeName : includeNames) {
File resolvedFile = resolveSingleIncludeName(includeName);

if (resolvedFile != null) {
resolvedIncludeFiles.add(resolvedFile);
}
}

File[] arrayResolvedIncludeFiles = new File[resolvedIncludeFiles.size()];

for ( int j = 0; j < arrayResolvedIncludeFiles.length; ++j )
{
arrayResolvedIncludeFiles[j] = resolvedIncludeFiles.get( j );
for (int j = 0; j < arrayResolvedIncludeFiles.length; ++j) {
arrayResolvedIncludeFiles[j] = resolvedIncludeFiles.get(j);
}

return arrayResolvedIncludeFiles;
Expand All @@ -198,21 +170,17 @@ private File[] resolveIncludeNames( String[] includeNames )
* @return an file or null when it is not found in user include path
* @throws IOException
*/

private File resolveSingleIncludeName( String includeName )
throws IOException
{
private File resolveSingleIncludeName(String includeName) throws IOException {
File includeFile = null;

File[] sourcePath = new File[1];

sourcePath[0] = new File( new File( this.source ).getParent() ); // TODO
sourcePath[0] = new File(new File(this.source).getParent()); // TODO

includeFile = this.resolveSingleIncludeNameFromPaths( includeName, sourcePath );
includeFile = this.resolveSingleIncludeNameFromPaths(includeName, sourcePath);

if ( includeFile == null )
{
includeFile = this.resolveSingleIncludeNameFromPaths( includeName, this.includePaths );
if (includeFile == null) {
includeFile = this.resolveSingleIncludeNameFromPaths(includeName, this.includePaths);
}

return includeFile;
Expand All @@ -225,17 +193,14 @@ private File resolveSingleIncludeName( String includeName )
* @param includePath
* @return
*/
private File resolveSingleIncludeNameFromPaths( String includeName, File[] includePath )
{
private File resolveSingleIncludeNameFromPaths(String includeName, File[] includePath) {
File includeFile = null;

for ( File file : includePath )
{
File tmpFile = new File( file, includeName );
for (File file : includePath) {
File tmpFile = new File(file, includeName);

// make sure we dont pickup directory like STL which has no extension
if ( tmpFile.exists() && tmpFile.isFile() )
{
if (tmpFile.exists() && tmpFile.isFile()) {
includeFile = tmpFile;

break;
Expand All @@ -250,18 +215,15 @@ private File resolveSingleIncludeNameFromPaths( String includeName, File[] inclu
*
* @param dependency
*/
public void addDependency( Dependency dependency )
{
getDependencies().add( dependency );
public void addDependency(Dependency dependency) {
getDependencies().add(dependency);
}

/**
* Method getDependencies
*/
public java.util.List<Dependency> getDependencies()
{
if ( this.dependencies == null )
{
public java.util.List<Dependency> getDependencies() {
if (this.dependencies == null) {
this.dependencies = new java.util.ArrayList<>();
}

Expand All @@ -271,45 +233,37 @@ public java.util.List<Dependency> getDependencies()
/**
* Method getLastModified
*/
public long getLastModified()
{
public long getLastModified() {
return this.lastModified;
}

/**
* Method getSource
*/
public String getSource()
{
public String getSource() {
return this.source;
}

// helper for testing only
boolean contains( Dependency dependent )
{
if ( this.source.equals( dependent.getSource() ) )
{
boolean contains(Dependency dependent) {
if (this.source.equals(dependent.getSource())) {
return true;
}

for ( int i = 0; i < this.getDependencies().size(); ++i )
{
Dependency node = this.getDependencies().get( i );
if ( node.contains( dependent ) )
{
for (int i = 0; i < this.getDependencies().size(); ++i) {
Dependency node = this.getDependencies().get(i);
if (node.contains(dependent)) {
return true;
}
}

return false;
}

int getDeepDependencyCount()
{
int getDeepDependencyCount() {
int ret = this.getDependencies().size();
for ( int i = 0; i < this.getDependencies().size(); ++i )
{
Dependency node = this.getDependencies().get( i );
for (int i = 0; i < this.getDependencies().size(); ++i) {
Dependency node = this.getDependencies().get(i);
ret += node.getDeepDependencyCount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
/**
* @author dtran
*/
public interface EnvFactory
{
public interface EnvFactory {
/**
* @return a map of environment variable/value pairs
* @throws NativeBuildException
*/
Map<String, String> getEnvironmentVariables()
throws NativeBuildException;

Map<String, String> getEnvironmentVariables() throws NativeBuildException;
}

0 comments on commit cf4c400

Please sign in to comment.