Skip to content

Commit

Permalink
Latest bnd sync
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1370165 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Stuart McCulloch committed Aug 7, 2012
1 parent 5e1031a commit 55d4dfe
Show file tree
Hide file tree
Showing 88 changed files with 695 additions and 272 deletions.
3 changes: 3 additions & 0 deletions bundleplugin/src/main/java/aQute/bnd/build/Container.java
Expand Up @@ -103,12 +103,14 @@ public String getError() {
return error;
}

@Override
public boolean equals(Object other) {
if (other instanceof Container)
return file.equals(((Container) other).file);
return false;
}

@Override
public int hashCode() {
return file.hashCode();
}
Expand All @@ -122,6 +124,7 @@ public Project getProject() {
*
* @return
*/
@Override
public String toString() {
if (getError() != null)
return "/error/" + getError();
Expand Down
79 changes: 40 additions & 39 deletions bundleplugin/src/main/java/aQute/bnd/build/Project.java
Expand Up @@ -14,6 +14,7 @@
import aQute.bnd.osgi.*;
import aQute.bnd.osgi.eclipse.*;
import aQute.bnd.service.*;
import aQute.bnd.service.RepositoryPlugin.PutResult;
import aQute.bnd.service.RepositoryPlugin.Strategy;
import aQute.bnd.service.action.*;
import aQute.bnd.version.*;
Expand Down Expand Up @@ -146,6 +147,7 @@ public Workspace getWorkspace() {
return workspace;
}

@Override
public String toString() {
return getBase().getName();
}
Expand Down Expand Up @@ -202,7 +204,9 @@ public synchronized void prepare() throws Exception {
// Set default bin directory
output = getOutput0();
if (!output.exists()) {
output.mkdirs();
if (!output.mkdirs()) {
throw new IOException("Could not create directory " + output);
}
getWorkspace().changedFile(output);
}
if (!output.isDirectory())
Expand Down Expand Up @@ -296,10 +300,12 @@ private File getOutput0() {
/**
*
*/
private File getTarget0() {
private File getTarget0() throws IOException {
File target = getFile(getProperty("target", "generated"));
if (!target.exists()) {
target.mkdirs();
if (!target.mkdirs()) {
throw new IOException("Could not create directory " + target);
}
getWorkspace().changedFile(target);
}
return target;
Expand Down Expand Up @@ -809,27 +815,29 @@ private String list(String[] args, Collection< ? > list) {
return join(list, separator);
}

@Override
protected Object[] getMacroDomains() {
return new Object[] {
workspace
};
}

public File release(Jar jar) throws Exception {
public File release(String jarName, InputStream jarStream) throws Exception {
String name = getProperty(Constants.RELEASEREPO);
return release(name, jar);
return release(name, jarName, jarStream);
}

/**
* Release
*
* @param name
* The repository name
* @param jar
* @param jarName
* @param jarStream
* @return
* @throws Exception
*/
public File release(String name, Jar jar) throws Exception {
public File release(String name, String jarName, InputStream jarStream) throws Exception {
trace("release %s", name);
List<RepositoryPlugin> plugins = getPlugins(RepositoryPlugin.class);
RepositoryPlugin rp = null;
Expand All @@ -848,14 +856,11 @@ public File release(String name, Jar jar) throws Exception {

if (rp != null) {
try {
File file = rp.put(jar);
trace("Released %s to file %s in repository %s", jar.getName(), file, rp);
PutResult r = rp.put(jarStream, new RepositoryPlugin.PutOptions());
trace("Released %s to %s in repository %s", jarName, r.artifact, rp);
}
catch (Exception e) {
msgs.Release_Into_Exception_(jar, rp, e);
}
finally {
jar.close();
msgs.Release_Into_Exception_(jarName, rp, e);
}
} else if (name == null)
msgs.NoNameForReleaseRepository();
Expand Down Expand Up @@ -890,15 +895,8 @@ public void release(String name, boolean test) throws Exception {
}
trace("build ", Arrays.toString(jars));
for (File jar : jars) {
Jar j = new Jar(jar);
try {
release(name, j);
}
finally {
j.close();
}
release(name, jar.getName(), new BufferedInputStream(new FileInputStream(jar)));
}

}

/**
Expand Down Expand Up @@ -1114,17 +1112,13 @@ public void deploy(String name, File file) throws Exception {
}

if (rp != null) {
Jar jar = new Jar(file);
try {
rp.put(jar);
rp.put(new BufferedInputStream(new FileInputStream(file)), new RepositoryPlugin.PutOptions());
return;
}
catch (Exception e) {
msgs.DeployingFile_On_Exception_(file, rp.getName(), e);
}
finally {
jar.close();
}
return;
}
trace("No repo found " + file);
Expand Down Expand Up @@ -1155,22 +1149,16 @@ public void deploy() throws Exception {
}
File[] outputs = getBuildFiles();
for (File output : outputs) {
Jar jar = new Jar(output);
try {
for (Deploy d : getPlugins(Deploy.class)) {
trace("Deploying %s to: %s", jar, d);
trace("Deploying %s to: %s", output.getName(), d);
try {
if (d.deploy(this, jar))
if (d.deploy(this, output.getName(), new BufferedInputStream(new FileInputStream(output))))
trace("deployed %s successfully to %s", output, d);
}
catch (Exception e) {
msgs.Deploying(e);
}
}
}
finally {
jar.close();
}
}
}

Expand Down Expand Up @@ -1452,8 +1440,12 @@ public File saveBuild(Jar jar) throws Exception {
if (!f.exists() || f.lastModified() < jar.lastModified()) {
reportNewer(f.lastModified(), jar);
f.delete();
if (!f.getParentFile().isDirectory())
f.getParentFile().mkdirs();
File fp = f.getParentFile();
if (!fp.isDirectory()) {
if (!fp.exists() && !fp.mkdirs()) {
throw new IOException("Could not create directory " + fp);
}
}
jar.write(f);

getWorkspace().changedFile(f);
Expand Down Expand Up @@ -1491,6 +1483,7 @@ private void reportNewer(long lastModified, Jar jar) {
/**
* Refresh if we are based on stale data. This also implies our workspace.
*/
@Override
public boolean refresh() {
boolean changed = false;
if (isCnf()) {
Expand All @@ -1503,6 +1496,7 @@ public boolean isCnf() {
return getBase().getName().equals(Workspace.CNFDIR);
}

@Override
public void propertiesChanged() {
super.propertiesChanged();
preparedPaths = false;
Expand Down Expand Up @@ -1568,12 +1562,16 @@ public void clean() throws Exception {
File target = getTarget0();
if (target.isDirectory() && target.getParentFile() != null) {
IO.delete(target);
target.mkdirs();
if (!target.exists() && !target.mkdirs()) {
throw new IOException("Could not create directory " + target);
}
}
File output = getOutput0();
if (getOutput().isDirectory())
IO.delete(output);
output.mkdirs();
if (!output.exists() && !output.mkdirs()) {
throw new IOException("Could not create directory " + output);
}
}

public File[] build() throws Exception {
Expand Down Expand Up @@ -2052,7 +2050,10 @@ void updatePackageInfoFile(String packageName, Version newVersion) throws Except

String path = packageName.replace('.', '/') + "/packageinfo";
File binary = IO.getFile(getOutput(), path);
binary.getParentFile().mkdirs();
File bp = binary.getParentFile();
if (!bp.exists() && !bp.mkdirs()) {
throw new IOException("Could not create directory " + bp);
}
IO.copy(file, binary);

refresh();
Expand Down
Expand Up @@ -27,12 +27,14 @@ public long lastModified() {
/**
* We put our project and our workspace on the macro path.
*/
@Override
protected Object[] getMacroDomains() {
return new Object[] {
project, project.getWorkspace()
};
}

@Override
public Builder getSubBuilder() throws Exception {
return project.getBuilder(this);
}
Expand All @@ -41,6 +43,7 @@ public Project getProject() {
return project;
}

@Override
public void init() {
try {
if (!initialized) {
Expand Down Expand Up @@ -68,6 +71,7 @@ public void init() {
}
}

@Override
public List<Jar> getClasspath() {
init();
return super.getClasspath();
Expand Down
Expand Up @@ -3,7 +3,6 @@
import java.io.*;
import java.util.*;

import aQute.bnd.osgi.*;
import aQute.bnd.service.*;
import aQute.bnd.service.RepositoryPlugin.Strategy;
import aQute.bnd.version.*;
Expand Down Expand Up @@ -39,7 +38,7 @@ public interface ProjectMessages extends Messages {

ERROR ReleaseRepository_NotFoundIn_(String name, List<RepositoryPlugin> plugins);

ERROR Release_Into_Exception_(Jar jar, RepositoryPlugin rp, Exception e);
ERROR Release_Into_Exception_(String jar, RepositoryPlugin rp, Exception e);

ERROR NoScripters_(String script);

Expand Down
Expand Up @@ -63,7 +63,9 @@ public void setContinuous(boolean b) {
}

public boolean prepare() throws Exception {
reportDir.mkdirs();
if (!reportDir.exists() && !reportDir.mkdirs()) {
throw new IOException("Could not create directory " + reportDir);
}
for (File file : reportDir.listFiles()) {
file.delete();
}
Expand Down
Expand Up @@ -16,6 +16,7 @@ public void execute(Project project, String action) throws Exception {
m.invoke(project);
}

@Override
public String toString() {
return "ra:" + what;
}
Expand Down
18 changes: 14 additions & 4 deletions bundleplugin/src/main/java/aQute/bnd/build/Workspace.java
Expand Up @@ -81,7 +81,9 @@ public static Workspace getWorkspace(File parent) throws Exception {

public Workspace(File dir) throws Exception {
dir = dir.getAbsoluteFile();
dir.mkdirs();
if (!dir.exists() && !dir.mkdirs()) {
throw new IOException("Could not create directory " + dir);
}
assert dir.isDirectory();

File buildDir = new File(dir, BNDDIR).getAbsoluteFile();
Expand Down Expand Up @@ -123,6 +125,7 @@ public Collection<Project> getCurrentProjects() {
return models.values();
}

@Override
public boolean refresh() {
if (super.refresh()) {
for (Project project : getCurrentProjects()) {
Expand Down Expand Up @@ -261,19 +264,23 @@ class CachedFileRepo extends FileRepo {
super("cache", getFile(buildDir, CACHEDIR), false);
}

@Override
public String toString() {
return "bnd-cache";
}

@Override
protected void init() throws Exception {
if (lock.tryLock(50, TimeUnit.SECONDS) == false)
throw new TimeLimitExceededException("Cached File Repo is locked and can't acquire it");
try {
if (!inited) {
inited = true;
root.mkdirs();
if (!root.exists() && !root.mkdirs()) {
throw new IOException("Could not create cache directory " + root);
}
if (!root.isDirectory())
throw new IllegalArgumentException("Cannot create cache dir " + root);
throw new IllegalArgumentException("Cache directory " + root + " not a directory");

InputStream in = getClass().getResourceAsStream(EMBEDDED_REPO);
if (in != null)
Expand All @@ -296,7 +303,10 @@ void unzip(InputStream in, File dir) throws Exception {
if (!jentry.isDirectory()) {
File dest = Processor.getFile(dir, jentry.getName());
if (!dest.isFile() || dest.lastModified() < jentry.getTime() || jentry.getTime() == 0) {
dest.getParentFile().mkdirs();
File dp = dest.getParentFile();
if (!dp.exists() && !dp.mkdirs()) {
throw new IOException("Could not create directory " + dp);
}
FileOutputStream out = new FileOutputStream(dest);
try {
copy(jin, out);
Expand Down
Expand Up @@ -86,7 +86,7 @@ public boolean canWrite() {
return false;
}

public File put(Jar jar) throws Exception {
public PutResult put(InputStream stream, PutOptions options) throws Exception {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion bundleplugin/src/main/java/aQute/bnd/build/packageinfo
@@ -1 +1 @@
version 1.45.0
version 2.0.0
Expand Up @@ -19,6 +19,7 @@ public static Access modifier(int mod) {
return PACKAGE;
}

@Override
public String toString() {
return super.toString().toLowerCase();
}
Expand Down
Expand Up @@ -13,6 +13,7 @@ public GenericParameter(String name, GenericType[] bounds) {
};
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(name);
Expand Down
Expand Up @@ -6,6 +6,7 @@
public enum Kind {
ROOT, CLASS, FIELD, CONSTRUCTOR, METHOD, UNKNOWN;

@Override
public String toString() {
return super.toString().toLowerCase();
}
Expand Down

0 comments on commit 55d4dfe

Please sign in to comment.