*/
private static DependenciesManager createDependencyManager( MetaModel metaModel ) {
long start = System.currentTimeMillis();
DependenciesManager depMgr = createInstance();
DependenciesPackage componentScripts = depMgr.getPackage( StdPackages.COMPONENT_DEF_SCRIPTS );
DependenciesPackage componentSnippets = depMgr.getPackage( StdPackages.COMPONENT_SNIPPETS );
DependenciesPackage componentStyles = depMgr.getPackage( StdPackages.COMPONENT_STYLES );
DependenciesPackage ddScripts = depMgr.getPackage( StdPackages.CDFDD );
for ( ComponentType compType : metaModel.getComponentTypes() ) {
// General Resources
for ( Resource res : compType.getResources() ) {
Resource.Type resType = res.getType();
if ( resType == Resource.Type.RAW ) {
try {
componentSnippets.registerRawDependency( res.getName(), res.getVersion(), res.getSource() );
} catch ( Exception ex ) {
logger.error( "Failed to register code fragment '" + res.getSource() + "'" );
}
} else {
DependenciesPackage pack = null;
if ( resType == Resource.Type.SCRIPT ) {
String app = res.getApp();
if ( StringUtils.isEmpty( app ) || app.equals( StdPackages.COMPONENT_DEF_SCRIPTS ) ) {
pack = componentScripts;
} else if ( app.equals( StdPackages.CDFDD ) ) {
pack = ddScripts;
}
} else if ( resType == Resource.Type.STYLE ) {
pack = componentStyles;
}
if ( pack != null ) {
try {
pack.registerFileDependency( res.getName(), res.getVersion(), res.getOrigin(), res.getSource() );
} catch ( Exception ex ) {
logger.error( "Failed to register dependency '" + res.getSource() + "'" );
}
}
}
}
// Implementation
PathOrigin origin = compType.getOrigin();
String srcImpl = compType.getImplementationPath();
if ( StringUtils.isNotEmpty( srcImpl ) ) {
try {
componentScripts.registerFileDependency( compType.getName(), compType.getVersion(), origin, srcImpl );
} catch ( Exception e ) {
logger.error( "Failed to register dependency '" + srcImpl + "'" );
}
}
}
//read resources/include.properties
Properties extraProps = new Properties();
try {
InputStream in = null;
try {
in = CdeEnvironment.getPluginSystemReader().getFileInputStream( EXTRA_INCLUDES_PROP );
extraProps.load( in );
} finally {
IOUtils.closeQuietly( in );
}
PathOrigin origin = new StaticSystemOrigin( "" );
DependenciesPackage scripts = depMgr.getPackage( StdPackages.COMPONENT_DEF_SCRIPTS );
if ( extraProps.containsKey( "scripts" ) ) {
for ( String path : extraProps.get( "scripts" ).toString().split( "," ) ) {
if ( !path.isEmpty() ) {
scripts.registerFileDependency( path, null, origin, path );
}
}
}
DependenciesPackage styles = depMgr.getPackage( StdPackages.COMPONENT_STYLES );
if ( extraProps.containsKey( "styles" ) ) {
for ( String path : extraProps.get( "styles" ).toString().split( "," ) ) {
if ( !path.isEmpty() ) {
styles.registerFileDependency( path, null, origin, path );
}
}
}
} catch ( IOException e ) {
logger.error( "Error attempting to read " + EXTRA_INCLUDES_PROP, e );