blob: d9cccda83d83c3308d4cc61ae8849ca2b59bd24b [file] [log] [blame]
Stuart McCulloch26e7a5a2011-10-17 10:31:43 +00001package aQute.bnd.build;
2
3import java.io.*;
4import java.util.*;
5
6import aQute.lib.osgi.*;
7
8public class ProjectBuilder extends Builder {
9 Project project;
10 boolean initialized;
11
12 public ProjectBuilder(Project project) {
13 super(project);
14 this.project = project;
15 }
16
17 public ProjectBuilder(ProjectBuilder builder) {
18 super(builder);
19 this.project = builder.project;
20 }
21
22 @Override
23 public long lastModified() {
24 return Math.max(project.lastModified(), super.lastModified());
25 }
26
27 /**
28 * We put our project and our workspace on the macro path.
29 */
30 protected Object[] getMacroDomains() {
31 return new Object[] { project, project.getWorkspace() };
32 }
33
34 public Builder getSubBuilder() throws Exception {
35 return project.getBuilder(this);
36 }
37
38 public Project getProject() {
39 return project;
40 }
41
42 public void init() {
43 try {
44 if (!initialized) {
45 initialized = true;
46 for (Container file : project.getBuildpath()) {
47 addClasspath(file.getFile());
48 }
49
50 for (Container file : project.getBootclasspath()) {
51 addClasspath(file.getFile());
52 }
53
54 for (File file : project.getAllsourcepath()) {
55 addSourcepath(file);
56 }
57
58 }
59 } catch (Exception e) {
60 error("init project builder fails", e);
61 }
62 }
63
64 public List<Jar> getClasspath() {
65 init();
66 return super.getClasspath();
67 }
68
69 @Override
70 protected void changedFile(File f) {
71 project.getWorkspace().changedFile(f);
72 }
73}