public static ProjectValidationResult validateProject( File appDirectory, boolean isRecipe ) {

		// Load and validate the application
		ApplicationLoadResult alr;
		if( isRecipe ) {
			alr = RuntimeModelIo.loadApplicationFlexibly( appDirectory );
		} else {
			alr = RuntimeModelIo.loadApplication( appDirectory );
		}

		// Then, search for all the graph files and validate them
		File dir = new File( appDirectory, Constants.PROJECT_DIR_GRAPH );
		if( dir.exists()) {
			for( File f : Utils.listAllFiles( dir, Constants.FILE_EXT_GRAPH )) {
				RuntimeModelIo.loadGraph( f, dir, alr );
			}
		}

		// Eventually, search for all the instance files and validate them
		dir = new File( appDirectory, Constants.PROJECT_DIR_INSTANCES );
		if( dir.exists()
				&& alr.getApplicationTemplate().getGraphs() != null ) {

			for( File f : Utils.listAllFiles( dir, Constants.FILE_EXT_INSTANCES )) {
				InstancesLoadResult ilr = RuntimeModelIo.loadInstances( f, dir, alr.getApplicationTemplate().getGraphs(), null );
				alr.getObjectToSource().putAll( ilr.getObjectToSource());
				alr.getLoadErrors().addAll( ilr.getLoadErrors());
			}
		}

		// Recipe? Filter some errors.
		if( isRecipe ) {
			RoboconfErrorHelpers.filterErrorsForRecipes( alr );
		}

		// Now, remove duplicate errors and resolve locations
		Collection<RoboconfError> errors = new HashSet<> ();
		errors.addAll( RoboconfErrorHelpers.resolveErrorsWithLocation( alr ));

		// Do not show errors in tooling when the project version looks like "${project.version}"
		// Only valid if the project is a Maven one.
		String path = appDirectory.getAbsolutePath().replaceAll( "\\\\", "/" );
		if( ! path.endsWith( "/" ) && Constants.MAVEN_SRC_MAIN_MODEL.endsWith( "/" ))
			path += "/";

		if( path.endsWith( Constants.MAVEN_SRC_MAIN_MODEL )
				&& new File( appDirectory, "../../../pom.xml" ).exists()) {

			List<RoboconfError> errorsToRemove = new ArrayList<> ();
			for( RoboconfError error : errors ) {

				// We ignore this error if it looks like a Maven property.
				if( error.getErrorCode() == ErrorCode.RM_INVALID_APPLICATION_VERSION
						&& error.getDetails().length > 0
						&& error.getDetails()[ 0 ].getElementName().matches( "^\\$\\{.*\\}\\S*" )) {

					errorsToRemove.add( error );
				}
			}

			errors.removeAll( errorsToRemove );
		}

		// Eventually, sort everything
		List<RoboconfError> errorsList = new ArrayList<>( errors );
		Collections.sort( errorsList, new RoboconfErrorComparator());

		return new ProjectValidationResult( errorsList, alr, isRecipe );
	}
public static ProjectValidationResult validateProject ( File appDirectory , boolean isRecipe ) { ApplicationLoadResult alr ; if ( isRecipe ) { alr = RuntimeModelIo . loadApplicationFlexibly ( appDirectory ) ; } else { alr = RuntimeModelIo . loadApplication ( appDirectory ) ; } File dir = new File ( appDirectory , Constants . PROJECT_DIR_GRAPH ) ; if ( dir . exists ( ) ) { for ( File f : Utils . listAllFiles ( dir , Constants . FILE_EXT_GRAPH ) ) { RuntimeModelIo . loadGraph ( f , dir , alr ) ; } } dir = new File ( appDirectory , Constants . PROJECT_DIR_INSTANCES ) ; if ( dir . exists ( ) && alr . getApplicationTemplate ( ) . getGraphs ( ) != null ) { for ( File f : Utils . listAllFiles ( dir , Constants . FILE_EXT_INSTANCES ) ) { InstancesLoadResult ilr = RuntimeModelIo . loadInstances ( f , dir , alr . getApplicationTemplate ( ) . getGraphs ( ) , null ) ; alr . getObjectToSource ( ) . putAll ( ilr . getObjectToSource ( ) ) ; alr . getLoadErrors ( ) . addAll ( ilr . getLoadErrors ( ) ) ; } } if ( isRecipe ) { RoboconfErrorHelpers . filterErrorsForRecipes ( alr ) ; } Collection < RoboconfError > errors = new HashSet < > ( ) ; errors . addAll ( RoboconfErrorHelpers . resolveErrorsWithLocation ( alr ) ) ; String path = appDirectory . getAbsolutePath ( ) . replaceAll ( "\\\\" , "/" ) ; if ( ! path . endsWith ( "/" ) && Constants . MAVEN_SRC_MAIN_MODEL . endsWith ( "/" ) ) path += "/" ; if ( path . endsWith ( Constants . MAVEN_SRC_MAIN_MODEL ) && new File ( appDirectory , "../../../pom.xml" ) . exists ( ) ) { List < RoboconfError > errorsToRemove = new ArrayList < > ( ) ; for ( RoboconfError error : errors ) { if ( error . getErrorCode ( ) == ErrorCode . RM_INVALID_APPLICATION_VERSION && error . getDetails ( ) . length > 0 && error . getDetails ( ) [ 0 ] . getElementName ( ) . matches ( "^\\$\\{.*\\}\\S*" ) ) { errorsToRemove . add ( error ) ; } } errors . removeAll ( errorsToRemove ) ; } List < RoboconfError > errorsList = new ArrayList < > ( errors ) ; Collections . sort ( errorsList , new RoboconfErrorComparator ( ) ) ; return new ProjectValidationResult ( errorsList , alr , isRecipe ) ; }
Validates a project.
<p>
It first tries to load it as a Roboconf project.
Then, it validates all the files within the project, even those
that are not reachable from the project descriptor.
</p>

@param appDirectory the application's directory (must exist)
@param isRecipe true if the project is a reusable recipe
@return a non-null list of errors, with the resolved location (sorted by error code)