Author: rob.stryker(a)jboss.com
Date: 2008-04-03 23:20:36 -0400 (Thu, 03 Apr 2008)
New Revision: 7311
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
Log:
JBIDE-1987 - reinstated the old archives ant code, and tested. Still requires unit testing
but it seems to work just as it did in the last version.
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java 2008-04-03
22:37:14 UTC (rev 7310)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java 2008-04-04
03:20:36 UTC (rev 7311)
@@ -18,10 +18,13 @@
public Task getCurrentTask() { return currentTask; }
public IPath getProjectPath(String projectName) {
- HashMap<Object, Object> map =
ResourceModel.getDefault().getTaskEnvironment(currentTask);
- if( map.containsKey(projectName)) return new Path((String)map.get(projectName));
- if( map.containsKey(IPath.SEPARATOR + projectName)) return new
Path((String)map.get(IPath.SEPARATOR + projectName));
-
+// HashMap<Object, Object> map =
ResourceModel.getDefault().getTaskEnvironment(currentTask);
+// if( map.containsKey(projectName)) return new Path((String)map.get(projectName));
+// if( map.containsKey(IPath.SEPARATOR + projectName)) return new
Path((String)map.get(IPath.SEPARATOR + projectName));
+ projectName = projectName.replace(' ', '_');
+ String projectPath = System.getProperty(projectName + ".dir");
+ if (projectPath != null)
+ return new Path(projectPath);
return null;
}
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-04-04
03:20:36 UTC (rev 7311)
@@ -0,0 +1,86 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.archives.core.ant;
+
+import java.util.Iterator;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
+
+/**
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ *
+ */
+public class GenerateArchivesTask extends Task {
+
+ private String projectPath;
+
+ public void init() throws BuildException {
+ // Force standalone mode
+ ArchivesCore standalone = new AntArchivesCore();
+ ArchivesCore.setInstance(standalone);
+ }
+
+ public void execute() throws BuildException {
+ ClassLoader original = Thread.currentThread().getContextClassLoader();
+ try {
+ IPath projectPath = new Path(this.projectPath);
+ IProgressMonitor monitor = new NullProgressMonitor();
+
+ for (Iterator iter = getProject().getProperties().keySet().iterator(); iter.hasNext();
)
+ {
+ String property = (String) iter.next();
+ if (property.endsWith(".dir")) {
+ System.setProperty(property, getProject().getProperty(property));
+ }
+ }
+
+ // needed so the correct XML binding / TrueZIP jars are loaded
+ ClassLoader myCL = getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(myCL);
+
+ ArchivesModel.instance().registerProject(projectPath, monitor);
+ ArchivesModelCore.buildProject(projectPath, monitor);
+ } catch(RuntimeException e ) {
+ e.printStackTrace();
+ throw e;
+ }
+ finally {
+ Thread.currentThread().setContextClassLoader(original);
+ }
+ }
+
+ public String getProjectPath() {
+ return projectPath;
+ }
+
+ public void setProjectPath(String projectPath) {
+ this.projectPath = projectPath;
+ }
+}
\ No newline at end of file
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-04-03
22:37:14 UTC (rev 7310)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-04-04
03:20:36 UTC (rev 7311)
@@ -238,8 +238,11 @@
IArchive node2 = ((IArchive)node);
boolean exploded = ((IArchive)node).isExploded();
ArchiveDetector detector = exploded ? ArchiveDetector.NULL :
TrueZipUtil.getJarArchiveDetector();
- if( parentFile == null )
- return new
File(node2.getGlobalDestinationPath().append(node2.getName()).toOSString(), detector);
+ if( parentFile == null ) {
+ IPath p = node2.getGlobalDestinationPath();
+ if( p == null ) return null;
+ return new File(p.append(node2.getName()).toOSString(), detector);
+ }
return new File(parentFile, node2.getName(), detector);
}
if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER ) {