Minor cleanups

This commit is contained in:
Erik C. Thauvin 2025-03-24 21:29:54 -07:00
parent bf82ea1920
commit 8e2415eda4
Signed by: erik
GPG key ID: 776702A6A2DA330E
3 changed files with 34 additions and 18 deletions

View file

@ -508,18 +508,20 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
jvmOptions_.forEach(s -> command.add("-J" + s));
}
// compiler options
if (compileOptions_ != null) {
args.addAll(compileOptions_.args());
// classpath
if (compileOptions_ != null && !compileOptions_.classpath().isEmpty()) {
cp.addAll(compileOptions_.classpath().stream().map(this::cleanPath).toList());
}
// classpath
if (!cp.isEmpty()) {
args.add("-cp");
args.add('"' + FileUtils.joinPaths(cp.stream().map(this::cleanPath).toList()) + '"');
}
// compile options
if (compileOptions_ != null && !compileOptions_.args().isEmpty()) {
args.addAll(compileOptions_.args());
}
// destination
args.add("-d");
args.add('"' + cleanPath(destination) + '"');

View file

@ -185,17 +185,23 @@ class CompileOptionsTest {
var bar = new File("bar.txt");
var options = new CompileOptions();
options = options.argFile(foo);
assertThat(options.argFile()).contains(foo);
options.argFile().clear();
assertThat(options.argFile()).isEmpty();
options.argFile(foo, bar);
assertThat(options.argFile()).contains(foo, bar);
options.argFile().clear();
assertThat(options.argFile()).isEmpty();
options = options.argFile(foo.toPath(), bar.toPath());
assertThat(options.argFile()).contains(foo, bar);
options.argFile().clear();
assertThat(options.argFile()).isEmpty();
options.argFile(foo.getAbsolutePath(), bar.getAbsolutePath());
options = options.argFile(foo.getAbsolutePath(), bar.getAbsolutePath());
assertThat(options.argFile()).contains(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
options.argFile().clear();
}
@Test
@ -254,31 +260,45 @@ class CompileOptionsTest {
var bar = new File("bar.txt");
var options = new CompileOptions();
options = options.classpath(foo);
assertThat(options.classpath()).as("File").containsExactly(foo);
options.classpath().clear();
assertThat(options.argFile()).isEmpty();
options.classpath(foo, bar);
assertThat(options.classpath()).as("File...").containsExactly(foo, bar);
options.classpath().clear();
assertThat(options.argFile()).isEmpty();
options.classpath(List.of(foo, bar));
assertThat(options.classpath()).as("List(File...)").containsExactly(foo, bar);
options.classpath().clear();
assertThat(options.argFile()).isEmpty();
options = options.classpath(foo.toPath(), bar.toPath());
assertThat(options.classpath()).as("Path...").containsExactly(foo, bar);
options.classpath().clear();
assertThat(options.argFile()).isEmpty();
options = options.classpathPaths(List.of(foo.toPath(), bar.toPath()));
assertThat(options.classpath()).as("List(Path...)").containsExactly(foo, bar);
options.classpath().clear();
assertThat(options.argFile()).isEmpty();
options.classpath(foo.getAbsolutePath(), bar.getAbsolutePath());
assertThat(options.classpath()).as("String...")
.containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
options.classpath().clear();
assertThat(options.argFile()).isEmpty();
options.classpathStrings(List.of(foo.getAbsolutePath(), bar.getAbsolutePath()));
assertThat(options.classpath()).as("List(String...)")
.containsExactly(new File(foo.getAbsolutePath()), new File(bar.getAbsolutePath()));
options.classpath().clear();
}
@Test