The test class is compiled with all 3 annotation libraries but when running the test class we only supply the problem library on the classpath.
./run.sh
problem: about:blank{200, test problem}
#!/usr/bin/env bash | |
# construct runtime classpath | |
RUNTIME_CLASSPATH=.:${RUNTIME_CLASSPATH}:~/.m2/repository/org/zalando/problem/0.21.0/problem-0.21.0.jar | |
# construct compile classpath | |
COMPILE_CLASSPATH=${RUNTIME_CLASSPATH} | |
COMPILE_CLASSPATH=${COMPILE_CLASSPATH}:~/.m2/repository/com/google/gag/gag/1.0.1/gag-1.0.1.jar | |
COMPILE_CLASSPATH=${COMPILE_CLASSPATH}:~/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar | |
COMPILE_CLASSPATH=${COMPILE_CLASSPATH}:~/.m2/repository/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar | |
export CLASSPATH=${COMPILE_CLASSPATH} | |
rm -f Test.class | |
javac Test.java | |
export CLASSPATH=${RUNTIME_CLASSPATH} | |
java Test |
import org.zalando.problem.Problem; | |
import static org.zalando.problem.Status.OK; | |
public class Test { | |
public static void main(String[] args) { | |
Problem p = Problem.builder() | |
.withDetail("test problem") | |
.withStatus(OK) | |
.build(); | |
System.out.println("problem: " + p.toString()); | |
} | |
} |