Skip to content

Commit 4eea713

Browse files
committed
Sync doc version with pom.xml
1 parent d1f67e1 commit 4eea713

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

docs/src/main/java/io/jooby/adoc/DependencyProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private String groupId(String artifactId) {
7070

7171
private String version(String artifactId) {
7272
if (artifactId.startsWith("jooby-")) {
73-
return DocGenerator.VERSION;
73+
return pom.selectFirst("version").text().trim();
7474
}
7575
String version = findArtifact(artifactId)
7676
.select("version").text().trim();

docs/src/main/java/io/jooby/adoc/DocGenerator.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
import java.util.stream.Stream;
3838

3939
public class DocGenerator {
40-
public static final String VERSION = "2.0.0.M1";
41-
4240
public static void main(String[] args) throws Exception {
4341
generate(basedir(), args.length > 0 && "publish".equals(args[0]));
4442
}
@@ -49,7 +47,7 @@ public static void generate(Path basedir, boolean publish) throws Exception {
4947

5048
Attributes attributes = new Attributes();
5149

52-
attributes.setAttribute("joobyVersion", VERSION);
50+
attributes.setAttribute("joobyVersion", version());
5351
attributes.setAttribute("love", "♡");
5452

5553
attributes.setAttribute("docinfo", "shared");
@@ -220,6 +218,17 @@ public static Path basedir() {
220218
return basedir;
221219
}
222220

221+
public static String version() {
222+
try {
223+
return Jsoup.parse(basedir().getParent().resolve("pom.xml").toFile(), "utf-8")
224+
.selectFirst("version")
225+
.text()
226+
.trim();
227+
} catch (IOException x) {
228+
throw new IllegalStateException(x);
229+
}
230+
}
231+
223232
private static void copyFile(Path out, Path... dirs) throws IOException {
224233
for (Path dir : dirs) {
225234
FileUtils.copyDirectory(dir.toFile(), out.resolve(dir.getFileName().toString()).toFile());

docs/src/main/java/io/jooby/adoc/JavadocProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public JavadocProcessor(String name) {
3939
public Object process(ContentNode parent, String clazz, Map<String, Object> attributes) {
4040
StringBuilder link = new StringBuilder("https://static.javadoc.io/io.jooby/jooby/");
4141
StringBuilder text = new StringBuilder();
42-
link.append(DocGenerator.VERSION);
42+
link.append(DocGenerator.version());
4343
String[] names = clazz.split("\\.");
4444
List<String> pkg = new ArrayList<>();
4545
List<String> nameList = new ArrayList<>();

0 commit comments

Comments
 (0)