private void addDependenciesToAptPath( RepositoryManager repositoryManager, ModuleSpec moduleSpec, Set<ModuleSpec> visited, StatusPrinterAptProgressListener progressListener) { if (!visited.add(moduleSpec)) return; String ns = ModuleUtil.getNamespaceFromUri(moduleSpec.getName()); String name = ModuleUtil.getModuleNameFromUri(moduleSpec.getName()); ArtifactContext context = new ArtifactContext( ns, name, moduleSpec.getVersion(), ArtifactContext.JAR, ArtifactContext.CAR); if (progressListener != null) progressListener.retrievingModuleArtifact(moduleSpec, context); ArtifactResult result = repositoryManager.getArtifactResult(context); if (progressListener != null) { if (result == null) { progressListener.retrievingModuleArtifactFailed(moduleSpec, context); } else { progressListener.retrievingModuleArtifactSuccess(moduleSpec, result); } } ceylonEnter.addModuleToAptPath(moduleSpec, result); for (ArtifactResult dep : result.dependencies()) { if (JDKUtils.isJDKModule(dep.name()) || JDKUtils.isOracleJDKModule(dep.name())) { continue; } // we are running deps, so we need compile/provided/runtime, but not test if (dep.moduleScope() == ModuleScope.TEST) continue; ModuleSpec depSpec = new ModuleSpec(dep.namespace(), dep.name(), dep.version()); addDependenciesToAptPath(repositoryManager, depSpec, visited, progressListener); } }
@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 }