/Users/lyon/j4p/src/classUtils/pack/DependencyUtils.java
|
1 package classUtils.pack;
2
3 import classUtils.pack.util.ant.Pack;
4 import classUtils.putils.ClassPathUtils;
5 import classUtils.reflection.Command;
6
7
8
9
10 /**
11 * User: lyon Date: May 18, 2004 Time: 10:38:11
12 * AM
13 */
14 public class DependencyUtils {
15 public static void main(String[] args) {
16 Class classFromFile = Command.getClassFromFile();
17 printDependencies(classFromFile);
18 }
19
20 private static void packTask() {
21 pack(dhry.Main.class);
22 pack(addBk.addressBook.Main.class);
23 pack(classUtils.pack.DependencyUtils.class);
24 pack(ip.Main.class);
25 }
26
27 public static void pack(Class c) {
28 String name = c.getName();
29 pack(name, name + ".jar");
30 }
31
32 public static void printDependencies(Class mainClass) {
33 String name1 = mainClass.getName();
34 Pack p1 = new Pack();
35 p1.setManifestMainClass(name1);
36 p1.setClasses(name1);
37 p1.setTargetJar(name1 + ".jar");
38 p1.execute();
39 p1.printDependencies();
40
41 }
42
43 public static void pack(String mainClass,
44 String targetJar) {
45 Pack p = new Pack();
46 p.setManifestMainClass(mainClass);
47 p.setClasses(mainClass);
48 p.setIncludePkg("net.scp,com.jcraft.jsch.jce,com.jcraft.jsch,com.jcraft");
49 p.setTargetJar(targetJar);
50 final String classPath =
51 ClassPathUtils.getClassPath();
52 System.out.println("using class path:" + classPath);
53 p.setClasspath(classPath);
54 p.execute();
55 System.out.println("done with:" + targetJar);
56 }
57 }
58