Skip to content

Instantly share code, notes, and snippets.

@bertramn
Last active July 15, 2018 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertramn/e3cf2e55077664112141827e45b919e7 to your computer and use it in GitHub Desktop.
Save bertramn/e3cf2e55077664112141827e45b919e7 to your computer and use it in GitHub Desktop.
Zalando Problem dependencies exclusion test

Exclude Findbugs, API Guardian and Google GAG from Runtime

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());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment