@@ -22,6 +22,7 @@ component accessors=true {
2222 property name = ' classOutputDirectory' type = ' string' ;
2323 property name = ' verbose' type = ' boolean' ;
2424 property name = ' encode' type = ' string' ;
25+ property name = ' source' type = ' array' ;
2526
2627 // DI
2728 property name = ' wirebox' inject = ' wirebox' ;
@@ -40,6 +41,7 @@ component accessors=true {
4041 setClassOutputDirectory ( ' ' );
4142 setVerbose ( false );
4243 setEncode ( ' ' );
44+ setSource ( [] );
4345 return this ;
4446 }
4547
@@ -51,10 +53,16 @@ component accessors=true {
5153 return this ;
5254 }
5355
54- function fromSource ( required sourceDirectory ){
55- setSourceDirectory ( fileSystemutil .resolvePath ( sourceDirectory , getProjectRoot () ) )
56- return this ;
57- }
56+ function fromSource ( required any source ) {
57+ if ( isSimpleValue ( arguments .source ) ) {
58+ arguments .source = listToArray ( arguments .source );
59+ }
60+ arguments .source = arguments .source .map ( function ( s ) {
61+ return fileSystemutil .resolvePath ( arguments .s , getProjectRoot () );
62+ } );
63+ variables .source = arguments .source ;
64+ return this ;
65+ }
5866
5967 function toClasses ( required classOutputDirectory ){
6068 setClassOutputDirectory ( fileSystemutil .resolvePath ( classOutputDirectory , getProjectRoot () ) )
@@ -72,12 +80,41 @@ component accessors=true {
7280 }
7381
7482 string function run () {
83+ j = generateJavacCommand ();
84+ shell .printString ( j );
85+ shell .callCommand ( j );
86+
87+ }
88+
89+ function generateJavacCommand () {
7590 var workingDirectory = getProjectRoot ();
7691 var classOutputString = " " ;
7792 var verboseString = " " ;
7893 var encodingString = " " ;
7994
80- if ( getSourceDirectory ().len () ) {
95+ if ( getSource ().len () == 0 ){
96+ variables .source = listToArray ( workingDirectory );
97+ }
98+
99+ var currSource = getSource ();
100+ currSource = currSource .map ( function ( p ) {
101+ var currFolder = fileSystemutil .resolvePath ( arguments .p , getProjectRoot () );
102+ if ( directoryExists ( currFolder ) ) {
103+ return currFolder & " *.java" ;
104+ } else {
105+ throw (
106+ message = ' Non-Existing Folder' , detail = currFolder & ' does not exist' ,
107+ type = " commandException"
108+ );
109+ }
110+ } );
111+ variables .source = currSource ;
112+
113+ arrayeach ( variables .source , function ( p ) {
114+ variables .sourceDirectory = variables .sourceDirectory & " #arguments .p # " ;
115+ } );
116+
117+ if ( getSourceDirectory ().len () ) {
81118 workingDirectory = getSourceDirectory ();
82119 }
83120
@@ -90,17 +127,9 @@ component accessors=true {
90127 }
91128
92129 if ( getEncode ().len () ){
93- encodingString = " -encoding #variables .encode #" ;
130+ encodingString = " -encoding #variables .encode # " ;
94131 }
95132
96- var finalCommand = " run javac " ;
97- finalCommand = listAppend (finalCommand , " #workingDirectory #*.java" , " " );
98- finalCommand = listAppend (finalCommand , " #classOutputString #" , " " );
99- finalCommand = listAppend (finalCommand , " #verboseString #" , " " );
100- finalCommand = listAppend (finalCommand , " #encodingString #" , " " );
101-
102- shell .printString ( " #finalCommand # " );
103- shell .callCommand ( " #finalCommand #" );
104-
105- }
133+ return " run javac #workingDirectory # #classOutputString # #verboseString # #encodingString #" ;
134+ }
106135}
0 commit comments