View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.argeo.slc.client.ui.dist.commands;
17  
18  import java.io.File;
19  import java.io.IOException;
20  import java.util.jar.Manifest;
21  
22  import org.eclipse.core.commands.AbstractHandler;
23  import org.eclipse.core.commands.ExecutionEvent;
24  import org.eclipse.core.commands.ExecutionException;
25  
26  import aQute.bnd.osgi.Builder;
27  import aQute.bnd.osgi.Constants;
28  import aQute.bnd.osgi.Jar;
29  
30  public class BndProcess extends AbstractHandler implements Constants {
31  
32  	public Object execute(ExecutionEvent event) throws ExecutionException {
33  		try {
34  			Builder b = new Builder();
35  			b.setProperty(EXPORT_PACKAGE, "org.osgi.framework");
36  			b.setProperty(PRIVATE_PACKAGE, "*");
37  			b.addClasspath(new File(
38  					"/home/mbaudier/.m2/repository/org/eclipse/osgi/org.eclipse.osgi/3.6.1/org.eclipse.osgi-3.6.1.jar"));
39  
40  			Jar jar = b.build();
41  			Manifest m = jar.getManifest();
42  			jar.write(new File(b.getBsn() + ".jar"));
43  		} catch (IOException e) {
44  			// TODO Auto-generated catch block
45  			e.printStackTrace();
46  		} catch (Exception e) {
47  			// TODO Auto-generated catch block
48  			e.printStackTrace();
49  		}
50  
51  		return null;
52  	}
53  
54  	public static void main(String[] args) {
55  		try {
56  			new BndProcess().execute(null);
57  		} catch (ExecutionException e) {
58  			// TODO Auto-generated catch block
59  			e.printStackTrace();
60  		}
61  	}
62  
63  }