kobalt
kobalt copied to clipboard
`compile` task does not remove obsolete files from `kobaltBuild/classes`
When removing or renaming source files, then neither javac nor kotlinc does remove obsolete .class files from the kobaltBuild/classes folder.
The same happens if removing or renaming a resource file (e.g. .png, .xml, etc). Obsolete files are not removed from kobaltBuild/classes.
This may cause strange problems when running the resulting application...
The compile task should either empty the whole kobaltBuild/classes folder or remove all .class files from kobaltBuild/classes before running javac/kotlinc. In the second case, the resource copying must remove files in kobaltBuild/classes which are not in source resources directories.
Is this what other build tools do? It seems that this would completely defeat incremental compilation.
Sure, removing all .class files becomes a problem as soon as Kobalt should support incremental compilation. But right now it does not. It always compiles all sources of a project (if a source file changed), which is fine.
So removing all .class files seems to be an easy solution to get reliable build results right now, which is important for a build tool, isn't it?
javac and kotlinc do not support incremental compilation out of the box and I think its a challenging task to implement this (especially for Kotlin).
Is this what other build tools do?
Just tried Gradle and Ant...
Gradle default (non-incremental) Java compilation compiles whole project and removes .class files if removing/renaming .java file.
Gradle incremental Java compilation (still incubating; disabled by default) uses "bytecode analysis", caches and more: https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_compile
Ant (from http://ant.apache.org/manual/Tasks/javac.html)
Only Java files that have no corresponding .class file or where the class file is older than the .java file will be compiled.
Ant does not remove obsolete .class files (which is a problem!) There is also a depend task which can remove out-of-date .class files.
Some interesting links regarding Java incremental compilation:
- http://takari.io/2014/10/16/incremental-compilation.html
- http://stackoverflow.com/questions/2590579/can-standard-sun-javac-do-incremental-compiling
- http://blog.ltgt.net/most-build-tools-misuse-javac/