Author: rob.stryker(a)jboss.com
Date: 2011-11-14 10:29:00 -0500 (Mon, 14 Nov 2011)
New Revision: 36324
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
Log:
JBIDE-8863
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java 2011-11-14
14:54:47 UTC (rev 36323)
+++
trunk/as/plugins/org.jboss.ide.eclipse.archives.webtools/src/org/jboss/ide/eclipse/archives/webtools/modules/LocalZippedPublisherUtil.java 2011-11-14
15:29:00 UTC (rev 36324)
@@ -353,11 +353,7 @@
}
public static IModule[] combine(IModule[] module, IModule newMod) {
- IModule[] retval = new IModule[module.length + 1];
- for( int i = 0; i < module.length; i++ )
- retval[i]=module[i];
- retval[retval.length-1] = newMod;
- return retval;
+ return PublishUtil.combine(module, newMod);
}
public IPath getOutputFilePath() {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java 2011-11-14
14:54:47 UTC (rev 36323)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/ResourceModuleResourceUtil.java 2011-11-14
15:29:00 UTC (rev 36324)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.core.modules;
+import java.io.File;
import java.util.ArrayList;
import org.eclipse.core.resources.IContainer;
@@ -18,6 +19,10 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.IModuleFile;
+import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.util.ModuleFile;
import org.eclipse.wst.server.core.util.ModuleFolder;
@@ -38,8 +43,7 @@
public static IModuleResource createFile(IFile resource, IPath path) {
IPath global = resource.getLocation();
- return new ModuleFile(global.toFile(),
- global.lastSegment(), path);
+ return new ModuleFile(global.toFile(), global.lastSegment(), path);
}
public static IModuleResource createFolder(IContainer cont, IPath path) {
@@ -71,4 +75,47 @@
}
return modChildren.toArray(new IModuleResource[modChildren.size()]);
}
+
+ public static IModuleResource[] addFileToModuleResources(IModule[] moduleTree, IPath
prevPath,
+ IModuleResource[] resources, IPath remainingPath, File childFile) {
+ boolean found = false;
+ String name = remainingPath.segment(0);
+ remainingPath = remainingPath.removeFirstSegments(1);
+
+ for( int i = 0; i < resources.length; i++ ) {
+ if( resources[i].getName().equals(remainingPath.segment(0))) {
+ found = true;
+ if( resources[i] instanceof IModuleFile ) {
+ resources[i] = new ModuleFile(childFile, name, prevPath);
+ return resources;
+ } else if( resources[i] instanceof IModuleFolder){
+ IModuleFolder mf = (IModuleFolder) resources[i];
+ IModuleResource[] mfChildren = mf.members();
+ IModuleResource[] newChildren = addFileToModuleResources(moduleTree,
+ prevPath.append(name), mfChildren, remainingPath, childFile);
+ ((ModuleFolder)mf).setMembers(newChildren);
+ }
+ }
+ }
+
+ if( found )
+ return resources;
+
+ IModuleResource[] newResources = new IModuleResource[resources.length+1];
+ System.arraycopy(resources, 0, newResources, 0, resources.length);
+ if( remainingPath.segmentCount() == 0 ) {
+ // add a file
+ newResources[newResources.length-1] = new ModuleFile(childFile, name, prevPath);
+ } else {
+ // add a folder
+ ModuleFolder mf = new ModuleFolder(null, name, prevPath);
+ IModuleResource[] newChildren = addFileToModuleResources(moduleTree,
+ prevPath.append(name), new IModuleResource[]{}, remainingPath, childFile);
+ ((ModuleFolder)mf).setMembers(newChildren);
+ newResources[newResources.length-1] = mf;
+ }
+ return newResources;
+ }
+
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2011-11-14
14:54:47 UTC (rev 36323)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/AbstractServerToolsPublisher.java 2011-11-14
15:29:00 UTC (rev 36324)
@@ -31,9 +31,11 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.eclipse.wst.server.core.util.ModuleFile;
+import org.eclipse.wst.server.core.util.ProjectModule;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.Messages;
import org.jboss.ide.eclipse.as.core.extensions.events.IEventCodes;
+import org.jboss.ide.eclipse.as.core.modules.ResourceModuleResourceUtil;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublishMethod;
import org.jboss.ide.eclipse.as.core.server.IJBossServerPublisher;
@@ -202,7 +204,7 @@
List<IStatus> list = new ArrayList<IStatus>();
boolean isBinaryObject = ServerModelUtilities.isBinaryModule(module);
- boolean forceZip = forceZipModule(moduleTree);
+ boolean forceZip = forceZipModule(moduleTree) || parentModuleIsForcedZip(moduleTree);
if( !forceZip && !isBinaryObject) {
PublishCopyUtil util = new PublishCopyUtil(callback);
@@ -224,31 +226,72 @@
return status;
}
+ private File createForceZippedChild(IPath deployRoot, IModule module, IModule[]
moduleTree,
+ ArrayList<IStatus> errors) throws CoreException {
+ File temp = null;
+ try {
+ ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
+ IModuleResource[] resources = pm.members();
+
+ IModule[] children = server.getServer().getChildModules(moduleTree, new
NullProgressMonitor());
+ for( int i = 0; i < children.length; i++ ) {
+ IPath path = new Path(pm.getPath(children[i]));
+ IModule[] tmpTree = PublishUtil.combine(moduleTree, children[i]);
+ File childFile = createForceZippedChild(deployRoot, children[i], tmpTree, errors);
+ resources = ResourceModuleResourceUtil.addFileToModuleResources(
+ tmpTree, new Path("/"), resources, path, childFile); //$NON-NLS-1$
+ }
+
+ // Make output
+ temp = File.createTempFile(module.getName(), ".tmp", deployRoot.toFile());
//$NON-NLS-1$
+ IPath tempFile = new Path(temp.getAbsolutePath());
+ IStatus[] e2 =
PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1].getName(), resources,
tempFile);
+ errors.addAll(Arrays.asList(e2));
+ return temp;
+ } catch( IOException ioe) {
+ errors.add( new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID,
ioe.getMessage(), ioe));
+ return null;
+ }
+ }
+
+ private boolean parentModuleIsForcedZip(IModule[] moduleTree) {
+ ArrayList<IModule> tmp = new ArrayList<IModule>();
+ tmp.addAll(Arrays.asList(moduleTree));
+ tmp.remove(tmp.size()-1);
+ while( tmp.size() > 0 ) {
+ IModule[] tmpArray = tmp.toArray(new IModule[tmp.size()]);
+ if( forceZipModule(tmpArray) ) {
+ return true;
+ }
+ tmp.remove(tmp.size()-1);
+ }
+ return false;
+ }
+
protected IStatus[] transferForceZippedChild(IPath deployPath, IModule module, IModule[]
moduleTree, IProgressMonitor monitor) throws CoreException {
+ // Been here already
+ if(parentModuleIsForcedZip(moduleTree))
+ return new IStatus[]{};
+
// A child that must be zipped, forceZip is true
ArrayList<IStatus> list = new ArrayList<IStatus>();
IPath deployRoot = JBossServerCorePlugin.getServerStateLocation(server.getServer()).
append(IJBossToolingConstants.TEMP_DEPLOY).makeAbsolute();
- try {
// Make local jar copy
- File temp = File.createTempFile(module.getName(), ".tmp",
deployRoot.toFile()); //$NON-NLS-1$
- IPath tempFile = new Path(temp.getAbsolutePath());
- list.addAll(Arrays.asList(PublishUtil.packModuleIntoJar(moduleTree[moduleTree.length-1],
tempFile)));
-
- // TODO !!!!! Transfer it
+ File temp = createForceZippedChild(deployRoot, module, moduleTree, list);
+ if( temp != null ) {
+ // Transfer it
IPath deployPathInner = getParentDeployPath(moduleTree, server);
IPublishCopyCallbackHandler handler =
getCallbackHandler(getRootPath(deployPathInner).append(deployPathInner));
IPath filePath = deployPath.removeFirstSegments(deployPathInner.segments().length);
IPath parentFolderPath = filePath.removeLastSegments(1);
handler.makeDirectoryIfRequired(parentFolderPath, getSubMon(monitor, 200));
- ModuleFile mf = new ModuleFile(tempFile.toFile(), tempFile.lastSegment(), tempFile);
+ ModuleFile mf = new ModuleFile(temp, temp.getName(), new
Path(temp.getAbsolutePath()));
handler.copyFile(mf, filePath, getSubMon(monitor, 500));
// Cleanup
- tempFile.toFile().delete();
- } catch( IOException ioe) {
- list.add( new Status(IStatus.ERROR, JBossServerCorePlugin.PLUGIN_ID, ioe.getMessage(),
ioe));
+ temp.delete();
}
return list.toArray(new IStatus[list.size()]);
}
@@ -272,7 +315,7 @@
boolean isBinaryObject = ServerModelUtilities.isBinaryModule(module);
monitor.beginTask("Incremental Publish: " +
moduleTree[moduleTree.length-1].getName(), 100); //$NON-NLS-1$
- boolean forceZip = forceZipModule(moduleTree);
+ boolean forceZip = forceZipModule(moduleTree) || parentModuleIsForcedZip(moduleTree);
IPublishCopyCallbackHandler handler = null;
if( !forceZip && !isBinaryObject) {
handler = getCallbackHandler(deployPath);
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2011-11-14
14:54:47 UTC (rev 36323)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PublishUtil.java 2011-11-14
15:29:00 UTC (rev 36324)
@@ -384,4 +384,11 @@
}
}
+ public static IModule[] combine(IModule[] module, IModule newMod) {
+ IModule[] retval = new IModule[module.length + 1];
+ for( int i = 0; i < module.length; i++ )
+ retval[i]=module[i];
+ retval[retval.length-1] = newMod;
+ return retval;
+ }
}