use of org.eclipse.ceylon.model.cmr.RepositoryException in project ceylon by eclipse.
the class CeylonMavenExportTool method makeMavenModule.
protected void makeMavenModule(Module module, File outputFolder, Set<String> directImports) {
String groupId = module.artifact.groupId();
String artifactId = module.artifact.artifactId();
String path = groupId.replace('.', '/') + "/" + artifactId + "/" + module.version;
File folder = new File(outputFolder, path);
FileUtil.mkdirs(folder);
String mavenFileName = artifactId + "-" + module.version;
try {
File jarFile = new File(folder, mavenFileName + ".jar");
File pomFile = new File(folder, mavenFileName + ".pom");
Files.copy(module.artifact.artifact().toPath(), jarFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
// extract its pom.xml too
try (ZipFile zf = new ZipFile(module.artifact.artifact())) {
ZipEntry pomEntry = zf.getEntry("META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml");
if (pomEntry != null) {
try (InputStream is = zf.getInputStream(pomEntry)) {
Files.copy(is, pomFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
} else {
generatePomFromModule(pomFile, module.artifact, directImports);
}
}
// now sha1 them
ShaSigner.sign(jarFile, null, false);
ShaSigner.sign(pomFile, null, false);
} catch (RepositoryException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.eclipse.ceylon.model.cmr.RepositoryException in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method putArtifact.
public void putArtifact(ArtifactContext context, InputStream content) throws RepositoryException {
try {
final Node parent = getOrCreateParent(context);
log.debug("Adding artifact " + context + " to cache " + cache.getDisplayString());
log.debug(" -> " + NodeUtils.getFullPath(parent));
final String[] names = cache.getArtifactNames(context);
if (names.length != 1) {
throw new RepositoryException("ArtifactContext should have a single suffix");
}
final String label = names[0];
try {
if (parent instanceof OpenNode) {
final OpenNode on = (OpenNode) parent;
if (on.addContent(label, content, context) == null)
addContent(context, parent, label, content);
} else {
addContent(context, parent, label, content);
}
} catch (IOException e) {
throw new RepositoryException(e);
}
log.debug(" -> [done]");
} finally {
IOUtils.safeClose(content);
}
}
use of org.eclipse.ceylon.model.cmr.RepositoryException in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method downloadZipped.
private ArtifactResult downloadZipped(Node node, ArtifactContext context) {
ArtifactContext zippedContext = context.getZipContext();
ArtifactResult zipResult = getArtifactResult(zippedContext);
if (zipResult != null) {
String zipName = zipResult.artifact().getName();
File unzippedFolder = new File(zipResult.artifact().getParentFile(), zipName.substring(0, zipName.length() - 4));
try {
IOUtils.extractArchive(zipResult.artifact(), unzippedFolder);
} catch (IOException e) {
throw new RepositoryException("Failed to unzip folder downloaded from Herd: " + zipResult.artifact(), e);
}
return new FileArtifactResult(zipResult.repository(), this, zipResult.name(), zipResult.version(), unzippedFolder, zipResult.repositoryDisplayString());
} else {
return null;
}
}
use of org.eclipse.ceylon.model.cmr.RepositoryException in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method isSameFile.
// Check if the source file and destination node point to the same file
@Override
public boolean isSameFile(ArtifactContext context, File srcFile) throws RepositoryException {
boolean same = false;
if (!cache.getRoot().isRemote()) {
Node dstParent = getOrCreateParent(context);
Node newChild = dstParent.getChild(srcFile.getName());
if (newChild != null) {
try {
File existing = newChild.getContent(File.class);
same = FileUtil.sameFile(srcFile, existing);
} catch (IOException e) {
throw new RepositoryException(e);
}
}
}
return same;
}
use of org.eclipse.ceylon.model.cmr.RepositoryException in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method removeArtifact.
public void removeArtifact(ArtifactContext context) throws RepositoryException {
Node parent = getFromCacheNode(context, false);
log.debug("Remove artifact " + context + " to repository " + cache.getDisplayString());
if (parent != null) {
final String[] labels = cache.getArtifactNames(context);
for (String label : labels) {
try {
removeNode(parent, label);
} catch (IOException e) {
throw new RepositoryException(e);
}
}
log.debug(" -> [done]");
} else {
log.debug(" -> No such artifact: " + context);
}
}
Aggregations