1 package org.apache.maven.plugin.cxx;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.io.File;
22 import java.util.HashMap;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.ArrayList;
27
28 import org.codehaus.plexus.util.StringUtils;
29
30 import org.apache.maven.plugins.annotations.LifecyclePhase;
31 import org.apache.maven.plugins.annotations.Mojo;
32 import org.apache.maven.plugins.annotations.Parameter;
33
34
35
36
37
38
39 @Mojo( name = "qmake", defaultPhase = LifecyclePhase.GENERATE_SOURCES )
40 public class QMakeMojo extends AbstractLaunchMojo
41 {
42 @Override
43 protected List<String> getArgsList()
44 {
45 return null;
46 }
47
48
49
50
51
52
53 @Parameter()
54 private List<String> sourceDirs = new ArrayList<String>();
55
56
57
58
59
60
61
62
63 @Parameter()
64 private List<String> pros = new ArrayList<String>();
65
66 protected List<String> getProjectList()
67 {
68 if ( pros.size() == 0 )
69 {
70 Iterator it = sourceDirs.iterator();
71 while ( it.hasNext() )
72 {
73 pros.add( new File( (String) it.next() ).getAbsolutePath() );
74 }
75 }
76 if ( pros.size() == 0 )
77 {
78 pros.add( new String( basedir.getAbsolutePath() ) );
79 }
80 return pros;
81 }
82
83
84
85
86
87
88 @Parameter( property = "qmake.args", defaultValue = "" )
89 private String commandArgs;
90
91 @Override
92 protected String getCommandArgs()
93 {
94 String result = new String( "-makefile " );
95 if ( !StringUtils.isEmpty( commandArgs ) )
96 {
97 result += commandArgs + " ";
98 }
99 List<String> proList = getProjectList();
100 Iterator it = proList.iterator();
101 while ( it.hasNext() )
102 {
103 result += "\"" + (String) it.next() + "\" ";
104 }
105 return result;
106 }
107
108
109
110
111
112
113
114 @Parameter()
115 private Map qmakecommandPerOS = new HashMap();
116
117 @Override
118 protected String getExecutable()
119 {
120 String sOsName = System.getProperty( "os.name" );
121 sOsName = sOsName.replace( " ", "" );
122 getLog().info( "os.name is \"" + sOsName + "\"" );
123 if ( qmakecommandPerOS == null )
124 {
125 return "qmake";
126 }
127 else
128 {
129 if ( qmakecommandPerOS.containsKey( sOsName ) )
130 {
131 return (String) qmakecommandPerOS.get( sOsName );
132 }
133 else
134 {
135 return "qmake";
136 }
137 }
138 }
139
140
141
142
143
144
145 @Parameter()
146 private Map environmentVariables = new HashMap();
147
148 @Override
149 protected Map getMoreEnvironmentVariables()
150 {
151 return environmentVariables;
152 }
153
154 @Override
155 protected List<String> getSuccesCode()
156 {
157 return null;
158 }
159
160
161
162
163
164
165 @Parameter( property = "qmake.outsourcedir" )
166 private File outsourceDir;
167
168 @Override
169 protected File getWorkingDir()
170 {
171 if ( null == outsourceDir )
172 {
173 outsourceDir = new File( basedir.getPath() );
174 }
175 return outsourceDir;
176 }
177
178 @Override
179 public boolean isSkip()
180 {
181 return false;
182 }
183
184 }