Skip to content

Commit

Permalink
Merge branch 'master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
pkriens committed Mar 21, 2011
2 parents 67268e7 + ee180e6 commit cd4c24d
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 136 deletions.
47 changes: 45 additions & 2 deletions README
Expand Up @@ -3,17 +3,32 @@ bnd is a swiss army knife for OSGi, it creates manifest headers for you based on
analyzing the class code, it verifies your settings, it manages project dependencies,
gives you quote of the day, diffs jars, and much more.

The information about bnd can be found at http://www.aQute.biz/Bnd

Repository
The git repository contains all code. It contains the following projects:

1) bndlib - Core library function, also contains most tests
2) bnd - Command line tool, eclipse plugin, and ant plugin
3) launcher - A launcher plugin for bnd
4) libg - Small simple library utilities that are useful outside bnd
4) libg - Small, simple library utilities that are useful outside bnd
5) junit - A tester plugin for JUnit 3.8 testing for bnd
6) cnf - The bnd project directory, contains the repo with dependencies
7) demo - A project used in testing
8) compiler - A wrapped version of the eclipse java compiler

API
All code is Apache 2.0 Licensed so you can do what you want with the source code.
though I am usually pretty good at backward compatibility, there is no guarantee. This
is an unpaid project and one of the most annoying thing of work is being backward compatible
on the Java API when you know a better way to do it. Properties will be backward compatible
if there is any possibility. So be aware, its ok to use this package but do not complain
if new releases require some work.

If you're building a tool with a general audience, e.g. bndtools, that includes bnd
for a general audience I would appreciate if you got in touch with me so I can keep
in touch. I am always interested in ideas.

Eclipse
bnd is build with itself, which can create some headaches. Overall, you want
to your work therefore in Eclipse with a recent bnd.jar in the Eclipse dropins
Expand All @@ -37,5 +52,33 @@ ant junit - Run standard JUnit tests in the test package
Outputs are stored in the tmp directory in the different projects.

Testing
The main tests are in the bndlib project. These are standard JUnit tests.
The main tests are in the bndlib project. These are standard JUnit tests. They
are all in the src/test directory. Tests are quite extensive and run from the
Eclipse JUnit screen.

Release
The current release process could use some work. The following steps are used:

1) Changes to the tree are made on the next branch
2) After the next branch is done, commit all changes. There are a few
files changed by tests that should not be committed every time:
# biz.aQute.bndlib/test/ws/p1/bnd.bnd
# biz.aQute.bndlib/test/ws/p1/bnd.bnd.bak
# biz.aQute.bndlib/test/ws/p3/generated/p3.jar
This needs fixing btw. The test should not touch those files or at least restore
3) Switch to master
4) ant clean build
5) run the tests
6) if successful, release the jars
7) bump the version (bnd bump command does this)
8) switch to next branch

This process is likely to change because it contains too many manual steps

Feedback
Feedback is always welcome, for general discussions use bndtools-users@googlegroups.com
Bugs and issues should go to https://github.com/bnd/bnd
Other feedback or specific functionality send to Peter.Kriens@aQute.biz

Donations should go to http://pledgie.com/campaigns/10548

7 changes: 7 additions & 0 deletions aQute.libg/README
@@ -0,0 +1,7 @@
This is a project that contains lots of small utilties, each in their own package. This
library is intended to be used with the bnd Conditinal-Package header. This header
will include all packages in a given namespace. Just put the JAR of this project on
your claspath and then:

Conditional-Package: aQute.lib.*, aQute.libg.*

7 changes: 7 additions & 0 deletions biz.aQute.bnd/README
@@ -0,0 +1,7 @@
The bnd project creates a Jar that has the following functions:

- Command line utility (has a Main-Class)
- An Eclipse plugin (this will be replaced soon with bndtools)
- An ant plugin


