Skip to content

Commit 34f5f82

Browse files
authored
Consolidate java-templates folder into rest of module (#174)
* - Consolidate java-templates folder into rest of module - Mark immutable variables as final - Remove unused `apiVersion` global variable * - Undo move, template file needed to generate VERSION variable dynamically from pom.xml * - Clarify how Maven template variable work
1 parent 388cbd1 commit 34f5f82

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/main/java-templates/com/easypost/EasyPost.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,37 @@
22

33
import com.easypost.easyvcr.VCR;
44

5+
/**
6+
* Hello weary traveler, welcome to the EasyPost Java client library.
7+
* <p>
8+
* This file exists as a template for the Templating Maven Plugin (https://www.mojohaus.org/templating-maven-plugin/)
9+
* If you notice the VERSION = ${project.version} below, that's an example of a template variable.
10+
* <p>
11+
* In Maven (and Gradle), you can set variables inside the pom.xml file
12+
* (https://maven.apache.org/guides/introduction/introduction-to-the-pom.html#available-variables)
13+
* <p>
14+
* The Templating Maven Plugin, at compile time, will extract these variables and add them into the source code.
15+
* <p>
16+
* Specifically here, VERSION = ${project.version} will be replaced with, i.e. VERSION = 1.0.0 when compiling the code.
17+
* <p>
18+
* The placement of this file is important.
19+
* The Templating Maven Plugin will look for any template files in this specific `java-templates` directory.
20+
* As a result, you can not remove this file.
21+
* (https://www.hascode.com/2013/09/filtering-source-files-using-the-templating-maven-plugin/)
22+
* <p>
23+
* Most of the other variables in this file are not template variables.
24+
* Instead, we simply use this file as a catch-all for all global variables.
25+
* <p>
26+
* If you ever run across a section of code where your IDE says it cannot find, i.e. `EasyPost.apiKey`,
27+
* it's likely because this file has not been compiled yet.
28+
* Simply run `mvn install` (or `make build-dev`) to compile this code and your IDE will be able to find the variable.
29+
*/
30+
531
public abstract class EasyPost {
632
public static final String VERSION = "${project.version}";
7-
public static String API_BASE = "https://api.easypost.com/v2";
8-
public static String BETA_API_BASE = "https://api.easypost.com/beta";
33+
public static final String API_BASE = "https://api.easypost.com/v2";
34+
public static final String BETA_API_BASE = "https://api.easypost.com/beta";
935
public static String apiKey;
10-
public static String apiVersion;
1136
public static int readTimeout;
1237

1338
/**

0 commit comments

Comments
 (0)