Browse Source

Fix bug breaking Ant projects

Pete Whelpton 2 years ago
parent
commit
5768ed4292

+ 16 - 13
jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java

@@ -210,12 +210,12 @@ public class ProjectAssetManager extends DesktopAssetManager {
                     logger.info(fo.toURL().toExternalForm());
                     if (!fo.equals(getAssetFolder())) {
                             fo.addRecursiveListener(listener);
-                            logger.log(Level.INFO, "Add classpath:{0}", fo);
+                            logger.log(Level.FINE, "Add classpath:{0}", fo);
                             classPathItems.add(new ClassPathItem(fo, listener));
                             urls.add(fo.toURL());
                         }
                     if (fo.toURL().toExternalForm().startsWith("jar")) {
-                            logger.log(Level.INFO, "Add Gradle locator:{0}", fo.toURL());
+                            logger.log(Level.FINE, "Add Gradle locator:{0}", fo.toURL());
                             jarItems.add(fo);
                             registerLocator(fo.toURL().toExternalForm(),
                                     "com.jme3.asset.plugins.UrlLocator");
@@ -227,7 +227,7 @@ public class ProjectAssetManager extends DesktopAssetManager {
             
             loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
             addClassLoader(loader);
-            logger.log(Level.INFO, "Updated {0} classpath entries and {1} url locators for project {2}", new Object[]{classPathItems.size(), jarItems.size(), project.toString()});
+            logger.log(Level.FINE, "Updated {0} classpath entries and {1} url locators for project {2}", new Object[]{classPathItems.size(), jarItems.size(), project.toString()});
         }
     }
     FileChangeListener listener = new FileChangeListener() {
@@ -524,19 +524,22 @@ public class ProjectAssetManager extends DesktopAssetManager {
             while (classPathItemsIter.hasNext()) {
                 ClassPathItem classPathItem = classPathItemsIter.next();
                 FileObject jarFile = classPathItem.object;
-                if(FileUtil.isArchiveFile(jarFile)) {
-                    FileObject jarFileRoot = FileUtil.getArchiveRoot(jarFile);
-                    Enumeration<FileObject> jarEntry = (Enumeration<FileObject>) jarFileRoot.getChildren(true);
-                    while (jarEntry.hasMoreElements()) {
-                        FileObject jarEntryAsset = jarEntry.nextElement();
-                        if (jarEntryAsset.getExt().equalsIgnoreCase(suffix)) {
-                            if (!jarEntryAsset.getPath().startsWith("/")) {
-                                list.add(jarEntryAsset.getPath());
-                            }
+                
+                // Gradle projects don't know that the dependency is a Jar file
+                if (FileUtil.isArchiveFile(jarFile)) {
+                    jarFile = FileUtil.getArchiveRoot(jarFile);
+                }
+
+                Enumeration<FileObject> jarEntry = (Enumeration<FileObject>) jarFile.getChildren(true);
+                while (jarEntry.hasMoreElements()) {
+                    FileObject jarEntryAsset = jarEntry.nextElement();
+                    if (jarEntryAsset.getExt().equalsIgnoreCase(suffix)) {
+                        if (!jarEntryAsset.getPath().startsWith("/")) {
+                            list.add(jarEntryAsset.getPath());
                         }
                     }
                 }
-                
+
             }
             return list;
         }

+ 1 - 1
jme3-core/src/com/jme3/gde/core/assets/actions/UpdateProjectAssetManagerAfterBuild.java

@@ -40,7 +40,7 @@ import org.netbeans.spi.project.ProjectServiceProvider;
 import org.openide.util.Lookup;
 
 /**
- * Hook that fires after a Gradle JME project has been build and requests
+ * Hook that fires after a Gradle JME project has been built and requests
  * the ProjectAssetManager to update its ClassLoader (e.g. in case new
  * dependencies have been added)
  *