1 package org.apache.maven.plugins.artifact.buildinfo;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import org.codehaus.plexus.util.FileUtils;
26
27
28
29
30
31 public class NotReproduciblePluginsDocumentationTest
32 {
33 private static final String LS = System.lineSeparator();
34 private static final String DELIMITER = "~~ content generated by NotReproduciblePluginsDocumentationTest";
35
36 public void testBasic() throws IOException
37 {
38 File pluginIssuesApt = new File( "src/site/apt/plugin-issues.apt" );
39 String content = FileUtils.fileRead( pluginIssuesApt, "UTF-8" );
40 content = content.substring( 0, content.indexOf( DELIMITER ) + DELIMITER.length() );
41
42 StringBuilder sb = new StringBuilder( content );
43 sb.append( LS );
44 sb.append( "*---------+-------------------------------------------------------------------+-------+--------------+" + LS );
45 sb.append( "| | <<plugin>> | <<minimum version>> | <<comments>>" );
46 String groupId = null;
47 for ( String line : FileUtils.loadFile( new File( "src/main/resources/org/apache/maven/plugins/artifact/buildinfo/not-reproducible-plugins.properties" ) ) )
48 {
49 if ( !line.startsWith( "#" ) )
50 {
51 sb.append( LS + "*--------+--------------------------------------------------------------------+-------+--------------+" + LS );
52 int index = line.indexOf( '=' );
53 String plugin = line.substring( 0, index );
54 String status = line.substring( index + 1 );
55
56 index = plugin.indexOf( '+' );
57 if ( index < 0 )
58 {
59 groupId = "org.apache.maven.plugins";
60 sb.append( "| org.apache.maven.plugins | {{{/plugins/" + plugin + "/}" + plugin + "}} " );
61 }
62 else
63 {
64 groupId = plugin.substring( 0, index );
65 plugin = plugin.substring( index + 1 );
66 sb.append( "| " + groupId + " | " + plugin + " " );
67 }
68 if ( status.startsWith( "fail:" ) )
69 {
70 sb.append( "| - | no fixed release available, see {{{" + status.substring( 5 ) + "}reference}}" );
71 }
72 else
73 {
74 sb.append( "| " + status + " | ");
75 }
76 continue;
77 }
78 if ( groupId == null )
79 {
80 continue;
81 }
82 sb.append( line.substring( 1 ) );
83 }
84 sb.append( LS + "*----------+------------------------------------------------------------------+-------+--------------+" + LS );
85
86 FileUtils.fileWrite( pluginIssuesApt, "UTF-8", sb.toString() );
87 }
88 }