Subversion Repository Public Repository

litesoft

Diff Revisions 959 vs 974 for /trunk/Java/ScarPlus/src/com/esotericsoftware/scar/Scar.java

Diff revisions: vs.
  @@ -25,19 +25,19 @@
25 25 * Provides utility methods for common Java build tasks.
26 26 */
27 27 @SuppressWarnings({"ResultOfMethodCallIgnored"})
28 - public class Scar extends Utils implements ProjectFactory {
29 - public static final String VERSION = "2.95 - 1.7";
28 + public class Scar extends Utils implements ProjectAccessor,
29 + ProjectFactory {
30 + public static final String VERSION = "2.96 - 1.7";
30 31
31 32 public static final String DEFAULT_PROJECT_FILE_NAME = "Build";
32 -
33 - public static final String JAVA_EXTENSION = ".java";
34 - public static final String YAML_EXTENSION = ".yaml";
33 + public static final String YAML_EXTENSION = "yaml";
34 + private static final String DEFAULT_YAML_PROJECT_FILE_NAME = DEFAULT_PROJECT_FILE_NAME + "." + YAML_EXTENSION;
35 35
36 36 protected static final Logger LOGGER = LoggerFactory.getLogger( Scar.class );
37 37
38 38 protected final ProjectCache mProjectCache = new ProjectCache();
39 39
40 - private Project mLaunchProject;
40 + private ProjectFromFile mLaunchProject;
41 41
42 42 /**
43 43 * The command line arguments Scar was started with. Empty if Scar was started with no arguments or Scar was not started from
  @@ -50,136 +50,109 @@
50 50 }
51 51
52 52 @SuppressWarnings({"UnusedDeclaration"})
53 - public Project getLaunchProject() {
53 + public ProjectFromFile getLaunchProject() {
54 54 return mLaunchProject;
55 55 }
56 56
57 57 /**
58 58 * Loads the specified project with default values and loads any other projects needed for the "include" property.
59 59 *
60 - * @param pCanonicalCurrentDirectory
61 - * @param pPath Path to a YAML project file, or a directory containing a "project.yaml" file.
60 + * @param pCanonicalCurrentDirectory Current project's (or starting directory's) actual directory!
61 + * @param pPath Path to a YAML project file, or a directory containing a "project.yaml" file w/ an optional
62 + * jars path reference (e.g. '|| xyzzy') should the dependent project be unreachable.
62 63 */
63 64 @Override
64 - public Project project( File pCanonicalCurrentDirectory, String pPath ) {
65 + public Project getProject( File pCanonicalCurrentDirectory, String pPath ) {
65 66 Util.assertNotNull( "CurrentDirectory", pCanonicalCurrentDirectory );
66 - pPath = Util.assertNotEmpty( "Path", pPath );
67 +
68 + File zTargetDistDirForClassPathJars = null;
69 +
70 + int zAt = (pPath = Util.assertNotEmpty( "Project Path", pPath )).indexOf( "||" );
71 + if ( zAt != -1 ) {
72 + zTargetDistDirForClassPathJars = extractTargetDistDirForClassPathJars( pCanonicalCurrentDirectory, pPath, pPath.substring( zAt + 2 ) );
73 + pPath = Util.assertNotEmpty( "Project '" + pPath + "' less '||...'", pPath.substring( 0, zAt ) );
74 + }
75 +
67 76 File zFile = new File( pPath );
68 77 if ( !zFile.isAbsolute() ) {
69 78 zFile = new File( pCanonicalCurrentDirectory, pPath );
70 79 }
71 - try {
72 - zFile = zFile.getCanonicalFile();
73 - }
74 - catch ( IOException e ) {
75 - throw new WrappedIOException( e );
76 - }
77 -
78 - String zPath = zFile.getPath();
79 - Project zProject = mProjectCache.getByPath( zPath );
80 - if ( zProject != null ) {
81 - return zProject;
82 - }
83 - try {
84 - if ( zFile.isFile() ) { // Assume Project Build File
85 - return mProjectCache.initialize( this, zPath, createProject( zFile, zFile.getParentFile() ) );
86 - }
87 - if ( zFile.isDirectory() ) { // Assume Project Dir
88 - return mProjectCache.initialize( this, zPath, createProject( findBuildFile( zFile ), zFile, zFile.getName() ) );
80 + if ( zFile.exists() ) {
81 + zFile = probableProjectFile( zFile );
82 + ProjectFromFile zProject = mProjectCache.getByPath( zFile, this );
83 + return (zTargetDistDirForClassPathJars != null) ? new TargetDistributionProxyProject( zProject, zTargetDistDirForClassPathJars ) : zProject;
84 + }
85 + if ( zTargetDistDirForClassPathJars != null ) {
86 + String zProjectName = projectNameFrom( zFile );
87 + TargetDistributionProject zProject = new TargetDistributionProject( zProjectName, zTargetDistDirForClassPathJars );
88 + if ( zProject.hasArtifactFiles() ) {
89 + return zProject;
89 90 }
90 - }
91 - catch ( WrappedIOException e ) {
92 - throw new WrappedIOException( pPath, e );
91 + throw new IllegalStateException( "Target Dist Dir for Project '" + zProjectName + "', but no Artifact files found at: " + zTargetDistDirForClassPathJars );
93 92 }
94 93 throw new IllegalArgumentException( "Project is Neither a Project File, nor a Project Directory: " + zFile );
95 94 }
96 95
97 - protected File findBuildFile( File pProjectDir ) {
98 - File[] zFiles = pProjectDir.listFiles( BuildFileFilter.INSTANCE );
99 - if ( (zFiles == null) || (zFiles.length == 0) ) {
100 - return null;
96 + private File probableProjectFile( File pFile ) {
97 + if ( pFile.isDirectory() ) {
98 + pFile = new File( pFile, DEFAULT_YAML_PROJECT_FILE_NAME );
101 99 }
102 - if ( zFiles.length == 1 ) {
103 - return zFiles[0];
100 + if ( pFile.isFile() && YAML_EXTENSION.equalsIgnoreCase( new FileNameExtension( pFile.getName() ).getExtension() ) ) {
101 + return FileUtils.getCanonicalFile( pFile );
104 102 }
105 - File zFile = findBuildFile( zFiles, JAVA_EXTENSION );
106 - return (zFile != null) ? zFile : findBuildFile( zFiles, YAML_EXTENSION );
103 + throw new IllegalArgumentException( "Project is Neither a Project File, nor a Project Directory (with '" + DEFAULT_YAML_PROJECT_FILE_NAME + "'): " + pFile );
107 104 }
108 105
109 - private File findBuildFile( File[] pFiles, String pExtension ) {
110 - File rv = null;
111 - for ( File zFile : pFiles ) {
112 - if ( zFile.getName().endsWith( pExtension ) ) {
113 - if ( rv != null ) {
114 - throw new IllegalStateException( "Found Both:\n " + rv + "\n " + zFile );
115 - }
116 - rv = zFile;
117 - }
106 + private File extractTargetDistDirForClassPathJars( File pCanonicalCurrentDirectory, String pFullPath, String pRelativeDirPath ) {
107 + pRelativeDirPath = Util.assertNotEmpty( "Project '" + pFullPath + "' post '||'", pRelativeDirPath );
108 + File zFile = new File( pCanonicalCurrentDirectory, pRelativeDirPath );
109 + if ( !zFile.exists() ) {
110 + FileUtils.ensureDirectory( zFile );
118 111 }
119 - return rv;
120 - }
121 -
122 - protected Project createProject( File pPossibleBuildFile, File pCanonicalProjectDir ) {
123 - String zBuildFileName = pPossibleBuildFile.getName();
124 - int zDotAt = zBuildFileName.lastIndexOf( '.' );
125 - if ( (zDotAt != -1) && (pCanonicalProjectDir != null) ) {
126 - String zName = zBuildFileName.substring( 0, zDotAt ).trim();
127 - if ( DEFAULT_PROJECT_FILE_NAME.equalsIgnoreCase( zName ) ) {
128 - zName = pCanonicalProjectDir.getName();
129 - }
130 - return createProject( pPossibleBuildFile, pCanonicalProjectDir, zName );
112 + if ( zFile.isDirectory() ) {
113 + return FileUtils.getCanonicalFile( zFile );
131 114 }
132 - throw new IllegalArgumentException( "Unacceptable Project Path or Name, Project File " + pPossibleBuildFile );
115 + throw new IllegalArgumentException( "Project '" + pFullPath + "' post '||' is not a Directory" );
133 116 }
134 117
135 - protected Project createProject( File pBuildFile, File pCanonicalProjectDir, String pProjectName ) {
136 - if ( pBuildFile == null ) {
137 - throw new IllegalArgumentException( "No 'Build.java' or 'Build.yaml' file found in Project Directory: " + pCanonicalProjectDir );
138 - }
139 - String zBuildFileName = pBuildFile.getName();
140 - if ( zBuildFileName.endsWith( JAVA_EXTENSION ) ) {
141 - return createJavaProject( pBuildFile, pCanonicalProjectDir, pProjectName );
142 - }
143 - if ( zBuildFileName.endsWith( YAML_EXTENSION ) ) {
144 - return createYamlProject( pBuildFile, pCanonicalProjectDir, pProjectName );
145 - }
146 - throw new IllegalArgumentException( pBuildFile + " was NOT either a '.java' or a '.yaml' file!" );
147 - }
148 -
149 - protected Project createYamlProject( File pYamlBuildFile, File pCanonicalProjectDir, String pProjectName ) {
150 - List<String> zLines = readLines( pYamlBuildFile );
151 - int at = findLine( zLines, "---" );
152 - String zYAML, zCode = null;
153 - if ( at == -1 ) {
154 - zYAML = mergeLines( zLines, 0 );
155 - } else {
156 - zYAML = mergeLines( zLines, 0, at );
157 - zCode = Util.noEmpty( mergeLines( zLines, at + 1 ) );
118 + protected String projectNameFrom( File pPathToProjectFile ) {
119 + String zName = pPathToProjectFile.getName();
120 + int zDotAt = zName.lastIndexOf( '.' );
121 + if ( zDotAt != -1 ) {
122 + zName = zName.substring( 0, zDotAt );
158 123 }
159 - Map<Object, Object> zData = (zYAML.length() == 0) ? new HashMap<Object, Object>() : parseYAML( pCanonicalProjectDir, zYAML );
160 - Class<? extends Project> zClass = createYamlProjectClass();
161 - if ( zCode != null ) {
162 - zClass = createYamlCodeProjectClass( zClass, zCode, at + 1 );
124 + if ( !DEFAULT_PROJECT_FILE_NAME.equalsIgnoreCase( zName ) ) {
125 + return zName;
163 126 }
164 - return instantiate( pYamlBuildFile, zClass, pCanonicalProjectDir, pProjectName, zData );
127 + return pPathToProjectFile.getParentFile().getName();
165 128 }
166 129
167 - protected Project createJavaProject( File pJavaBuildFile, File pCanonicalProjectDir, String pProjectName ) {
168 - String zFile = mergeLines( readLines( pJavaBuildFile ), 0 );
169 - Class<? extends Project> zClass = createJavaProjectClass();
170 - zClass = createJavaCodeProjectClass( zClass, zFile );
171 - return instantiate( pJavaBuildFile, zClass, pCanonicalProjectDir, pProjectName, null );
130 + @Override
131 + public ProjectFromFile createProject( File pPathToProjectFile ) {
132 + String zProjectName = projectNameFrom( pPathToProjectFile );
133 + String zBuildFileName = pPathToProjectFile.getName();
134 + if ( !zBuildFileName.endsWith( YAML_EXTENSION ) ) {
135 + throw new IllegalArgumentException( pPathToProjectFile + " was NOT a '.yaml' file!" );
136 + }
137 + // YAML!
138 + File zYamlBuildFile = pPathToProjectFile;
139 + File zCanonicalProjectDir = FileUtils.getCanonicalFile( pPathToProjectFile.getParentFile() );
140 + List<String> zLines = readLines( pPathToProjectFile );
141 + String zYAML = mergeLines( zLines, 0 );
142 + Map<Object, Object> zData = (zYAML.length() == 0) ? new HashMap<Object, Object>() : parseYAML( zCanonicalProjectDir, zYAML );
143 + Class<? extends ProjectFromFile> zClass = createYamlProjectClass();
144 + return instantiate( zYamlBuildFile, zClass, zCanonicalProjectDir, zProjectName, zData );
172 145 }
173 146
174 - protected Project instantiate( File zProjectFile, Class<? extends Project> pClass, File pCanonicalProjectDir, String pProjectName, Map<Object, Object> pData ) {
147 + protected ProjectFromFile instantiate( File zProjectFile, Class<? extends Project> pClass, File pCanonicalProjectDir, String pProjectName, Map<Object, Object> pData ) {
175 148 return instantiate( pClass, new ProjectParameters( zProjectFile, pProjectName, pCanonicalProjectDir, pData ) );
176 149 }
177 150
178 - protected Project instantiate( Class<? extends Project> pClass, ProjectParameters pParameters ) {
151 + protected ProjectFromFile instantiate( Class<? extends Project> pClass, ProjectParameters pParameters ) {
179 152 Throwable zCause;
180 153 try {
181 154 Constructor zConstructor = pClass.getConstructor( ProjectParameters.class );
182 - return (Project) zConstructor.newInstance( pParameters );
155 + return (ProjectFromFile) zConstructor.newInstance( pParameters );
183 156 }
184 157 catch ( NoSuchMethodException e ) {
185 158 zCause = e;
  @@ -202,12 +175,8 @@
202 175 throw new RuntimeException( "Unable to Instantiate Project Class for Project: " + pParameters.getName() + " in dir " + pParameters.getCanonicalProjectDir(), zCause );
203 176 }
204 177
205 - protected Class<? extends Project> createYamlProjectClass() {
206 - return Project.class;
207 - }
208 -
209 - protected Class<? extends Project> createJavaProjectClass() {
210 - return Project.class;
178 + protected Class<? extends ProjectFromFile> createYamlProjectClass() {
179 + return ProjectFromFile.class;
211 180 }
212 181
213 182 protected Map<Object, Object> parseYAML( File pProjectDir, String pYAML ) {
  @@ -229,14 +198,14 @@
229 198 return yamlReader.read( HashMap.class );
230 199 }
231 200 catch ( IOException e ) {
232 - throw new WrappedIOException( e );
201 + throw new FileSystemException( e );
233 202 }
234 203 finally {
235 204 try {
236 205 yamlReader.close();
237 206 }
238 207 catch ( IOException e ) {
239 - throw new WrappedIOException( e );
208 + throw new FileSystemException( e );
240 209 }
241 210 }
242 211 }
  @@ -253,14 +222,14 @@
253 222 return sb.toString();
254 223 }
255 224
256 - private int findLine( List<String> pLines, String zLine ) {
257 - for ( int i = 0; i < pLines.size(); i++ ) {
258 - if ( zLine.equals( pLines.get( i ) ) ) {
259 - return i;
260 - }
261 - }
262 - return -1;
263 - }
225 + // private int findLine( List<String> pLines, String zLine ) {
226 + // for ( int i = 0; i < pLines.size(); i++ ) {
227 + // if ( zLine.equals( pLines.get( i ) ) ) {
228 + // return i;
229 + // }
230 + // }
231 + // return -1;
232 + // }
264 233
265 234 protected List<String> readLines( File zFile ) {
266 235 BufferedReader fileReader;
  @@ -268,7 +237,7 @@
268 237 fileReader = new BufferedReader( new FileReader( zFile ) );
269 238 }
270 239 catch ( FileNotFoundException e ) {
271 - throw new WrappedIOException( e );
240 + throw new FileSystemException( e );
272 241 }
273 242 try {
274 243 List<String> lines = new ArrayList<String>();
  @@ -289,7 +258,7 @@
289 258 // Whatever!
290 259 }
291 260 }
292 - throw new WrappedIOException( e );
261 + throw new FileSystemException( e );
293 262 }
294 263 }
295 264
  @@ -315,21 +284,13 @@
315 284 };
316 285 }
317 286
318 - protected Class<Project> createYamlCodeProjectClass( Class<? extends Project> pClass, String pCode, int pOverheadStartLines ) {
319 - throw new UnsupportedOperationException(); // todo: See - executeDocument();
320 - }
321 -
322 - protected Class<Project> createJavaCodeProjectClass( Class<? extends Project> pClass, String pCode ) {
323 - throw new UnsupportedOperationException(); // todo: See - executeDocument()!;
324 - }
325 -
326 287 /**
327 288 * Cleans All projects - Normally called reflectively
328 289 */
329 290 @SuppressWarnings({"UnusedDeclaration"})
330 291 public void cleanAll() {
331 292 progress( "CleanAll" );
332 - Set<Project> zProjects = mProjectCache.getAllProjects();
293 + List<Project> zProjects = mProjectCache.getAllProjects();
333 294 for ( Project zProject : zProjects ) {
334 295 zProject.clean();
335 296 }
  @@ -428,7 +389,7 @@
428 389 tempFile = File.createTempFile( "scar", "removejarsig" );
429 390 }
430 391 catch ( IOException e ) {
431 - throw new WrappedIOException( e );
392 + throw new FileSystemException( e );
432 393 }
433 394 JarOutputStream jarOutput = null;
434 395 JarInputStream jarInput = null;
  @@ -467,7 +428,7 @@
467 428 copyFile( tempFile.getAbsolutePath(), jarFile );
468 429 }
469 430 catch ( IOException ex ) {
470 - throw new WrappedIOException( "Error unsigning JAR file: " + jarFile, ex );
431 + throw new FileSystemException( "Error unsigning JAR file: " + jarFile, ex );
471 432 }
472 433 finally {
473 434 dispose( jarInput );
  @@ -582,13 +543,13 @@
582 543 input = new FileInputStream( file );
583 544 }
584 545 catch ( FileNotFoundException e ) {
585 - throw new WrappedIOException( e );
546 + throw new FileSystemException( e );
586 547 }
587 548 try {
588 549 copyStreamAndCloseEm( input, new GZIPOutputStream( new FileOutputStream( gzipFile ) ) );
589 550 }
590 551 catch ( IOException e ) {
591 - throw new WrappedIOException( e );
552 + throw new FileSystemException( e );
592 553 }
593 554 finally {
594 555 dispose( input );
  @@ -628,13 +589,13 @@
628 589 input = new GZIPInputStream( new FileInputStream( gzipFile ) );
629 590 }
630 591 catch ( IOException e ) {
631 - throw new WrappedIOException( e );
592 + throw new FileSystemException( e );
632 593 }
633 594 try {
634 595 copyStreamAndCloseEm( input, new FileOutputStream( file ) );
635 596 }
636 597 catch ( FileNotFoundException e ) {
637 - throw new WrappedIOException( e );
598 + throw new FileSystemException( e );
638 599 }
639 600 finally {
640 601 dispose( input );
  @@ -682,7 +643,7 @@
682 643 LzmaAlone.main( new String[]{"e", file, lzmaFile} );
683 644 }
684 645 catch ( Exception ex ) {
685 - throw new WrappedIOException( "Error lzma compressing file: " + file, ex );
646 + throw new FileSystemException( "Error lzma compressing file: " + file, ex );
686 647 }
687 648 return lzmaFile;
688 649 }
  @@ -718,7 +679,7 @@
718 679 LzmaAlone.main( new String[]{"d", lzmaFile, file} );
719 680 }
720 681 catch ( Exception ex ) {
721 - throw new WrappedIOException( "Error lzma decompressing file: " + file, ex );
682 + throw new FileSystemException( "Error lzma decompressing file: " + file, ex );
722 683 }
723 684 return file;
724 685 }
  @@ -728,7 +689,7 @@
728 689 * the specified keystore to sign each JAR. If the "pack" parameter is true, it also compresses each JAR using pack200 and
729 690 * GZIP.
730 691 */
731 - public void jws( Project project, boolean pack, String keystoreFile, String alias, String password ) {
692 + public void jws( ProjectFromFile project, boolean pack, String keystoreFile, String alias, String password ) {
732 693 Util.assertNotNull( "Project", project );
733 694 Util.assertNotNull( "keystoreFile", keystoreFile );
734 695 Util.assertNotNull( "alias", alias );
  @@ -762,7 +723,7 @@
762 723 * Generates ".htaccess" and "type map" VAR files in the "jws" directory. These files allow Apache to serve both pack200/GZIP
763 724 * JARs and regular JARs, based on capability of the client requesting the JAR.
764 725 */
765 - public void jwsHtaccess( Project project ) {
726 + public void jwsHtaccess( ProjectFromFile project ) {
766 727 Util.assertNotNull( "Project", project );
767 728
768 729 progress( "JWS htaccess: " + project );
  @@ -776,7 +737,7 @@
776 737 writer = new FileWriter( jwsDir + jarFileName + ".var" );
777 738 }
778 739 catch ( IOException e ) {
779 - throw new WrappedIOException( e );
740 + throw new FileSystemException( e );
780 741 }
781 742 try {
782 743 writer.write( "URI: packed/" + packedFileName + "\n" );
  @@ -786,7 +747,7 @@
786 747 writer.write( "Content-Type: x-java-archive\n" );
787 748 }
788 749 catch ( IOException e ) {
789 - throw new WrappedIOException( e );
750 + throw new FileSystemException( e );
790 751 }
791 752 finally {
792 753 dispose( writer );
  @@ -797,7 +758,7 @@
797 758 writer = new FileWriter( jwsDir + ".htaccess" );
798 759 }
799 760 catch ( IOException e ) {
800 - throw new WrappedIOException( e );
761 + throw new FileSystemException( e );
801 762 }
802 763 try {
803 764 writer.write( "AddType application/x-java-jnlp-file .jnlp" ); // JNLP mime type.
  @@ -811,7 +772,7 @@
811 772 writer.write( "</Files>\n" );
812 773 }
813 774 catch ( IOException e ) {
814 - throw new WrappedIOException( e );
775 + throw new FileSystemException( e );
815 776 }
816 777 finally {
817 778 dispose( writer );
  @@ -825,7 +786,7 @@
825 786 *
826 787 * @param splashImage Can be null.
827 788 */
828 - public void jnlp( Project project, String url, String company, String title, String splashImage ) {
789 + public void jnlp( ProjectFromFile project, String url, String company, String title, String splashImage ) {
829 790 Util.assertNotNull( "Project", project );
830 791 Util.assertNotNull( "company", company );
831 792 Util.assertNotNull( "title", title );
  @@ -859,7 +820,7 @@
859 820 writer = new FileWriter( jwsDir + jnlpFile );
860 821 }
861 822 catch ( IOException e ) {
862 - throw new WrappedIOException( e );
823 + throw new FileSystemException( e );
863 824 }
864 825 try {
865 826 writer.write( "<?xml version='1.0' encoding='utf-8'?>\n" );
  @@ -927,14 +888,14 @@
927 888 writer.write( "</jnlp>" );
928 889 }
929 890 catch ( IOException e ) {
930 - throw new WrappedIOException( e );
891 + throw new FileSystemException( e );
931 892 }
932 893 finally {
933 894 dispose( writer );
934 895 }
935 896 }
936 897
937 - public String lwjglApplet( Project project, String keystoreFile, String alias, String password ) {
898 + public String lwjglApplet( ProjectFromFile project, String keystoreFile, String alias, String password ) {
938 899 Util.assertNotNull( "Project", project );
939 900 Util.assertNotNull( "keystoreFile", keystoreFile );
940 901 Util.assertNotNull( "alias", alias );
  @@ -974,7 +935,7 @@
974 935 writer = new FileWriter( appletDir + "applet.html" );
975 936 }
976 937 catch ( IOException e ) {
977 - throw new WrappedIOException( e );
938 + throw new FileSystemException( e );
978 939 }
979 940 try {
980 941 writer.write( "<html>\n" );
  @@ -1019,7 +980,7 @@
1019 980 writer.write( "</body></html>\n" );
1020 981 }
1021 982 catch ( IOException e ) {
1022 - throw new WrappedIOException( e );
983 + throw new FileSystemException( e );
1023 984 }
1024 985 finally {
1025 986 dispose( writer );
  @@ -1045,7 +1006,7 @@
1045 1006 *
1046 1007 * @param parameters These parameters will be available in the scope where the code is executed.
1047 1008 */
1048 - public void executeCode( Project project, String code, HashMap<String, Object> parameters ) {
1009 + public void executeCode( ProjectFromFile project, String code, HashMap<String, Object> parameters ) {
1049 1010 try {
1050 1011 // Wrap code in a class.
1051 1012 StringBuilder classBuffer = new StringBuilder( 2048 );
  @@ -1165,52 +1126,6 @@
1165 1126 /// todo: ==================================================================================================================
1166 1127 /// todo: ==================================================================================================================
1167 1128
1168 - private static class BuildFileFilter implements FileFilter {
1169 - private static final String DEFAULT_JAVA_PROJECT_FILE_NAME = DEFAULT_PROJECT_FILE_NAME + JAVA_EXTENSION;
1170 - private static final String DEFAULT_YAML_PROJECT_FILE_NAME = DEFAULT_PROJECT_FILE_NAME + YAML_EXTENSION;
1171 -
1172 - @Override
1173 - public boolean accept( File pFile ) {
1174 - if ( pFile.isFile() ) {
1175 - String zName = pFile.getName();
1176 - if ( DEFAULT_JAVA_PROJECT_FILE_NAME.equalsIgnoreCase( zName ) || DEFAULT_YAML_PROJECT_FILE_NAME.equalsIgnoreCase( zName ) ) {
1177 - return pFile.canRead();
1178 - }
1179 - }
1180 - return false;
1181 - }
1182 -
1183 - public static final FileFilter INSTANCE = new BuildFileFilter();
1184 - }
1185 -
1186 - private static class ProjectCache {
1187 - private Map<String, Project> mProjectByName = new HashMap<String, Project>();
1188 - private Map<String, Project> mProjectByPath = new HashMap<String, Project>();
1189 -
1190 - public synchronized Project getByPath( String pPath ) {
1191 - return mProjectByPath.get( pPath );
1192 - }
1193 -
1194 - private Project initialize( ProjectFactory pFactory, String pPath, Project pProject ) {
1195 - synchronized ( this ) {
1196 - String zName = pProject.getName();
1197 - Project zProject = mProjectByName.get( zName );
1198 - if ( zProject != null ) {
1199 - mProjectByPath.put( pPath, zProject );
1200 - return zProject;
1201 - }
1202 - mProjectByPath.put( pPath, pProject );
1203 - mProjectByName.put( zName, pProject );
1204 - }
1205 - pProject.initialize( pFactory );
1206 - return pProject;
1207 - }
1208 -
1209 - public Set<Project> getAllProjects() {
1210 - return new HashSet<Project>( mProjectByName.values() );
1211 - }
1212 - }
1213 -
1214 1129 protected Runnable createRunnableFor( String pMethodName ) {
1215 1130 Runnable zRunnable = createRunnableFor( this, pMethodName );
1216 1131 return (zRunnable != null) ? zRunnable : createRunnableFor( mLaunchProject, pMethodName );
  @@ -1254,7 +1169,7 @@
1254 1169 }
1255 1170
1256 1171 protected void createLaunchProject() {
1257 - mLaunchProject = project( CANONICAL_USER_DIR, mArgs.get( "file", "." ) );
1172 + mLaunchProject = (ProjectFromFile) getProject( CANONICAL_USER_DIR, mArgs.get( "file", "." ) );
1258 1173 }
1259 1174
1260 1175 protected int run() {