1414package com.apm.client.commands.project
1515{
1616 import airsdk.AIRSDKVersion ;
17-
17+
1818 import com.apm.client.APM ;
1919 import com.apm.client.commands.Command ;
2020 import com.apm.client.commands.project.processes.AndroidManifestMergeProcess ;
@@ -28,45 +28,44 @@ package com.apm.client.commands.project
2828 import com.apm.client.processes.ProcessQueue ;
2929 import com.apm.data.project.ApplicationDescriptor ;
3030 import com.apm.data.project.ProjectDefinition ;
31-
31+
3232 import flash.events.EventDispatcher ;
3333 import flash.filesystem.File ;
34-
35-
34+
3635 public class GenerateAppDescriptorCommand extends EventDispatcher implements Command
3736 {
3837 ////////////////////////////////////////////////////////
3938 // CONSTANTS
4039 //
41-
40+
4241 private static const TAG : String = "GenerateAppDescriptorCommand" ;
43-
44-
42+
43+
4544 public static const NAME : String = "generate/app-descriptor" ;
46-
47-
45+
46+
4847 ////////////////////////////////////////////////////////
4948 // VARIABLES
5049 //
51-
50+
5251 private var _parameters : Array ;
5352 private var _options : Array ;
5453 private var _queue : ProcessQueue;
55-
56-
54+
55+
5756 ////////////////////////////////////////////////////////
5857 // FUNCTIONALITY
5958 //
60-
59+
6160 public function GenerateAppDescriptorCommand ()
6261 {
6362 super ();
6463 _parameters = [];
6564 _options = [];
6665 _queue = new ProcessQueue();
6766 }
68-
69-
67+
68+
7069 public function setParameters ( parameters :Array ):void
7170 {
7271 if (parameters != null )
@@ -86,26 +85,26 @@ package com.apm.client.commands.project
8685 }
8786 }
8887 }
89-
90-
88+
89+
9190 public function get name ():String
9291 {
9392 return NAME ;
9493 }
95-
96-
94+
95+
9796 public function get category ():String
9897 {
9998 return "" ;
10099 }
101-
102-
100+
101+
103102 public function get description ():String
104103 {
105104 return "generate an application descriptor with all package required additions" ;
106105 }
107-
108-
106+
107+
109108 public function get usage ():String
110109 {
111110 return description + "\n " +
@@ -114,34 +113,48 @@ package com.apm.client.commands.project
114113 "apm generate app-descriptor [out.xml] generates an application descriptor updating the specified out.xml file\n " +
115114 "\n " +
116115 "options: \n " +
117- " --exclude-android excludes generation of the android manifest additions\n " +
118- " --exclude-ios excludes generation of the iOS info additions and entitlements\n "
116+ " --exclude-android \n " +
117+ " --ios excludes generation of the android manifest additions\n " +
118+ " --exclude-ios \n " +
119+ " --android excludes generation of the iOS info additions and entitlements\n " +
120+ " --strip-comments strip comments from the generated application descriptor\n "
119121 ;
120122 }
121-
122-
123+
124+
123125 public function get requiresNetwork ():Boolean
124126 {
125127 return false ;
126128 }
127-
128-
129+
130+
129131 public function get requiresProject ():Boolean
130132 {
131133 return true ;
132134 }
133-
134-
135+
136+
135137 public function execute ():void
136138 {
137139 Log . d ( TAG , "execute(): " + (_parameters . length > 0 ? _parameters . join ( "," ) : "..." ) + "\n " );
138-
140+
139141 var excludeAndroid: Boolean = false ;
140142 var excludeIOS: Boolean = false ;
143+ var stripComments: Boolean = false ;
141144 for each (var option: String in _options )
142145 {
143146 switch (option)
144147 {
148+ case "--ios" :
149+ {
150+ excludeAndroid = true ;
151+ break ;
152+ }
153+ case "--android" :
154+ {
155+ excludeIOS = true ;
156+ break ;
157+ }
145158 case "--exclude-android" :
146159 {
147160 excludeAndroid = true ;
@@ -152,9 +165,14 @@ package com.apm.client.commands.project
152165 excludeIOS = true ;
153166 break ;
154167 }
168+ case "--strip-comments" :
169+ {
170+ stripComments = true ;
171+ break ;
172+ }
155173 }
156174 }
157-
175+
158176 // Get AIR SDK version for app descriptor
159177 var airSDKVersion: AIRSDKVersion = null ;
160178 if (APM . config. airDirectory != null )
@@ -171,17 +189,17 @@ package com.apm.client.commands.project
171189 Log . d ( TAG , "AIR DIR doesn't exist: " + APM . config. airDirectory );
172190 }
173191 }
174-
192+
175193 Log . d ( TAG , "AIR SDK Version: " + (airSDKVersion == null ? "null" : airSDKVersion. toString ()) );
176-
177- var appDescriptor: ApplicationDescriptor = new ApplicationDescriptor( airSDKVersion );
178-
194+
195+ var appDescriptor: ApplicationDescriptor = new ApplicationDescriptor( airSDKVersion, stripComments );
196+
179197 var outputPath: String = defaultOutputPath();
180198 if (_parameters . length > 0 )
181199 {
182- outputPath = _parameters [ 0 ];
200+ outputPath = _parameters [ 0 ];
183201 }
184-
202+
185203 _queue . addProcess( new ValidateProjectParametersProcess() );
186204 _queue . addProcess( new ValidatePackageCacheProcess() );
187205 if (! excludeAndroid)
@@ -194,7 +212,7 @@ package com.apm.client.commands.project
194212 _queue . addProcess( new IOSEntitlementsMergeProcess( appDescriptor ) );
195213 }
196214 _queue . addProcess( new ApplicationDescriptorGenerationProcess( appDescriptor, outputPath ) );
197-
215+
198216 _queue . start (
199217 function (): void
200218 {
@@ -206,27 +224,30 @@ package com.apm.client.commands.project
206224 dispatchEvent ( new CommandEvent( CommandEvent. COMPLETE , APM . CODE_ERROR ) );
207225 } );
208226 }
209-
210-
227+
228+
211229 public function defaultOutputPath ():String
212230 {
213231 var proj: ProjectDefinition = APM . config. projectDefinition;
214- if (proj. applicationFilename != null )
232+ var buildType: String = APM . config. buildType;
233+ var filename: String = proj. getApplicationFilename( buildType );
234+ var appName: Object = proj. getApplicationName( buildType );
235+ if (filename != null )
215236 {
216- return "src/" + proj . applicationFilename + "-app.xml" ;
237+ return "src/" + filename + "-app.xml" ;
217238 }
218- else if (proj . applicationName is String )
239+ else if (appName is String )
219240 {
220- return "src/" + proj . applicationName . replace ( / / g , "" ) + "-app.xml" ;
241+ return "src/" + appName . replace ( / / g , "" ) + "-app.xml" ;
221242 }
222- else if (proj . applicationName . hasOwnProperty ("en" ))
243+ else if (appName . hasOwnProperty ( "en" ))
223244 {
224- return "src/" + proj . applicationName [ "en" ] . replace ( / / g , "" ) + "-app.xml" ;
245+ return "src/" + appName [ "en" ] . replace ( / / g , "" ) + "-app.xml" ;
225246 }
226247 return "src/MyApplication-app.xml" ;
227248 }
228-
229-
249+
250+
230251 }
231-
252+
232253}
0 commit comments