14
14
import org .apache .log4j .LogManager ;
15
15
import org .apache .log4j .Logger ;
16
16
import org .eclipse .core .resources .IFolder ;
17
+ import org .eclipse .core .resources .IProject ;
18
+ import org .eclipse .core .resources .ResourcesPlugin ;
17
19
import org .eclipse .core .runtime .CoreException ;
20
+ import org .eclipse .core .runtime .IPath ;
18
21
import org .eclipse .jdt .core .IClasspathEntry ;
19
22
import org .eclipse .jdt .core .IJavaProject ;
20
23
import org .eclipse .jdt .core .JavaCore ;
21
24
import org .eclipse .jdt .core .JavaModelException ;
22
25
23
26
import jce .util .ProgressMonitorAdapter ;
24
- import jce .util .ProjectDirectories ;
25
27
26
28
/**
27
29
* Helper class that edits an project do add the Xtend dependencies.
@@ -37,13 +39,13 @@ private XtendLibraryHelper() {
37
39
38
40
/**
39
41
* Adds the Xtend dependencies to a project and creates the xtend-gen source folder.
40
- * @param project is the {@link IJavaProject} instance of the project.
41
- * @param directories is the {@link ProjectDirectories} instance of the project.
42
+ * @param javaProject is the {@link IJavaProject} instance of the project.
42
43
*/
43
- public static void addXtendLibs (IJavaProject project , ProjectDirectories directories ) {
44
+ public static void addXtendLibs (IJavaProject javaProject ) {
45
+ IProject project = javaProject .getProject ();
44
46
createXtendFolder (project );
45
- addClasspathEntry (project ); // TODO (MEDIUM) add xtend-gen folder to build.properties file.
46
- addManifestEntries (directories );
47
+ addClasspathEntry (javaProject ); // TODO (MEDIUM) add xtend-gen folder to build.properties file.
48
+ addManifestEntries (project );
47
49
}
48
50
49
51
/**
@@ -65,24 +67,26 @@ private static void addClasspathEntry(IJavaProject project) {
65
67
66
68
/**
67
69
* Adds Xtend manifest entries to the manifest file.
68
- * @param directories is the {@link ProjectDirectories} instance of the project .
70
+ * @param project is the {@link IJavaProject} .
69
71
*/
70
- private static void addManifestEntries (ProjectDirectories directories ) {
71
- File file = new File (directories .getManifestDirectory () + SLASH + "MANIFEST.MF" );
72
+ private static void addManifestEntries (IProject project ) {
73
+ IPath workspace = ResourcesPlugin .getWorkspace ().getRoot ().getLocation (); // workspace path
74
+ String folder = workspace .toString () + project .getFolder ("META-INF" ).getFullPath (); // manifest folder
75
+ File file = new File (folder + SLASH + "MANIFEST.MF" ); // manifest file
72
76
if (file .exists ()) {
73
77
List <String > manifest = read (file .toPath ());
74
78
List <String > newManifest = edit (manifest );
75
79
write (file .toPath (), newManifest );
76
80
} else {
77
- logger .error ("Could not find MANIFEST.MF file in " + directories . getManifestDirectory () );
81
+ logger .error ("Could not find MANIFEST.MF file in " + folder );
78
82
}
79
83
}
80
84
81
85
/**
82
86
* Creates the binary file folder for Xtend. This is the xtend-bin folder.
83
87
*/
84
- private static void createXtendFolder (IJavaProject project ) {
85
- IFolder folder = project .getProject (). getFolder ("xtend-gen" );
88
+ private static void createXtendFolder (IProject project ) {
89
+ IFolder folder = project .getFolder ("xtend-gen" );
86
90
try {
87
91
folder .create (false , true , new ProgressMonitorAdapter (logger ));
88
92
} catch (CoreException exception ) {
0 commit comments