@@ -284,8 +284,16 @@ protected void executeBuildMainSources() throws ExitStatusException {
284284 protected void executeBuildSources (Collection <String > classpath , Collection <File > sources , File destination ,
285285 File friendPaths )
286286 throws ExitStatusException {
287- if (sources .isEmpty () || destination == null ) {
287+ if (sources .isEmpty ()) {
288+ if (!silent () && LOGGER .isLoggable (Level .WARNING )) {
289+ LOGGER .warning ("Nothing to compile." );
290+ }
288291 return ;
292+ } else if (destination == null ) {
293+ if (!silent () && LOGGER .isLoggable (Level .SEVERE )) {
294+ LOGGER .severe ("No destination specified." );
295+ }
296+ throw new ExitStatusException (ExitStatusException .EXIT_FAILURE );
289297 }
290298
291299 var args = new ArrayList <String >();
@@ -294,8 +302,10 @@ protected void executeBuildSources(Collection<String> classpath, Collection<File
294302 args .add (kotlinCompiler ());
295303
296304 // classpath
297- args .add ("-cp" );
298- args .add (FileUtils .joinPaths (classpath .stream ().toList ()));
305+ if (classpath != null && !classpath .isEmpty ()) {
306+ args .add ("-cp" );
307+ args .add (FileUtils .joinPaths (classpath .stream ().toList ()));
308+ }
299309
300310 // destination
301311 args .add ("-d" );
@@ -376,16 +386,16 @@ protected void executeCreateBuildDirectories() throws IOException {
376386 * <p>
377387 * Sets the following from the project:
378388 * <ul>
379- * <li>{@link #kotlinHome()} to the {@code KOTLIN_HOME} environment variable, if set.</li>
380- * <li>{@link #workDir()} to the project's directory.</li>
389+ * <li>{@link #kotlinHome() kotlinHome } to the {@code KOTLIN_HOME} environment variable, if set.</li>
390+ * <li>{@link #workDir() workDir } to the project's directory.</li>
381391 * <li>{@link #buildMainDirectory() buildMainDirectory}</li>
382392 * <li>{@link #buildTestDirectory() buildTestDirectory}</li>
383393 * <li>{@link #compileMainClasspath() compileMainClassPath}</li>
384394 * <li>{@link #compileTestClasspath() compilesTestClassPath}</li>
385- * <li>{@link #mainSourceDirectories()} () mainSourceDirectories} to the {@code kotlin} directory in
386- * {@link BaseProject#srcMainDirectory() srcMainDirectory}</li>
395+ * <li>{@link #mainSourceDirectories() mainSourceDirectories} to the {@code kotlin} directory in
396+ * {@link BaseProject#srcMainDirectory() srcMainDirectory}, if present. </li>
387397 * <li>{@link #testSourceDirectories() testSourceDirectories} to the {@code kotlin} directory in
388- * {@link BaseProject#srcTestDirectory() srcTestDirectory}</li>
398+ * {@link BaseProject#srcTestDirectory() srcTestDirectory}, if present. </li>
389399 * <li>{@link CompileOptions#jdkRelease jdkRelease} to {@link BaseProject#javaRelease() javaRelease}</li>
390400 * <li>{@link CompileOptions#noStdLib(boolean) noStdLib} to {@code true}</li>
391401 * </ul>
@@ -406,9 +416,17 @@ public CompileKotlinOperation fromProject(BaseProject project) {
406416 var op = buildMainDirectory (project .buildMainDirectory ())
407417 .buildTestDirectory (project .buildTestDirectory ())
408418 .compileMainClasspath (project .compileMainClasspath ())
409- .compileTestClasspath (project .compileTestClasspath ())
410- .mainSourceDirectories (new File (project .srcMainDirectory (), "kotlin" ))
411- .testSourceDirectories (new File (project .srcTestDirectory (), "kotlin" ));
419+ .compileTestClasspath (project .compileTestClasspath ());
420+
421+ var mainDir = new File (project .srcMainDirectory (), "kotlin" );
422+ if (mainDir .exists ()) {
423+ op = op .mainSourceDirectories (mainDir );
424+ }
425+ var testDir = new File (project .srcTestDirectory (), "kotlin" );
426+ if (testDir .exists ()) {
427+ op = op .testSourceDirectories (testDir );
428+ }
429+
412430 if (project .javaRelease () != null && !compileOptions_ .hasRelease ()) {
413431 compileOptions_ .jdkRelease (project .javaRelease ());
414432 }
0 commit comments