public static void main ( String [ ] args ) { String outputDir = "out" ; //default output directory String defxml = null ; int arg = 0 ; if ( args . length > 0 ) { while ( args . length > arg + 1 ) { if ( args [ arg ] . startsWith ( "-" ) ) { if ( args [ arg ] . equals ( "-o" ) ) { arg ++ ; if ( arg >= args . length ) { usage ( ) ; System . exit ( OTHER ) ; } outputDir = args [ arg ] ; } else if ( args [ arg ] . equals ( "-f" ) ) { arg ++ ; if ( arg >= args . length ) { usage ( ) ; System . exit ( OTHER ) ; } defxml = args [ arg ] ; } } else { usage ( ) ; System . exit ( OTHER ) ; } arg ++ ; } } try { File out = new File ( outputDir ) ; Utils . recursiveDelete ( out ) ; Definition def ; if ( defxml == null ) def = inputFromCommandLine ( ) ; else def = inputFromXml ( defxml ) ; if ( def == null ) System . exit ( ERROR ) ; def . setOutputDir ( outputDir ) ; Profile profile ; switch ( def . getVersion ( ) ) { case "1.7" : profile = new JCA17Profile ( ) ; break ; case "1.6" : profile = new JCA16Profile ( ) ; break ; case "1.5" : profile = new JCA15Profile ( ) ; break ; default : profile = new JCA10Profile ( ) ; break ; } profile . generate ( def ) ; if ( def . getBuild ( ) . equals ( "ant" ) ) copyAllJars ( outputDir ) ; System . out . println ( rb . getString ( "code.wrote" ) ) ; System . exit ( SUCCESS ) ; } catch ( IOException | JAXBException e ) { e . printStackTrace ( ) ; } }
Code generator stand alone tool