forked from mojohaus/versions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.bsh
88 lines (77 loc) · 2.54 KB
/
verify.bsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import java.io.*;
import org.codehaus.plexus.util.FileUtils;
import java.util.regex.*;
try
{
File file = new File( basedir, "pom.xml" );
BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
StringBuilder buf = new StringBuilder();
String line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}
Pattern p = Pattern.compile( "\\Q<version>\\E\\s*1\\.2\\.1-SNAPSHOT\\s*\\Q</version>\\E" );
Matcher m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not set new version in parent pom" );
return false;
}
file = new File( basedir, "module-a1/pom.xml" );
in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
buf = new StringBuilder();
line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}
p = Pattern.compile( "\\Q<parent>\\E.*\\Q<version>\\E\\s*1\\.2\\.1-SNAPSHOT\\s*\\Q</version>\\E.*\\Q</parent>\\E" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update parent version in module-a1/pom" );
return false;
}
p = Pattern.compile( "\\Q</parent>\\E.*\\Q<version>\\E\\s*2\\.0\\.7-SNAPSHOT\\s*\\Q</version>\\E" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did update child version in module-a1/pom" );
return false;
}
file = new File( basedir, "module-a2/pom.xml" );
in = new BufferedReader( new InputStreamReader( new FileInputStream( file ), "UTF-8" ) );
buf = new StringBuilder();
line = in.readLine();
while ( line != null )
{
buf.append( line );
buf.append( " " );
line = in.readLine();
}
p = Pattern.compile( "\\Q<parent>\\E.*\\Q<version>\\E\\s*1\\.2\\.1-SNAPSHOT\\s*\\Q</version>\\E.*\\Q</parent>\\E" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update parent version in module-a2/pom" );
return false;
}
p = Pattern.compile( "\\Q</parent>\\E.*\\Q<version>\\E\\s*1\\.2\\.1-SNAPSHOT\\s*\\Q</version>\\E" );
m = p.matcher( buf.toString() );
if ( !m.find() )
{
System.out.println( "Did not update child version in module-a2/pom" );
return false;
}
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}
return true;