forked from highsource/jaxb-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[highsource#438] get version of XJC at runtime and dump it on source …
…generation
- Loading branch information
1 parent
6c8e84a
commit 7085316
Showing
5 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/XJCVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.jvnet.jaxb.maven; | ||
|
||
public class XJCVersion { | ||
public static final XJCVersion UNDEFINED = new XJCVersion(null); | ||
private String raw = "UNDEFINED"; | ||
private int major; | ||
private int minor; | ||
private int bugfix; | ||
|
||
public XJCVersion(String version) { | ||
if (version != null) { | ||
this.raw = version; | ||
int indexOfSnapshot = version.indexOf("-SNAPSHOT"); | ||
if (indexOfSnapshot >= 0) { | ||
version = version.substring(0, indexOfSnapshot); | ||
} | ||
String[] split = version.split("\\."); | ||
if (split.length >= 3) { | ||
major = Integer.valueOf(split[0]); | ||
minor = Integer.valueOf(split[1]); | ||
bugfix = Integer.valueOf(split[2]); | ||
} | ||
} | ||
} | ||
|
||
public String getRaw() { | ||
return raw; | ||
} | ||
|
||
public int getMajor() { | ||
return major; | ||
} | ||
|
||
public int getMinor() { | ||
return minor; | ||
} | ||
|
||
public int getBugfix() { | ||
return bugfix; | ||
} | ||
|
||
public boolean isKnown() { | ||
return !(this.major == 0 && this.minor == 0 && this.bugfix == 0); | ||
} | ||
|
||
public boolean gte(int major, int minor, int bugfix) { | ||
return this.major > major || (this.major == major && this.minor > minor) || (this.major == major && this.minor == minor && this.bugfix >= bugfix); | ||
} | ||
|
||
public boolean gt(int major, int minor, int bugfix) { | ||
return this.major > major || (this.major == major && this.minor > minor) || (this.major == major && this.minor == minor && this.bugfix > bugfix); | ||
} | ||
|
||
public boolean lte(int major, int minor, int bugfix) { | ||
return this.major < major || (this.major == major && this.minor < minor) || (this.major == major && this.minor == minor && this.bugfix <= bugfix); | ||
} | ||
|
||
public boolean lt(int major, int minor, int bugfix) { | ||
return this.major < major || (this.major == major && this.minor < minor) || (this.major == major && this.minor == minor && this.bugfix < bugfix); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters