private static void initializeDynamicJavaAssets ( ) throws DataAccessException , IOException , CachingException { logger . info ( "Initializing Dynamic Java assets for Groovy..." ) ; for ( Asset java : AssetCache . getAssets ( Asset . JAVA ) ) { Package pkg = PackageCache . getAssetPackage ( java . getId ( ) ) ; String packageName = pkg == null ? null : JavaNaming . getValidPackageName ( pkg . getName ( ) ) ; File dir = createNeededDirs ( packageName ) ; String filename = dir + "/" + java . getName ( ) ; if ( filename . endsWith ( ".java" ) ) filename = filename . substring ( 0 , filename . length ( ) - 5 ) ; filename += ".groovy" ; File file = new File ( filename ) ; logger . mdwDebug ( " - writing " + file . getAbsoluteFile ( ) ) ; if ( file . exists ( ) ) file . delete ( ) ; String content = java . getStringContent ( ) ; if ( content != null ) { if ( Compatibility . hasCodeSubstitutions ( ) ) content = doCompatibilityCodeSubstitutions ( java . getLabel ( ) , content ) ; FileWriter writer = new FileWriter ( file ) ; writer . write ( content ) ; writer . close ( ) ; } } logger . info ( "Dynamic Java assets initialized for groovy." ) ; }
so that Groovy scripts can reference these assets during compilation