use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class ShaSigner method signArtifact.
public static void signArtifact(RepositoryManager repoman, ArtifactContext context, File jarFile, Logger log) {
ArtifactContext sha1Context = context.getSha1Context();
if (sha1Context != null) {
sha1Context.setForceOperation(true);
File shaFile = sign(jarFile, log, false);
if (shaFile != null) {
try {
repoman.putArtifact(sha1Context, shaFile);
} finally {
shaFile.delete();
}
}
}
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class CeylonDocTool method makeDoc.
private void makeDoc() throws IOException {
buildNodesMaps();
if (includeSourceCode) {
copySourceFiles();
}
collectSubclasses();
collectAnnotationConstructors();
// document every module
boolean documentedOne = false;
for (Module module : modules) {
if (isEmpty(module)) {
getLogger().warning(CeylondMessages.msg("warn.moduleHasNoDeclaration", module.getNameAsString()));
} else {
documentedOne = true;
}
documentModule(module);
ArtifactContext artifactDocs = new ArtifactContext(null, module.getNameAsString(), module.getVersion(), ArtifactContext.DOCS);
// find all doc folders to copy
File outputDocFolder = getDocOutputFolder(module);
for (File docFolder : docFolders) {
File moduleDocFolder = new File(docFolder, join("/", module.getName()));
if (moduleDocFolder.exists()) {
FileUtil.copyAll(moduleDocFolder, outputDocFolder);
}
}
repositoryRemoveArtifact(outputRepositoryManager, artifactDocs);
repositoryPutArtifact(outputRepositoryManager, artifactDocs, getOutputFolder(module, null));
}
if (!documentedOne) {
getLogger().warning(CeylondMessages.msg("warn.couldNotFindAnyDeclaration"));
}
if (browse) {
for (Module module : modules) {
if (isEmpty(module)) {
continue;
}
ArtifactContext docArtifact = new ArtifactContext(null, module.getNameAsString(), module.getVersion(), ArtifactContext.DOCS);
File docFolder = outputRepositoryManager.getArtifact(docArtifact);
File docIndex = new File(docFolder, "api/index.html");
if (docIndex.isFile()) {
try {
Desktop.getDesktop().browse(docIndex.toURI());
} catch (Exception e) {
getLogger().error(CeylondMessages.msg("error.unableBrowseModuleDoc", docIndex.toURI()));
}
}
}
}
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class CeylonModuleLoader method findArtifact.
protected ArtifactResult findArtifact(ModuleIdentifier mi) {
String namespace = ModuleUtil.getNamespaceFromUri(mi.getName());
String name = ModuleUtil.getModuleNameFromUri(mi.getName());
final ArtifactContext context = new ArtifactContext(namespace, name, mi.getSlot(), ArtifactContext.CAR, ArtifactContext.JAR);
return repository.getArtifactResult(context);
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class LegacyImporter method checkDependencies.
private void checkDependencies(TreeSet<ModuleDependencyInfo> sortedDeps, Set<String> visited, boolean exported) throws Exception {
for (ModuleDependencyInfo dep : sortedDeps) {
// only do exported, or non-exported
if (exported != dep.isExport())
continue;
// skip test scope
if (dep.getModuleScope() == ModuleScope.TEST)
continue;
// skip already-visited dependencies based on name/version key
if (!visited.add(dep.getModuleName()))
continue;
feedback.beforeDependency(dep);
String name = dep.getName();
String version = dep.getVersion();
// missing dep is OK, it can be fixed later, but invalid module/dependency is not OK
if (name == null || name.isEmpty())
feedback.dependencyError(DependencyErrors.DEPERR_INVALID_MODULE_NAME, dep);
if (ModuleUtil.isDefaultModule(name))
feedback.dependencyError(DependencyErrors.DEPERR_INVALID_MODULE_DEFAULT, dep);
if (version == null || version.isEmpty())
feedback.dependencyError(DependencyErrors.DEPERR_INVALID_MODULE_VERSION, dep);
Usage usage = null;
if (jdkProvider.isJDKModule(name)) {
usage = scanner.removeMatchingJdkClasses(name);
} else {
ArtifactContext context = new ArtifactContext(dep.getNamespace(), name, version, ArtifactContext.CAR, ArtifactContext.JAR);
ArtifactResult result = lookupRepoman.getArtifactResult(context);
File artifact = result != null ? result.artifact() : null;
if (artifact != null && artifact.exists()) {
try {
Set<String> importedClasses = JarUtils.gatherClassnamesFromJar(artifact);
addTransitiveDependenciesClasses(result, importedClasses, visited, dep);
usage = scanner.removeMatchingClasses(importedClasses);
} catch (IOException e) {
feedback.dependency(DependencyResults.DEP_CHECK_FAILED, dep);
hasErrors = true;
}
} else {
if (dep.isOptional()) {
String key = ModuleUtil.makeModuleName(dep.getName(), dep.getVersion());
if (missingDependenciesPackages != null && missingDependenciesPackages.containsKey(key)) {
List<Pattern> packages = missingDependenciesPackages.get(key);
usage = scanner.removeMatchingPackages(packages);
}
}
if (usage == null) {
feedback.dependency(DependencyResults.DEP_NOT_FOUND, dep);
hasErrors = true;
}
}
}
if (usage != null) {
switch(usage) {
case Used:
if (!dep.isExport()) {
feedback.dependency(DependencyResults.DEP_OK, dep);
} else {
dep = new ModuleDependencyInfo(null, dep.getName(), dep.getVersion(), dep.isOptional(), false, dep.getNativeBackends(), dep.getModuleScope());
feedback.dependency(DependencyResults.DEP_MARK_UNSHARED, dep);
}
break;
case UsedInPublicApi:
if (dep.isExport()) {
feedback.dependency(DependencyResults.DEP_OK, dep);
} else {
dep = new ModuleDependencyInfo(null, dep.getName(), dep.getVersion(), dep.isOptional(), true, dep.getNativeBackends(), dep.getModuleScope());
feedback.dependency(DependencyResults.DEP_MARK_SHARED, dep);
hasProblems = true;
}
break;
default:
// not used at all
dep = new ModuleDependencyInfo(null, dep.getName(), dep.getVersion(), dep.isOptional(), false, dep.getNativeBackends(), dep.getModuleScope());
feedback.dependency(DependencyResults.DEP_OK_UNUSED, dep);
}
}
feedback.afterDependency(dep);
expectedDependencies.add(dep);
}
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class LazyArtifactResult method getDelegate.
private synchronized ArtifactResult getDelegate() {
if (delegate == null) {
final ArtifactContext context = new ArtifactContext(null, name(), version(), ArtifactContext.CAR, ArtifactContext.JAR);
context.setThrowErrorIfMissing(!optional);
delegate = manager.getArtifactResult(context);
}
return delegate;
}
Aggregations