Skip to content

Commit

Permalink
Merge pull request apache#7932 from matthiasblaesing/add_sources_modules
Browse files Browse the repository at this point in the history
Java Platform Libraries: Support source archives with multiple modules
  • Loading branch information
ebarboni authored Nov 5, 2024
2 parents 240014d + 513ed15 commit 64d64d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>

<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.netbeans.spi.project.libraries.LibraryStorageArea;
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
import org.openide.DialogDescriptor;
import org.openide.filesystems.URLMapper;
import org.openide.util.Utilities;

/**
Expand Down Expand Up @@ -532,8 +533,25 @@ private static URI[] pathsToURIs(
@NullAllowed final File baseFolder) throws MalformedURLException, URISyntaxException {
final List<URI> result = new ArrayList<URI>(fileNames.length);
for (String fileName : fileNames) {
final URI uri = pathToURI(baseFolder,fileName,volume);
if (uri != null) {
final URI uri = pathToURI(baseFolder, fileName, volume);
if (volume.equals(J2SELibraryTypeProvider.VOLUME_TYPE_SRC) && (FileUtil.isArchiveFile(uri.toURL()) || FileUtil.isArchiveArtifact(uri.toURL()))) {
// Handle src.jars, that hold the sources for multiple jars (observed for the JDK and OpenJFX)
URL archiveUrl = uri.toURL();
if(FileUtil.isArchiveFile(uri.toURL())) {
archiveUrl = FileUtil.getArchiveRoot(uri.toURL());
}
FileObject archiveFO = URLMapper.findFileObject(archiveUrl);
boolean moduleInfoOnSecondLevel = false;
for (FileObject topLevelFolder : archiveFO.getChildren()) {
if (topLevelFolder.isFolder() && topLevelFolder.getFileObject("module-info.java") != null) {
moduleInfoOnSecondLevel = true;
result.add(topLevelFolder.toURI());
}
}
if(!moduleInfoOnSecondLevel) {
result.add(uri);
}
} else if (uri != null) {
result.add(uri);
}
}
Expand Down Expand Up @@ -669,9 +687,6 @@ public Component getListCellRendererComponent(JList list, Object value, int inde
if (uri != null && uri.toString().startsWith("http")) {
displayName = uri.toString();
} else if (uri != null) {
if (uri.toString().contains("!/")) { //NOI18N
uri = LibrariesSupport.getArchiveFile(uri);
}
boolean broken = false;
VolumeContentModel model = (VolumeContentModel)list.getModel();
LibraryStorageArea area = model.getArea();
Expand Down

0 comments on commit 64d64d8

Please sign in to comment.