How to setup everything when you don't use either or
- Maven
- Gradle
- Ant
- Eclipse
- IntelliJ
.PHONY: all clean
all:
@mkdir -p bin
@javac -classpath "lib/*" -d bin `find src -name "*.java"`
clean:
rm -f `find . -name "*.class"`Of course a Gradle script would probably be much more efficient, and I could use Makefile's partial compilation features. But I just don't want to. This is the kind of project where I intend to spend zero time on complilation details. This Makefile is quite short, but I can guarantee that it will work on any unix-like machine where Java is installed.
I'm using to CLI to compile my code, so it stands to reason that I also want to run tests from the CLI. This is what ConsoleLauncher is for, and the latest standalone version should be available here.
Then it's just a matter of making sure that the latest *.jar is in the lib/ directory and
java -jar lib/junit-platform-console-standalone-1.7.2-all.jar -cp "bin:lib/*" --scan-classpathConsoleLauncher with the --scan-classpath option will find all classes that have test in their name and run them.
package test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
class SimpleTest {
@Test
@DisplayName("🏹➡️🍎")
void unicode_is_so_useful() {
assertEquals(7, 5 + 2);
}
}t:all
@java -jar lib/junit-platform-console-standalone-1.7.2-all.jar -cp "bin:lib/*" --scan-classpatht:all
@java -jar lib/junit-platform-console-standalone-1.7.2-all.jar -cp "bin:lib/*" --scan-classpath --config=junit.platform.output.capture.stdout=true --config=junit.platform.output.capture.stderr=true