Skip to content

Commit b7cc076

Browse files
committed
Reformat using spotless
1 parent 3d9c28b commit b7cc076

File tree

67 files changed

+3851
-5066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3851
-5066
lines changed

plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/AbstractCompiler.java

+87-128
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,26 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424
* SOFTWARE.
2525
*/
26-
27-
import org.codehaus.plexus.util.DirectoryScanner;
28-
import org.slf4j.Logger;
29-
import org.slf4j.LoggerFactory;
30-
3126
import java.io.File;
3227
import java.io.IOException;
3328
import java.util.HashSet;
3429
import java.util.List;
3530
import java.util.Set;
3631

32+
import org.codehaus.plexus.util.DirectoryScanner;
33+
import org.slf4j.Logger;
34+
import org.slf4j.LoggerFactory;
35+
3736
/**
3837
* @author <a href="mailto:[email protected]">Jason van Zyl </a>
3938
* @author <a href="mailto:[email protected]">Michal Maczka </a>
4039
* @author <a href="mailto:[email protected]">Trygve Laugst&oslash;l</a>
4140
*/
42-
public abstract class AbstractCompiler
43-
implements Compiler
44-
{
45-
protected Logger log = LoggerFactory.getLogger ( getClass() );
41+
public abstract class AbstractCompiler implements Compiler {
42+
protected Logger log = LoggerFactory.getLogger(getClass());
4643
protected static final String EOL = System.lineSeparator();
4744

48-
protected static final String PS = System.getProperty( "path.separator" );
45+
protected static final String PS = System.getProperty("path.separator");
4946

5047
private final CompilerOutputStyle compilerOutputStyle;
5148

@@ -59,9 +56,11 @@ public abstract class AbstractCompiler
5956
//
6057
// ----------------------------------------------------------------------
6158

62-
protected AbstractCompiler( CompilerOutputStyle compilerOutputStyle, String inputFileEnding,
63-
String outputFileEnding, String outputFile )
64-
{
59+
protected AbstractCompiler(
60+
CompilerOutputStyle compilerOutputStyle,
61+
String inputFileEnding,
62+
String outputFileEnding,
63+
String outputFile) {
6564
this.compilerOutputStyle = compilerOutputStyle;
6665

6766
this.inputFileEnding = inputFileEnding;
@@ -77,91 +76,71 @@ protected AbstractCompiler( CompilerOutputStyle compilerOutputStyle, String inpu
7776

7877
public abstract String getCompilerId();
7978

80-
public CompilerResult performCompile(CompilerConfiguration configuration)
81-
throws CompilerException
82-
{
79+
public CompilerResult performCompile(CompilerConfiguration configuration) throws CompilerException {
8380
throw new CompilerNotImplementedException("The performCompile method has not been implemented.");
8481
}
8582

86-
public CompilerOutputStyle getCompilerOutputStyle()
87-
{
83+
public CompilerOutputStyle getCompilerOutputStyle() {
8884
return compilerOutputStyle;
8985
}
9086

91-
public String getInputFileEnding( CompilerConfiguration configuration )
92-
throws CompilerException
93-
{
87+
public String getInputFileEnding(CompilerConfiguration configuration) throws CompilerException {
9488
return inputFileEnding;
9589
}
9690

97-
public String getOutputFileEnding( CompilerConfiguration configuration )
98-
throws CompilerException
99-
{
100-
if ( compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE )
101-
{
102-
throw new RuntimeException( "This compiler implementation doesn't have one output file per input file." );
91+
public String getOutputFileEnding(CompilerConfiguration configuration) throws CompilerException {
92+
if (compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE) {
93+
throw new RuntimeException("This compiler implementation doesn't have one output file per input file.");
10394
}
10495

10596
return outputFileEnding;
10697
}
10798

108-
public String getOutputFile( CompilerConfiguration configuration )
109-
throws CompilerException
110-
{
111-
if ( compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES )
112-
{
113-
throw new RuntimeException( "This compiler implementation doesn't have one output file for all files." );
99+
public String getOutputFile(CompilerConfiguration configuration) throws CompilerException {
100+
if (compilerOutputStyle != CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES) {
101+
throw new RuntimeException("This compiler implementation doesn't have one output file for all files.");
114102
}
115103

116104
return outputFile;
117105
}
118106

119-
public boolean canUpdateTarget( CompilerConfiguration configuration )
120-
throws CompilerException
121-
{
107+
public boolean canUpdateTarget(CompilerConfiguration configuration) throws CompilerException {
122108
return true;
123109
}
124110

125111
// ----------------------------------------------------------------------
126112
// Utility Methods
127113
// ----------------------------------------------------------------------
128114

129-
public static String getPathString( List<String> pathElements )
130-
{
115+
public static String getPathString(List<String> pathElements) {
131116
StringBuilder sb = new StringBuilder();
132117

133-
for ( String pathElement : pathElements )
134-
{
135-
sb.append( pathElement ).append( File.pathSeparator );
118+
for (String pathElement : pathElements) {
119+
sb.append(pathElement).append(File.pathSeparator);
136120
}
137121

138122
return sb.toString();
139123
}
140124

141-
protected static Set<String> getSourceFilesForSourceRoot( CompilerConfiguration config, String sourceLocation )
142-
{
125+
protected static Set<String> getSourceFilesForSourceRoot(CompilerConfiguration config, String sourceLocation) {
143126
DirectoryScanner scanner = new DirectoryScanner();
144127

145-
scanner.setBasedir( sourceLocation );
128+
scanner.setBasedir(sourceLocation);
146129

147130
Set<String> includes = config.getIncludes();
148131

149-
if ( includes != null && !includes.isEmpty() )
150-
{
151-
String[] inclStrs = includes.toArray( new String[0] );
152-
scanner.setIncludes( inclStrs );
153-
}
154-
else
155-
{
156-
scanner.setIncludes( new String[]{ "**/*.java" } );
132+
if (includes != null && !includes.isEmpty()) {
133+
String[] inclStrs = includes.toArray(new String[0]);
134+
scanner.setIncludes(inclStrs);
135+
} else {
136+
scanner.setIncludes(new String[] {"**/*.java"});
157137
}
158138

159139
Set<String> excludes = config.getExcludes();
160140

161-
if ( excludes != null && !excludes.isEmpty() )
162-
{
163-
String[] exclStrs = excludes.toArray( new String[0] );
164-
scanner.setExcludes( exclStrs );
141+
if (excludes != null && !excludes.isEmpty()) {
142+
String[] exclStrs = excludes.toArray(new String[0]);
143+
scanner.setExcludes(exclStrs);
165144
}
166145

167146
scanner.scan();
@@ -170,125 +149,105 @@ protected static Set<String> getSourceFilesForSourceRoot( CompilerConfiguration
170149

171150
Set<String> sources = new HashSet<>();
172151

173-
for ( String sourceDirectorySource : sourceDirectorySources )
174-
{
175-
File f = new File( sourceLocation, sourceDirectorySource );
152+
for (String sourceDirectorySource : sourceDirectorySources) {
153+
File f = new File(sourceLocation, sourceDirectorySource);
176154

177-
sources.add( f.getPath() );
155+
sources.add(f.getPath());
178156
}
179157

180158
return sources;
181159
}
182160

183-
protected static String[] getSourceFiles( CompilerConfiguration config )
184-
{
161+
protected static String[] getSourceFiles(CompilerConfiguration config) {
185162
Set<String> sources = new HashSet<>();
186163

187164
Set<File> sourceFiles = config.getSourceFiles();
188165

189-
if ( sourceFiles != null && !sourceFiles.isEmpty() )
190-
{
191-
for ( File sourceFile : sourceFiles )
192-
{
193-
sources.add( sourceFile.getAbsolutePath() );
166+
if (sourceFiles != null && !sourceFiles.isEmpty()) {
167+
for (File sourceFile : sourceFiles) {
168+
sources.add(sourceFile.getAbsolutePath());
194169
}
195-
}
196-
else
197-
{
198-
for ( String sourceLocation : config.getSourceLocations() )
199-
{
200-
sources.addAll( getSourceFilesForSourceRoot( config, sourceLocation ) );
170+
} else {
171+
for (String sourceLocation : config.getSourceLocations()) {
172+
sources.addAll(getSourceFilesForSourceRoot(config, sourceLocation));
201173
}
202174
}
203175

204176
String[] result;
205177

206-
if ( sources.isEmpty() )
207-
{
178+
if (sources.isEmpty()) {
208179
result = new String[0];
209-
}
210-
else
211-
{
212-
result = sources.toArray( new String[0] );
180+
} else {
181+
result = sources.toArray(new String[0]);
213182
}
214183

215184
return result;
216185
}
217186

218-
protected static String makeClassName( String fileName, String sourceDir )
219-
throws CompilerException
220-
{
221-
File origFile = new File( fileName );
187+
protected static String makeClassName(String fileName, String sourceDir) throws CompilerException {
188+
File origFile = new File(fileName);
222189

223190
String canonical = null;
224191

225-
if ( origFile.exists() )
226-
{
227-
canonical = getCanonicalPath( origFile ).replace( '\\', '/' );
192+
if (origFile.exists()) {
193+
canonical = getCanonicalPath(origFile).replace('\\', '/');
228194
}
229195

230-
if ( sourceDir != null )
231-
{
232-
String prefix = getCanonicalPath( new File( sourceDir ) ).replace( '\\', '/' );
196+
if (sourceDir != null) {
197+
String prefix = getCanonicalPath(new File(sourceDir)).replace('\\', '/');
233198

234-
if ( canonical != null )
235-
{
236-
if ( canonical.startsWith( prefix ) )
237-
{
238-
String result = canonical.substring( prefix.length() + 1, canonical.length() - 5 );
199+
if (canonical != null) {
200+
if (canonical.startsWith(prefix)) {
201+
String result = canonical.substring(prefix.length() + 1, canonical.length() - 5);
239202

240-
result = result.replace( '/', '.' );
203+
result = result.replace('/', '.');
241204

242205
return result;
243206
}
244-
}
245-
else
246-
{
247-
File t = new File( sourceDir, fileName );
207+
} else {
208+
File t = new File(sourceDir, fileName);
248209

249-
if ( t.exists() )
250-
{
251-
String str = getCanonicalPath( t ).replace( '\\', '/' );
210+
if (t.exists()) {
211+
String str = getCanonicalPath(t).replace('\\', '/');
252212

253-
return str.substring( prefix.length() + 1, str.length() - 5 ).replace( '/', '.' );
213+
return str.substring(prefix.length() + 1, str.length() - 5).replace('/', '.');
254214
}
255215
}
256216
}
257217

258-
if ( fileName.endsWith( ".java" ) )
259-
{
260-
fileName = fileName.substring( 0, fileName.length() - 5 );
218+
if (fileName.endsWith(".java")) {
219+
fileName = fileName.substring(0, fileName.length() - 5);
261220
}
262221

263-
fileName = fileName.replace( '\\', '.' );
222+
fileName = fileName.replace('\\', '.');
264223

265-
return fileName.replace( '/', '.' );
224+
return fileName.replace('/', '.');
266225
}
267226

268-
private static String getCanonicalPath( File origFile )
269-
throws CompilerException
270-
{
271-
try
272-
{
227+
private static String getCanonicalPath(File origFile) throws CompilerException {
228+
try {
273229
return origFile.getCanonicalPath();
274-
}
275-
catch ( IOException e )
276-
{
230+
} catch (IOException e) {
277231
throw new CompilerException(
278-
"Error while getting the canonical path of '" + origFile.getAbsolutePath() + "'.", e );
232+
"Error while getting the canonical path of '" + origFile.getAbsolutePath() + "'.", e);
279233
}
280234
}
281235

282-
protected void logCompiling( String[] sourceFiles, CompilerConfiguration config )
283-
{
284-
if ( log.isInfoEnabled() )
285-
{
286-
String to = ( config.getWorkingDirectory() == null ) ? config.getOutputLocation() :
287-
config.getWorkingDirectory().toPath().relativize( new File( config.getOutputLocation() ).toPath() ).toString();
288-
log.info( "Compiling " +
289-
( sourceFiles == null ? "" : ( sourceFiles.length + " source file" + ( sourceFiles.length == 1 ? " " : "s " ) ) ) +
290-
"with " + getCompilerId() + " [" + config.describe() + "]" +
291-
" to " + to );
236+
protected void logCompiling(String[] sourceFiles, CompilerConfiguration config) {
237+
if (log.isInfoEnabled()) {
238+
String to = (config.getWorkingDirectory() == null)
239+
? config.getOutputLocation()
240+
: config.getWorkingDirectory()
241+
.toPath()
242+
.relativize(new File(config.getOutputLocation()).toPath())
243+
.toString();
244+
log.info("Compiling "
245+
+ (sourceFiles == null
246+
? ""
247+
: (sourceFiles.length + " source file" + (sourceFiles.length == 1 ? " " : "s ")))
248+
+ "with "
249+
+ getCompilerId() + " [" + config.describe() + "]" + " to "
250+
+ to);
292251
}
293-
}
252+
}
294253
}

0 commit comments

Comments
 (0)