@@ -40,14 +40,23 @@ class ConfigCreator {
4040 private static final String HELP = "--help" ;
4141
4242 private static final Pattern MP_VERSION_PATTERN = Pattern .compile ("\\ d+\\ .\\ d+\\ .\\ d+\\ .GA" );
43+ private static final Pattern MAJOR_VERSION_PATTERN = Pattern .compile ("[1-9]+\\ .0\\ .0\\ .GA" );
44+
45+ private static final String PATCH_STREAM_BASE_NAME = "jboss-eap-xp-" ;
46+
47+ private static final String APPLIES_TO_VERSON_MARKER = "${applies.to.version}" ;
48+ private static final String EXPANSION_PACK_VERSION_MARKER = "${expansion.pack.version}" ;
49+ private static final String EXPANSION_PACK_PATCH_STREAM_NAME_MARKER = "${xp.patch.stream.name}" ;
4350
4451 private final String appliesToVersion ;
4552 private final String xpVersionRoot ;
53+ private final String patchStreamName ;
4654 private final String outputDir ;
4755
48- private ConfigCreator (String appliesToVersion , String xpVersionRoot , String outputDir ) {
56+ private ConfigCreator (String appliesToVersion , String xpVersionRoot , String patchStreamName , String outputDir ) {
4957 this .appliesToVersion = appliesToVersion ;
5058 this .xpVersionRoot = xpVersionRoot ;
59+ this .patchStreamName = patchStreamName ;
5160 this .outputDir = outputDir ;
5261 }
5362
@@ -91,7 +100,8 @@ static Path generate(final String... args) throws Exception{
91100
92101
93102 String appliesToVersion = "0.0.0" ;
94- if (!xpVersion .equals ("1.0.0.GA" )) {
103+ if (!MAJOR_VERSION_PATTERN .matcher (xpVersion ).matches ()) {
104+ // Figure out the last version
95105 String [] parts = xpVersion .split ("\\ ." );
96106 StringBuilder xpVersionBuilder = new StringBuilder ();
97107 StringBuilder appliesToVersionBuilder = new StringBuilder ();
@@ -114,8 +124,11 @@ static Path generate(final String... args) throws Exception{
114124
115125 int i = xpVersion .indexOf (".GA" );
116126 String xpVersionRoot = xpVersion .substring (0 , i );
127+
128+ String majorVersion = xpVersion .substring (0 , xpVersion .indexOf ("." ));
129+ String patchStreamName = PATCH_STREAM_BASE_NAME + majorVersion + ".0" ;
117130
118- ConfigCreator configCreator = new ConfigCreator (appliesToVersion , xpVersionRoot , outputDir );
131+ ConfigCreator configCreator = new ConfigCreator (appliesToVersion , xpVersionRoot , patchStreamName , outputDir );
119132 return configCreator .createPatchConfigXml ();
120133 }
121134
@@ -161,8 +174,9 @@ private String readBundledPatchConfigXml() throws Exception {
161174 StringBuffer sb = new StringBuffer ();
162175 String line = reader .readLine ();
163176 while (line != null ) {
164- line = line .replace ("${applies.to.version}" , appliesToVersion );
165- line = line .replace ("${expansion.pack.version}" , xpVersionRoot );
177+ line = line .replace (APPLIES_TO_VERSON_MARKER , appliesToVersion );
178+ line = line .replace (EXPANSION_PACK_VERSION_MARKER , xpVersionRoot );
179+ line = line .replace (EXPANSION_PACK_PATCH_STREAM_NAME_MARKER , patchStreamName );
166180 sb .append (line );
167181 sb .append ("\n " );
168182 line = reader .readLine ();
@@ -179,4 +193,8 @@ private String readBundledPatchConfigXml() throws Exception {
179193 }
180194 return contents ;
181195 }
196+
197+ public static void main (String [] args ) {
198+ System .out .println (MAJOR_VERSION_PATTERN .matcher ("1.0.0.GA" ).matches ());
199+ }
182200}
0 commit comments