|
@@ -42,6 +42,7 @@ |
42 |
42 |
|
|
43 |
43 |
|
protected void packageClean() |
44 |
44 |
|
{ |
|
45 |
+ |
delete( getPhoneGapDirPath() ); |
45 |
46 |
|
delete( getAppDirPath() ); |
46 |
47 |
|
delete( getOneJarPath() ); |
47 |
48 |
|
delete( getWarPath() ); |
|
@@ -49,7 +50,7 @@ |
49 |
50 |
|
|
50 |
51 |
|
protected boolean packageIt() |
51 |
52 |
|
{ |
52 |
|
- |
return appDir() | oneJAR() | war(); // Note: SINGLE '|' ORs to force full execution! |
|
53 |
+ |
return phoneGapDir() | appDir() | oneJAR() | war(); // Note: SINGLE '|' ORs to force full execution! |
53 |
54 |
|
} |
54 |
55 |
|
|
55 |
56 |
|
/** |
|
@@ -115,6 +116,40 @@ |
115 |
116 |
|
* (including dependency project classpaths) and places them into the specified directory. This is also done for depenency projects, |
116 |
117 |
|
* recursively. This is everything the application needs to be run from JAR files. |
117 |
118 |
|
* |
|
119 |
+ |
* @return True if the PhoneGapDir was populated or false if no distribution (App Dir) is requested for this project. |
|
120 |
+ |
*/ |
|
121 |
+ |
public boolean phoneGapDir() |
|
122 |
+ |
{ |
|
123 |
+ |
String zPhoneGapDir = getPhoneGapDirPath(); |
|
124 |
+ |
if ( zPhoneGapDir == null ) |
|
125 |
+ |
{ |
|
126 |
+ |
return false; |
|
127 |
+ |
} |
|
128 |
+ |
Paths zPaths = new Paths( getGWTwarPath(), "**.js", "**.gif" ); |
|
129 |
+ |
zPaths.add( getDist() ); |
|
130 |
+ |
|
|
131 |
+ |
File zPhoneGapDirFile = new File( zPhoneGapDir ); |
|
132 |
+ |
if ( zPhoneGapDirFile.exists() ) |
|
133 |
+ |
{ |
|
134 |
+ |
if ( zPhoneGapDirFile.lastModified() >= zPaths.getGreatestLastModified() ) |
|
135 |
+ |
{ |
|
136 |
+ |
progress( "PhoneGapDir: " + this + " NOT Needed!" ); |
|
137 |
+ |
return false; |
|
138 |
+ |
} |
|
139 |
+ |
delete( zPhoneGapDirFile ); |
|
140 |
+ |
} |
|
141 |
+ |
|
|
142 |
+ |
progress( "PhoneGapDir: " + this + " -> " + zPhoneGapDir ); |
|
143 |
+ |
String distDir = mkdir( zPhoneGapDir ); // Give it a new Timestamp |
|
144 |
+ |
zPaths.copyTo( distDir ); |
|
145 |
+ |
return true; |
|
146 |
+ |
} |
|
147 |
+ |
|
|
148 |
+ |
/** |
|
149 |
+ |
* Collects the distribution files using the "dist" property, the project's JAR file, and everything on the project's classpath |
|
150 |
+ |
* (including dependency project classpaths) and places them into the specified directory. This is also done for depenency projects, |
|
151 |
+ |
* recursively. This is everything the application needs to be run from JAR files. |
|
152 |
+ |
* |
118 |
153 |
|
* @return True if the AppDir was populated or false if no distribution (App Dir) is requested for this project. |
119 |
154 |
|
*/ |
120 |
155 |
|
public boolean appDir() |
|
@@ -261,7 +296,10 @@ |
261 |
296 |
|
zGWTclassPath.add( FilePath.canonical( zGWTatDir, GWT_USER ) ); |
262 |
297 |
|
zGWTclassPath.add( FilePath.canonical( zGWTatDir, GWT_VALIDATION ) ); |
263 |
298 |
|
zGWTclassPath.add( FilePath.canonical( zGWTatDir, GWT_VALIDATION_SOURCE ) ); |
264 |
|
- |
zGWTclassPath.add( FilePath.canonicalize( getJarPathFile() ) ); |
|
299 |
+ |
if ( mSources ) |
|
300 |
+ |
{ |
|
301 |
+ |
zGWTclassPath.add( FilePath.canonicalize( getJarPathFile() ) ); |
|
302 |
+ |
} |
265 |
303 |
|
zGWTclassPath.add( classpath() ); |
266 |
304 |
|
return zGWTclassPath.toString( File.pathSeparator ); |
267 |
305 |
|
} |
|
@@ -288,17 +326,30 @@ |
288 |
326 |
|
protected File getGeneratedGWT_nocache_jsFile() |
289 |
327 |
|
{ |
290 |
328 |
|
String zGWTxmlRelativeFilePath = getGWT().replace( '.', '/' ) + ".gwt.xml"; // e.g. org.litesoft.sandbox.csapp.CSapp |
291 |
|
- |
RootedPaths[] zRootedPaths = getSource().getRootedPaths(); |
|
329 |
+ |
File zFound = getGeneratedGWT_nocache_jsFile( zGWTxmlRelativeFilePath, getSource() ); |
|
330 |
+ |
if ( zFound == null ) |
|
331 |
+ |
{ |
|
332 |
+ |
if ( null == (zFound = getGeneratedGWT_nocache_jsFile( zGWTxmlRelativeFilePath, getResources() )) ) |
|
333 |
+ |
{ |
|
334 |
+ |
throw new IllegalArgumentException( "Unable to locate GWT module file: " + getGWT() ); |
|
335 |
+ |
} |
|
336 |
+ |
} |
|
337 |
+ |
return zFound; |
|
338 |
+ |
} |
|
339 |
+ |
|
|
340 |
+ |
private File getGeneratedGWT_nocache_jsFile( String pGWTxmlRelativeFilePath, Paths pPaths ) |
|
341 |
+ |
{ |
|
342 |
+ |
RootedPaths[] zRootedPaths = pPaths.getRootedPaths(); |
292 |
343 |
|
for ( RootedPaths zPath : zRootedPaths ) |
293 |
344 |
|
{ |
294 |
|
- |
File zFile = new File( zPath.getCanonicalRootDirectory(), zGWTxmlRelativeFilePath ); |
|
345 |
+ |
File zFile = new File( zPath.getCanonicalRootDirectory(), pGWTxmlRelativeFilePath ); |
295 |
346 |
|
if ( zFile.isFile() ) |
296 |
347 |
|
{ |
297 |
348 |
|
String moduleName = extractModuleNameFrom( getGWT(), fileContents( zFile ) ); |
298 |
349 |
|
return new File( getGWTwarPath(), moduleName + "/" + moduleName + ".nocache.js" ); |
299 |
350 |
|
} |
300 |
351 |
|
} |
301 |
|
- |
throw new IllegalArgumentException( "Unable to locate GWT module file: " + getGWT() ); |
|
352 |
+ |
return null; |
302 |
353 |
|
} |
303 |
354 |
|
|
304 |
355 |
|
private String extractModuleNameFrom( String pGWTmoduleReference, String pGWTmoduleFileContents ) |
|
@@ -332,14 +383,9 @@ |
332 |
383 |
|
|
333 |
384 |
|
protected boolean needToCompileGWT() |
334 |
385 |
|
{ |
335 |
|
- |
File zJarFile = getJarPathFile(); |
336 |
|
- |
if ( !zJarFile.isFile() ) |
337 |
|
- |
{ |
338 |
|
- |
throw new IllegalStateException( this + " Jar Not Built?" ); |
339 |
|
- |
} |
340 |
|
- |
long zJarTimestamp = zJarFile.lastModified(); |
341 |
386 |
|
File zGeneratedGWT_nocache_jsFile = getGeneratedGWT_nocache_jsFile(); |
342 |
|
- |
return (zGeneratedGWT_nocache_jsFile == null) || !zGeneratedGWT_nocache_jsFile.isFile() || (zGeneratedGWT_nocache_jsFile.lastModified() < zJarTimestamp); |
|
387 |
+ |
return needToBuild( ((zGeneratedGWT_nocache_jsFile != null) && zGeneratedGWT_nocache_jsFile.isFile()) ? |
|
388 |
+ |
zGeneratedGWT_nocache_jsFile.lastModified() : forceBuildLastModified() ); |
343 |
389 |
|
} |
344 |
390 |
|
|
345 |
391 |
|
public boolean GWTcompile() |
|
@@ -394,7 +440,8 @@ |
394 |
440 |
|
|
395 |
441 |
|
new Paths( zWarResourceRelativePathCurrent ).copyTo( zWarResourceRelativePathNew ); |
396 |
442 |
|
|
397 |
|
- |
updateFileContents( new File( mCanonicalProjectDir, zWarResourceRelativePathNew + "/index.html" ), updateVersionedIndexHtml( zIndexHtml, zCurVersion, zNewVersion ) ); |
|
443 |
+ |
updateFileContents( new File( mCanonicalProjectDir, zWarResourceRelativePathNew + "/index.html" ), |
|
444 |
+ |
updateVersionedIndexHtml( zIndexHtml, zCurVersion, zNewVersion ) ); |
398 |
445 |
|
|
399 |
446 |
|
updateFileContents( zWarWebXmlFile, updateVersionedWebXml( zWarWebXml, zCurVersion, zNewVersion ) ); |
400 |
447 |
|
|
|
@@ -462,7 +509,8 @@ |
462 |
509 |
|
} |
463 |
510 |
|
if ( zVersionedFiles.isEmpty() ) |
464 |
511 |
|
{ |
465 |
|
- |
throw new IllegalStateException( "Project does not appear to contain a 'gwt.xml' file with the current version module definition of: " + zVersionedModule ); |
|
512 |
+ |
throw new IllegalStateException( |
|
513 |
+ |
"Project does not appear to contain a 'gwt.xml' file with the current version module definition of: " + zVersionedModule ); |
466 |
514 |
|
} |
467 |
515 |
|
return zVersionedFiles; |
468 |
516 |
|
} |
|
@@ -482,7 +530,9 @@ |
482 |
530 |
|
String zContents = fileContents( assertIsFile( "Versioned index.html", pIndexHtmlFile ) ); |
483 |
531 |
|
if ( !zContents.contains( zVersionedScript ) ) |
484 |
532 |
|
{ |
485 |
|
- |
throw new IllegalStateException( "Project's current versioned index.html file (" + pIndexHtmlFile.getPath() + ") does not contain a 'versioned' script element of: " + zVersionedScript ); |
|
533 |
+ |
throw new IllegalStateException( |
|
534 |
+ |
"Project's current versioned index.html file (" + pIndexHtmlFile.getPath() + ") does not contain a 'versioned' script element of: " + |
|
535 |
+ |
zVersionedScript ); |
486 |
536 |
|
} |
487 |
537 |
|
return zContents; |
488 |
538 |
|
} |
|
@@ -528,18 +578,19 @@ |
528 |
578 |
|
return false; |
529 |
579 |
|
} |
530 |
580 |
|
mBuilt = true; |
|
581 |
+ |
mSources = !getSource().isEmpty(); |
531 |
582 |
|
boolean zAnythingBuilt = false; |
532 |
583 |
|
boolean zBuildIt; |
533 |
584 |
|
try |
534 |
585 |
|
{ |
535 |
|
- |
zBuildIt = !buildDependencies() && !needToBuild(); |
|
586 |
+ |
zBuildIt = buildDependencies() || needToBuild(); |
536 |
587 |
|
} |
537 |
588 |
|
catch ( RuntimeException e ) |
538 |
589 |
|
{ |
539 |
590 |
|
progress( "Build: " + this ); |
540 |
591 |
|
throw e; |
541 |
592 |
|
} |
542 |
|
- |
if ( zBuildIt ) |
|
593 |
+ |
if ( !zBuildIt ) |
543 |
594 |
|
{ |
544 |
595 |
|
progress( "Build: " + this + " NOT Needed!" ); |
545 |
596 |
|
} |
|
@@ -547,9 +598,12 @@ |
547 |
598 |
|
{ |
548 |
599 |
|
progress( "Build: " + this ); |
549 |
600 |
|
clean(); |
550 |
|
- |
compile(); |
551 |
|
- |
jar(); |
552 |
|
- |
zAnythingBuilt = true; |
|
601 |
+ |
if ( mSources ) |
|
602 |
+ |
{ |
|
603 |
+ |
compile(); |
|
604 |
+ |
jar(); |
|
605 |
+ |
zAnythingBuilt = true; |
|
606 |
+ |
} |
553 |
607 |
|
} |
554 |
608 |
|
zAnythingBuilt |= GWTcompile(); |
555 |
609 |
|
zAnythingBuilt |= packageIt(); |
|
@@ -558,22 +612,57 @@ |
558 |
612 |
|
|
559 |
613 |
|
protected boolean needToBuild() |
560 |
614 |
|
{ |
561 |
|
- |
File zJarFile = getJarPathFile(); |
562 |
|
- |
if ( !zJarFile.isFile() ) |
|
615 |
+ |
return needToBuild( determineOutputLastModified() ); |
|
616 |
+ |
} |
|
617 |
+ |
|
|
618 |
+ |
protected boolean needToBuild( long pOutputLastModified ) |
|
619 |
+ |
{ |
|
620 |
+ |
return (mProjectFileLastModified > pOutputLastModified) || // |
|
621 |
+ |
checkNewer( pOutputLastModified, "ClassPath", compileClasspath() ) || // |
|
622 |
+ |
checkNewer( pOutputLastModified, "Source", getSource() ) || // |
|
623 |
+ |
checkNewer( pOutputLastModified, "Resources", getResources() ) || // |
|
624 |
+ |
checkNewer( pOutputLastModified, "Dist", getDist() ); |
|
625 |
+ |
} |
|
626 |
+ |
|
|
627 |
+ |
protected boolean checkNewer( long pOutputLastModified, String pWhat, Paths pPaths ) |
|
628 |
+ |
{ |
|
629 |
+ |
Long zLastModified = pPaths.getGreatestLastModified(); |
|
630 |
+ |
if ( (zLastModified != null) && (zLastModified > pOutputLastModified) ) |
563 |
631 |
|
{ |
|
632 |
+ |
System.out.println( this + ": " + pWhat + " newer by " + (zLastModified - pOutputLastModified) + "ms" ); |
564 |
633 |
|
return true; |
565 |
634 |
|
} |
566 |
|
- |
long zJarTimestamp = zJarFile.lastModified(); |
567 |
|
- |
return (mProjectFileLastModified > zJarTimestamp) || // |
568 |
|
- |
checkNewer( zJarTimestamp, compileClasspath() ) || // |
569 |
|
- |
checkNewer( zJarTimestamp, getSource() ) || // |
570 |
|
- |
checkNewer( zJarTimestamp, getResources() ); |
|
635 |
+ |
return false; |
571 |
636 |
|
} |
572 |
637 |
|
|
573 |
|
- |
protected boolean checkNewer( long pJarTimestamp, Paths pPaths ) |
|
638 |
+ |
protected long forceBuildLastModified() |
574 |
639 |
|
{ |
575 |
|
- |
Long zLastModified = pPaths.getGreatestLastModified(); |
576 |
|
- |
return (zLastModified != null) && (zLastModified > pJarTimestamp); |
|
640 |
+ |
return (mProjectFileLastModified - 1); |
|
641 |
+ |
} |
|
642 |
+ |
|
|
643 |
+ |
protected long determineOutputLastModified() |
|
644 |
+ |
{ |
|
645 |
+ |
if ( mSources ) |
|
646 |
+ |
{ |
|
647 |
+ |
File zJarFile = getJarPathFile(); |
|
648 |
+ |
if ( zJarFile.isFile() ) |
|
649 |
+ |
{ |
|
650 |
+ |
return zJarFile.lastModified(); |
|
651 |
+ |
} |
|
652 |
+ |
} |
|
653 |
+ |
else |
|
654 |
+ |
{ |
|
655 |
+ |
String zPhoneGapDir = getPhoneGapDirPath(); |
|
656 |
+ |
if ( zPhoneGapDir != null ) |
|
657 |
+ |
{ |
|
658 |
+ |
File zPhoneGapDirFile = new File( zPhoneGapDir ); |
|
659 |
+ |
if ( zPhoneGapDirFile.isDirectory() ) |
|
660 |
+ |
{ |
|
661 |
+ |
return zPhoneGapDirFile.lastModified(); |
|
662 |
+ |
} |
|
663 |
+ |
} |
|
664 |
+ |
} |
|
665 |
+ |
return forceBuildLastModified(); |
577 |
666 |
|
} |
578 |
667 |
|
|
579 |
668 |
|
/** |
|
@@ -652,12 +741,14 @@ |
652 |
741 |
|
|
653 |
742 |
|
if ( compiler == null ) |
654 |
743 |
|
{ |
655 |
|
- |
throw new RuntimeException( "No compiler available. Ensure you are running from a " + getTargetJavaVersion() + "+ JDK, and not a JRE *and* that your class path includes tools.jar." ); |
|
744 |
+ |
throw new RuntimeException( "No compiler available. Ensure you are running from a " + getTargetJavaVersion() + |
|
745 |
+ |
"+ JDK, and not a JRE *and* that your class path includes tools.jar." ); |
656 |
746 |
|
} |
657 |
747 |
|
int zError = compiler.run( getCompile_in(), getCompile_out(), getCompile_err(), pCompileArgs.toArray( new String[pCompileArgs.size()] ) ); |
658 |
748 |
|
if ( zError != 0 ) |
659 |
749 |
|
{ |
660 |
|
- |
throw new RuntimeException( "Error (" + zError + ") during compilation of project: " + this + "\nSource: " + pSource.count() + " files\nClasspath: " + pClasspath ); |
|
750 |
+ |
throw new RuntimeException( |
|
751 |
+ |
"Error (" + zError + ") during compilation of project: " + this + "\nSource: " + pSource.count() + " files\nClasspath: " + pClasspath ); |
661 |
752 |
|
} |
662 |
753 |
|
try |
663 |
754 |
|
{ |
|
@@ -972,12 +1063,15 @@ |
972 |
1063 |
|
|
973 |
1064 |
|
protected void addDependentProjectJar( Paths pPathsToAddTo ) |
974 |
1065 |
|
{ |
975 |
|
- |
File zJarFile = getJarPathFile(); |
976 |
|
- |
if ( !zJarFile.isFile() ) |
|
1066 |
+ |
if ( mSources ) |
977 |
1067 |
|
{ |
978 |
|
- |
throw new RuntimeException( "Dependency (" + this + ") Jar not found, not built?" ); |
|
1068 |
+ |
File zJarFile = getJarPathFile(); |
|
1069 |
+ |
if ( !zJarFile.isFile() ) |
|
1070 |
+ |
{ |
|
1071 |
+ |
throw new RuntimeException( "Dependency (" + this + ") Jar not found, not built?" ); |
|
1072 |
+ |
} |
|
1073 |
+ |
pPathsToAddTo.add( new FilePath( zJarFile.getParentFile(), zJarFile.getName() ) ); |
979 |
1074 |
|
} |
980 |
|
- |
pPathsToAddTo.add( new FilePath( zJarFile.getParentFile(), zJarFile.getName() ) ); |
981 |
1075 |
|
} |
982 |
1076 |
|
|
983 |
1077 |
|
/** |
|
@@ -1103,5 +1197,6 @@ |
1103 |
1197 |
|
} |
1104 |
1198 |
|
|
1105 |
1199 |
|
protected boolean mBuilt = false; |
|
1200 |
+ |
protected boolean mSources = false; |
1106 |
1201 |
|
protected List<Project> mDependantProjects = new ArrayList<Project>(); |
1107 |
1202 |
|
} |