Skip to content

Commit 64f9c77

Browse files
committed
🎨 trim trailing whitespaces
1 parent 8a078f7 commit 64f9c77

12 files changed

+134
-139
lines changed

src/main/java/scala_maven/FileUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import java.io.File;
44

55
class FileUtils extends org.codehaus.plexus.util.FileUtils {
6-
6+
77
/**
88
* @param canonical Should use CanonicalPath to normalize path (true => getCanonicalPath, false => getAbsolutePath)
99
* @see <a href="https://github.com/davidB/maven-scala-plugin/issues/50">#50</a>
1010
*/
1111
public static String pathOf(File f, boolean canonical) throws Exception {
1212
return canonical? f.getCanonicalPath() : f.getAbsolutePath();
1313
}
14-
14+
1515
/**
1616
* @param canonical Should use CanonicalPath to normalize path (true => getCanonicalPath, false =&gt; getAbsolutePath)
1717
* @see <a href="https://github.com/davidB/maven-scala-plugin/issues/50">#50</a>

src/main/java/scala_maven/ScalaCompilerSupport.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
* Abstract parent of all Scala Mojo who run compilation
1616
*/
1717
public abstract class ScalaCompilerSupport extends ScalaSourceMojoSupport {
18-
18+
1919
public static final String ALL = "all";
2020
public static final String INCREMENTAL = "incremental";
21-
21+
2222
/**
2323
* Keeps track of if we get compile errors in incremental mode
2424
*/
2525
private boolean compileErrors;
26-
26+
2727
/**
2828
* Recompile mode to use when sources were previously compiled and there is at
2929
* least one change:
@@ -34,7 +34,7 @@ public abstract class ScalaCompilerSupport extends ScalaSourceMojoSupport {
3434
*/
3535
@Parameter(property = "recompileMode", defaultValue = "all")
3636
protected String recompileMode = ALL;
37-
37+
3838
/**
3939
* notifyCompilation if true then print a message "path: compiling"
4040
* for each root directory or files that will be compiled.
@@ -44,20 +44,20 @@ public abstract class ScalaCompilerSupport extends ScalaSourceMojoSupport {
4444
*/
4545
@Parameter(property = "notifyCompilation", defaultValue = "true")
4646
private boolean notifyCompilation = true;
47-
47+
4848
abstract protected File getOutputDir() throws Exception;
49-
49+
5050
abstract protected List<String> getClasspathElements() throws Exception;
51-
51+
5252
private long _lastCompileAt = -1;
53-
53+
5454
private SbtIncrementalCompiler incremental;
55-
55+
5656
/**
5757
* Analysis cache file for incremental recompilation.
5858
*/
5959
abstract protected File getAnalysisCacheFile() throws Exception;
60-
60+
6161
/**
6262
* Compile order for Scala and Java sources for sbt incremental compile.
6363
*
@@ -66,7 +66,7 @@ public abstract class ScalaCompilerSupport extends ScalaSourceMojoSupport {
6666
*/
6767
@Parameter(property = "compileOrder", defaultValue = "Mixed")
6868
private CompileOrder compileOrder;
69-
69+
7070
@Override
7171
protected void doExecute() throws Exception {
7272
if (getLog().isDebugEnabled()) {
@@ -88,7 +88,7 @@ protected void doExecute() throws Exception {
8888
break;
8989
}
9090
}
91-
91+
9292
protected int compile(List<File> sourceRootDirs, File outputDir, File analysisCacheFile, List<String> classpathElements, boolean compileInLoop) throws Exception, InterruptedException {
9393
if (!compileInLoop && INCREMENTAL.equals(recompileMode)) {
9494
// TODO - Do we really need this duplicated here?
@@ -98,27 +98,27 @@ protected int compile(List<File> sourceRootDirs, File outputDir, File analysisCa
9898
// if not compileInLoop, invoke incrementalCompile immediately
9999
return incrementalCompile(classpathElements, sourceRootDirs, outputDir, analysisCacheFile, compileInLoop);
100100
}
101-
101+
102102
long t0 = System.currentTimeMillis();
103103
LastCompilationInfo lastCompilationInfo = LastCompilationInfo.find(sourceRootDirs, outputDir);
104104
if (_lastCompileAt < 0) {
105105
_lastCompileAt = lastCompilationInfo.getLastSuccessfullTS();
106106
}
107-
107+
108108
List<File> files = getFilesToCompile(sourceRootDirs, _lastCompileAt);
109-
109+
110110
if (files == null) {
111111
return -1;
112112
}
113-
113+
114114
if (files.size() < 1) {
115115
return 0;
116116
}
117117
if (!outputDir.exists()) {
118118
outputDir.mkdirs();
119119
}
120120
long t1 = System.currentTimeMillis();
121-
121+
122122
if (compileInLoop && INCREMENTAL.equals(recompileMode)) {
123123
// if compileInLoop, do not invoke incrementalCompile when there's no change
124124
int retCode = incrementalCompile(classpathElements, sourceRootDirs, outputDir, analysisCacheFile, compileInLoop);
@@ -128,7 +128,7 @@ protected int compile(List<File> sourceRootDirs, File outputDir, File analysisCa
128128
}
129129
return retCode;
130130
}
131-
131+
132132
getLog().info(String.format("Compiling %d source files to %s at %d", files.size(), outputDir.getAbsolutePath(), t1));
133133
JavaMainCaller jcmd = getScalaCommand();
134134
jcmd.redirectToLog();
@@ -149,24 +149,24 @@ protected int compile(List<File> sourceRootDirs, File outputDir, File analysisCa
149149
_lastCompileAt = t1;
150150
return files.size();
151151
}
152-
152+
153153
/**
154154
* Returns true if the previous compile failed
155155
*/
156156
protected boolean hasCompileErrors() {
157157
return compileErrors;
158158
}
159-
159+
160160
protected void clearCompileErrors() {
161161
compileErrors = false;
162162
}
163-
163+
164164
protected List<File> getFilesToCompile(List<File> sourceRootDirs, long lastSuccessfullCompileTime) throws Exception {
165165
List<File> sourceFiles = findSourceWithFilters(sourceRootDirs);
166166
if (sourceFiles.size() == 0) {
167167
return null;
168168
}
169-
169+
170170
// filter uptodate
171171
// filter is not applied to .java, because scalac failed to used existing .class for unmodified .java
172172
// failed with "error while loading Xxx, class file '.../target/classes/.../Xxxx.class' is broken"
@@ -199,15 +199,15 @@ protected List<File> getFilesToCompile(List<File> sourceRootDirs, long lastSucce
199199
}
200200
return files;
201201
}
202-
202+
203203
private void notifyCompilation(List<File> files) throws Exception {
204204
if (notifyCompilation) {
205205
for (File f : files) {
206206
getLog().info(String.format("%s:-1: info: compiling", FileUtils.pathOf(f, useCanonicalPath)));
207207
}
208208
}
209209
}
210-
210+
211211
private static class LastCompilationInfo {
212212
static LastCompilationInfo find(List<File> sourceRootDirs, File outputDir) throws Exception {
213213
StringBuilder hash = new StringBuilder();
@@ -216,42 +216,42 @@ static LastCompilationInfo find(List<File> sourceRootDirs, File outputDir) throw
216216
}
217217
return new LastCompilationInfo(new File(outputDir.getAbsolutePath() + "." + hash.toString().hashCode() + ".timestamp"), outputDir);
218218
}
219-
219+
220220
private final File _lastCompileAtFile;
221221
private final File _outputDir;
222-
222+
223223
private LastCompilationInfo(File f, File outputDir) {
224224
_lastCompileAtFile = f;
225225
_outputDir = outputDir;
226226
}
227-
227+
228228
long getLastSuccessfullTS() throws Exception {
229229
long back = -1;
230230
if (_lastCompileAtFile.exists() && _outputDir.exists() && (_outputDir.list().length > 0)) {
231231
back = _lastCompileAtFile.lastModified();
232232
}
233233
return back;
234234
}
235-
235+
236236
void setLastSuccessfullTS(long v) throws Exception {
237237
if (!_lastCompileAtFile.exists()) {
238238
FileUtils.fileWrite(_lastCompileAtFile.getAbsolutePath(), ".");
239239
}
240240
_lastCompileAtFile.setLastModified(v);
241241
}
242242
}
243-
243+
244244
//
245245
// Incremental compilation
246246
//
247-
247+
248248
@SuppressWarnings("unchecked")
249249
protected int incrementalCompile(List<String> classpathElements, List<File> sourceRootDirs, File outputDir, File cacheFile, boolean compileInLoop) throws Exception {
250250
List<File> sources = findSourceWithFilters(sourceRootDirs);
251251
if (sources.isEmpty()) {
252252
return -1;
253253
}
254-
254+
255255
if (incremental == null) {
256256
File libraryJar = getLibraryJar();
257257
File reflectJar = getReflectJar();
@@ -261,11 +261,11 @@ protected int incrementalCompile(List<String> classpathElements, List<File> sour
261261
File compilerBridgeJar = getCompilerBridgeJar();
262262
incremental = new SbtIncrementalCompiler(libraryJar, reflectJar, compilerJar, findScalaVersion(), extraJars, compilerBridgeJar, getLog(), cacheFile, compileOrder);
263263
}
264-
264+
265265
classpathElements.remove(outputDir.getAbsolutePath());
266266
List<String> scalacOptions = getScalaOptions();
267267
List<String> javacOptions = getJavacOptions();
268-
268+
269269
try {
270270
incremental.compile(classpathElements, sources, outputDir, scalacOptions, javacOptions);
271271
} catch (xsbti.CompileFailed e) {
@@ -275,7 +275,7 @@ protected int incrementalCompile(List<String> classpathElements, List<File> sour
275275
throw e;
276276
}
277277
}
278-
278+
279279
return 1;
280280
}
281281
}

0 commit comments

Comments
 (0)