예제 #1
0
 private void addResources() throws Abort {
   HashSet<String> written = new HashSet<String>();
   try {
     for (JavaFileObject fo : resourceFileObjects) {
       CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
       String jarFileName =
           JarUtils.toPlatformIndependentPath(
               dfm.getLocation(CeylonLocation.RESOURCE_PATH), fo.getName());
       if (!written.contains(jarFileName)) {
         dfm.setModule(modelLoader.findModuleForFile(new File(jarFileName)));
         FileObject outFile =
             dfm.getFileForOutput(StandardLocation.CLASS_OUTPUT, "", jarFileName, null);
         OutputStream out = outFile.openOutputStream();
         try {
           InputStream in = new FileInputStream(new File(fo.getName()));
           try {
             JarUtils.copy(in, out);
           } finally {
             in.close();
           }
         } finally {
           out.close();
         }
         written.add(jarFileName);
       }
     }
   } catch (IOException ex) {
     throw new Abort(ex);
   }
 }
예제 #2
0
 @Override
 public void initProcessAnnotations(Iterable<? extends Processor> processors) {
   java.util.List<String> aptModules = options.getMulti(Option.CEYLONAPT);
   if (aptModules != null) {
     CeyloncFileManager dfm = (CeyloncFileManager) fileManager;
     RepositoryManager repositoryManager = dfm.getRepositoryManager();
     final Set<ModuleSpec> visited = new HashSet<>();
     StatusPrinterAptProgressListener progressListener = null;
     if (sp != null) {
       progressListener =
           new StatusPrinterAptProgressListener(sp) {
             @Override
             protected long getNumberOfModulesResolved() {
               return visited.size();
             }
           };
       sp.clearLine();
       sp.log("Starting APT resolving");
     }
     for (String aptModule : aptModules) {
       ModuleSpec moduleSpec = ModuleSpec.parse(aptModule);
       addDependenciesToAptPath(repositoryManager, moduleSpec, visited, progressListener);
     }
     if (sp != null) {
       sp.clearLine();
       sp.log("Done APT resolving");
     }
     // we only run APT if asked explicitly with the --apt flag
     super.initProcessAnnotations(processors);
   }
   // else don't do anything, which will leave the "processAnnotations" field to false
 }
예제 #3
0
 /** Get the Ceylon context instance for this context. */
 public static com.redhat.ceylon.compiler.typechecker.context.Context getCeylonContextInstance(
     Context context) {
   com.redhat.ceylon.compiler.typechecker.context.Context ceylonContext =
       context.get(ceylonContextKey);
   if (ceylonContext == null) {
     CeyloncFileManager fileManager = (CeyloncFileManager) context.get(JavaFileManager.class);
     VFS vfs = new VFS();
     ceylonContext =
         new com.redhat.ceylon.compiler.typechecker.context.Context(
             fileManager.getRepositoryManager(), vfs);
     context.put(ceylonContextKey, ceylonContext);
   }
   return ceylonContext;
 }