1 package org.codehaus.mojo.webstart.generator;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.logging.Log;
23 import org.codehaus.mojo.webstart.ResolvedJarResource;
24 import org.codehaus.plexus.util.StringUtils;
25
26 import java.util.Collection;
27
28
29
30
31
32
33
34
35 public class JarResourcesGenerator
36 extends AbstractGenerator<JarResourceGeneratorConfig>
37 {
38
39 public JarResourcesGenerator( Log log, GeneratorTechnicalConfig technicalConfig,
40 JarResourceGeneratorConfig extraConfig )
41 {
42 super( log, technicalConfig, extraConfig );
43 }
44
45 protected String getArgumentsText()
46 {
47 StringBuilder buffer = new StringBuilder();
48
49 if (getExtraConfig().getArguments() != null)
50 {
51 for (String argument : getExtraConfig().getArguments())
52 {
53 buffer.append("<argument>").append(argument).append("</argument>").append(EOL);
54 }
55 }
56
57 return buffer.toString();
58 }
59
60
61
62
63 protected String getDependenciesText()
64 {
65
66 String jarResourcesText = "";
67
68 String libPath = getExtraConfig().getLibPath();
69 Collection<ResolvedJarResource> jarResources = getExtraConfig().getJarResources();
70
71 if ( jarResources.size() != 0 )
72 {
73 final int multiplier = 100;
74 StringBuilder buffer = new StringBuilder( multiplier * jarResources.size() );
75 buffer.append( EOL );
76
77 for ( ResolvedJarResource jarResource : jarResources )
78 {
79
80 if ( !jarResource.isIncludeInJnlp() )
81 {
82 continue;
83 }
84
85 buffer.append( "<jar href=\"" );
86 if ( StringUtils.isNotEmpty( libPath ) )
87 {
88 buffer.append( libPath );
89 buffer.append( '/' );
90 }
91 buffer.append( jarResource.getHrefValue() );
92 buffer.append( "\"" );
93
94 if ( jarResource.isOutputJarVersion() )
95 {
96 buffer.append( " version=\"" ).append( jarResource.getVersion() ).append( "\"" );
97 }
98
99 if ( jarResource.getMainClass() != null )
100 {
101 buffer.append( " main=\"true\"" );
102 }
103
104 buffer.append( "/>" ).append( EOL );
105 }
106 jarResourcesText = buffer.toString();
107 }
108 return jarResourcesText;
109 }
110
111 }