73 changes: 36 additions & 37 deletions biz.aQute.bnd/src/aQute/bnd/main/bnd.java
Expand Up @@ -223,8 +223,8 @@ boolean doFiles(String args[], int i) throws Exception {
while (i < args.length) {
String path = args[i];
if (path.endsWith(Constants.DEFAULT_BND_EXTENSION))
doBuild(getFile(path), new File[0], new File[0], null, "", new File(path)
.getParentFile(), 0, new HashSet<File>());
doBuild(getFile(path), new File[0], new File[0], null, "",
new File(path).getParentFile(), 0, new HashSet<File>());
else if (path.endsWith(Constants.DEFAULT_JAR_EXTENSION)
|| path.endsWith(Constants.DEFAULT_BAR_EXTENSION))
doPrint(path, -1);
Expand All @@ -239,31 +239,30 @@ else if (path.endsWith(Constants.DEFAULT_BNDRUN_EXTENSION))

private void doRun(String path) throws Exception {
File file = getFile(path);
if ( ! file.isFile())
if (!file.isFile())
throw new FileNotFoundException(path);



File projectDir = file.getParentFile();
File workspaceDir = projectDir.getParentFile();
if ( workspaceDir == null ) {
if (workspaceDir == null) {
workspaceDir = new File(System.getProperty("user.home") + File.separator + ".bnd");
}
Workspace ws = Workspace.getWorkspace(workspaceDir);
File bndbnd = new File( projectDir,Project.BNDFILE);

File bndbnd = new File(projectDir, Project.BNDFILE);
Project project;
if ( bndbnd.isFile()) {
if (bndbnd.isFile()) {
project = new Project(ws, projectDir, bndbnd);
project.doIncludeFile(file, true, project.getProperties());
} else
project = new Project(ws,projectDir, file);
project = new Project(ws, projectDir, file);

project.setTrace(isTrace());
project.setPedantic(isPedantic());
try {
project.run();
} catch( Exception e ) {

} catch (Exception e) {
error("Failed to run %s: %s", project, e);
}
getInfo(project);
Expand All @@ -285,8 +284,7 @@ else if (mask.equalsIgnoreCase("minor"))
else if (mask.equalsIgnoreCase("micro"))
mask = "==+";
else if (!mask.matches("(+=0){1,3}")) {
error(
"Invalid mask for version bump %s, is (minor|major|micro|<mask>), see $version for mask",
error("Invalid mask for version bump %s, is (minor|major|micro|<mask>), see $version for mask",
mask);
return;
}
Expand Down Expand Up @@ -449,8 +447,8 @@ private void deliverables(String[] args, int i) throws Exception {

for (Container c : containers) {
Version v = new Version(c.getVersion());
System.out.printf("%-40s %d.%d.%d %s\n", c.getBundleSymbolicName(), v.getMajor(), v
.getMinor(), v.getMicro(), c.getFile());
System.out.printf("%-40s %d.%d.%d %s\n", c.getBundleSymbolicName(), v.getMajor(),
v.getMinor(), v.getMicro(), c.getFile());
}

}
Expand Down Expand Up @@ -773,8 +771,7 @@ private void doHelp() {

private void doHelp(String[] args, int i) {
if (args.length <= i) {
out
.println("bnd -failok? -exceptions? ( wrap | print | build | eclipse | xref | view )?");
out.println("bnd -failok? -exceptions? ( wrap | print | build | eclipse | xref | view )?");
out.println("See http://www.aQute.biz/Code/Bnd");
} else {
while (args.length > i) {
Expand All @@ -783,8 +780,7 @@ private void doHelp(String[] args, int i) {
} else if ("print".equals(args[i])) {
out.println("bnd wrap -verify? -manifest? -list? -eclipse <jar-file>");
} else if ("build".equals(args[i])) {
out
.println("bnd build (-output <file|dir>)? (-classpath <list>)? (-sourcepath <list>)? ");
out.println("bnd build (-output <file|dir>)? (-classpath <list>)? (-sourcepath <list>)? ");
out.println(" -eclipse? -noeclipse? -sources? <bnd-file>");
} else if ("eclipse".equals(args[i])) {
out.println("bnd eclipse");
Expand Down Expand Up @@ -1008,7 +1004,8 @@ private void printComponents(PrintStream out, Jar jar) throws Exception {

Resource r = jar.getResource(path);
if (r != null) {
InputStreamReader ir = new InputStreamReader(r.openInputStream(), Constants.DEFAULT_CHARSET);
InputStreamReader ir = new InputStreamReader(r.openInputStream(),
Constants.DEFAULT_CHARSET);
OutputStreamWriter or = new OutputStreamWriter(out, Constants.DEFAULT_CHARSET);
try {
copy(ir, or);
Expand Down Expand Up @@ -1038,13 +1035,16 @@ private void printMetatype(PrintStream out, Jar jar) throws Exception {
}

Map<String, Resource> map = jar.getDirectories().get("OSGI-INF/metatype");
for ( Map.Entry<String,Resource> entry : map.entrySet()) {
out.println(entry.getKey());
IO.copy(entry.getValue().openInputStream(), out);
if (map != null) {
for (Map.Entry<String, Resource> entry : map.entrySet()) {
out.println(entry.getKey());
IO.copy(entry.getValue().openInputStream(), out);
out.println();
}
out.println();
}
out.println();
}

Map<String, Set<String>> invertMapOfCollection(Map<String, Set<String>> map) {
Map<String, Set<String>> result = new TreeMap<String, Set<String>>();
for (Map.Entry<String, Set<String>> entry : map.entrySet()) {
Expand Down Expand Up @@ -1607,8 +1607,7 @@ public void repo(String args[], int i) throws Exception {
error("-bsn and -version must be set before spring command is used");
} else {
String url = String
.format(
"http://www.springsource.com/repository/app/bundle/version/download?name=%s&version=%s&type=binary",
.format("http://www.springsource.com/repository/app/bundle/version/download?name=%s&version=%s&type=binary",
bsn, version);
repoPut(writable, p, url, bsn, version);
}
Expand Down Expand Up @@ -1872,8 +1871,8 @@ private int runtTest(File testFile, Workspace ws, File reportDir, Tag summary) t
return 1;
}

Project project = new Project(ws, testFile.getAbsoluteFile().getParentFile(), testFile
.getAbsoluteFile());
Project project = new Project(ws, testFile.getAbsoluteFile().getParentFile(),
testFile.getAbsoluteFile());
project.setTrace(isTrace());
project.setProperty(NOBUNDLES, "true");
ProjectTester tester = project.getProjectTester();
Expand Down Expand Up @@ -2106,9 +2105,9 @@ void doLibsync(String args[], int i) throws Exception {
for (File file : files) {
Jar jar = new Jar(file);
try {
System.out.printf("%40s-%-10s", jar.getManifest().getMainAttributes().getValue(
BUNDLE_SYMBOLICNAME), jar.getManifest().getMainAttributes().getValue(
BUNDLE_VERSION));
System.out.printf("%40s-%-10s",
jar.getManifest().getMainAttributes().getValue(BUNDLE_SYMBOLICNAME), jar
.getManifest().getMainAttributes().getValue(BUNDLE_VERSION));
libsync.submit(jar);
getInfo(libsync);
System.out.printf(" ok\n");
Expand Down Expand Up @@ -2141,16 +2140,16 @@ public void global(String args[], int i) throws BackingStoreException {
System.out.printf("%-30s %s\n", key, settings.globalGet(key, "<>"));
} else {
while (i < args.length) {
boolean remove=false;
if ( "-remove".equals(args[i])) {
boolean remove = false;
if ("-remove".equals(args[i])) {
remove = true;
i++;
}
if (i + 1 == args.length) {
if ( remove )
if (remove)
settings.globalRemove(args[i]);
else
System.out.printf("%-30s %s\n", args[i], settings.globalGet(args[i], "<>"));
System.out.printf("%-30s %s\n", args[i], settings.globalGet(args[i], "<>"));
i++;
} else {
settings.globalSet(args[i], args[i + 1]);
Expand Down
4 changes: 4 additions & 0 deletions biz.aQute.bndlib/README
@@ -0,0 +1,4 @@
The bndlib project is a general library to be used with OSGi bundles. It contains
lots of cool functionality that calculates dependencies, etc.


11 changes: 9 additions & 2 deletions biz.aQute.bndlib/src/aQute/bnd/build/Project.java
Expand Up @@ -242,7 +242,7 @@ else if (!buildpath.contains(output))

doPath(buildpath, dependencies, parseBuildpath(), bootclasspath);
doPath(testpath, dependencies, parseTestpath(), bootclasspath);
if ( !delayRunDependencies) {
if (!delayRunDependencies) {
doPath(runpath, dependencies, parseRunpath(), null);
doPath(runbundles, dependencies, parseRunbundles(), null);
}
Expand Down Expand Up @@ -940,6 +940,10 @@ public File[] build(boolean underTest) throws Exception {
*/

public File[] getBuildFiles() throws Exception {
return getBuildFiles(true);
}

public File[] getBuildFiles(boolean buildIfAbsent) throws Exception {
File f = new File(getTarget(), BUILDFILES);
if (f.isFile()) {
FileReader fin = new FileReader(f);
Expand All @@ -959,7 +963,10 @@ public File[] getBuildFiles() throws Exception {
fin.close();
}
}
return buildLocal(false);
if (buildIfAbsent)
return buildLocal(false);
else
return null;
}

/**
Expand Down

0 comments on commit cd4c24d

Please sign in to comment.