Skip to content

Commit

Permalink
Convert projects without dependencies
Browse files Browse the repository at this point in the history
now also converts old projects without dependencies
avoid potential override of existing manifest
  • Loading branch information
pazi146 authored and azoitl committed Jan 7, 2025
1 parent ce3d4a2 commit e9ec053
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static Manifest getFolderManifest(final java.nio.file.Path path) {
* @return the manifest, or {@code null} if it couldn't be loaded
*/
public static Manifest getManifest(final IFile manifest) {
if (manifest == null || !manifest.exists()) {
if (manifest == null) {// don't use manifest.exists() as internal eclipse cache might be inconsistent
return null;
}
return getManifest(URI.createURI(manifest.getLocationURI().toString()));
Expand Down Expand Up @@ -472,10 +472,12 @@ public static boolean saveManifest(final Manifest manifest) {
* @return {@code true} if it was saved successfully, else {@code false}
*/
public static boolean sortAndSaveManifest(final Manifest manifest) {
// ensure dependencies are sorted (can't use EList.sort())
final var dependencies = new LinkedList<>(manifest.getDependencies().getRequired());
manifest.getDependencies().getRequired().clear();
dependencies.forEach(d -> ManifestHelper.addDependency(manifest, d));
if (manifest.getDependencies() != null) {
// ensure dependencies are sorted (can't use EList.sort())
final var dependencies = new LinkedList<>(manifest.getDependencies().getRequired());
manifest.getDependencies().getRequired().clear();
dependencies.forEach(d -> ManifestHelper.addDependency(manifest, d));
}
return saveManifest(manifest);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public void checkManifestFile(final IProject project, final TypeLibrary typeLibr
init(project);
}
final Manifest manifest = ManifestHelper.getOrCreateProjectManifest(project);
if (manifest == null || !ManifestHelper.isProject(manifest) || manifest.getDependencies() == null) {
if (manifest == null || !ManifestHelper.isProject(manifest)) {
return;
}

Expand Down Expand Up @@ -762,7 +762,7 @@ public void resolveDependencies(final IProject project, final TypeLibrary typeLi

final Manifest projectManifest = ManifestHelper.getContainerManifest(project);

if (projectManifest == null || projectManifest.getDependencies() == null) {
if (projectManifest == null) {
return;
}

Expand All @@ -771,6 +771,10 @@ public void resolveDependencies(final IProject project, final TypeLibrary typeLi
// remove when no longer needed
moveLinksToVirtualFolders(project, typeLibrary);

if (projectManifest.getDependencies() == null) {
return;
}

findPreferred(project, preferred, linked);

projectManifest.getDependencies().getRequired().forEach(req -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public IProject createNew4diacProject(final String projectName, final IPath loca
project.create(description, monitor);
project.open(monitor);

TypeLibraryManager.INSTANCE.getTypeLibrary(project); // insert the project into the project list

ManifestHelper.createProjectManifest(project, includedLibraries.keySet());

project.getFolder(TypeLibraryTags.TYPE_LIB_FOLDER_NAME).create(true, true, monitor);
Expand All @@ -128,6 +126,8 @@ public IProject createNew4diacProject(final String projectName, final IPath loca
project.getFolder(TypeLibraryTags.EXTERNAL_LIB_FOLDER_NAME).create(IResource.VIRTUAL | IResource.FORCE, true,
monitor);

TypeLibraryManager.INSTANCE.getTypeLibrary(project); // insert the project into the project list

return project;
}

Expand Down

0 comments on commit e9ec053

Please sign in to comment.