Author: rob.stryker(a)jboss.com
Date: 2008-08-06 19:37:56 -0400 (Wed, 06 Aug 2008)
New Revision: 9584
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVFS.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/PathUtils.java
Removed:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntExtensionManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntPreferenceManager.java
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/EclipseResourceGroupTask.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceTask.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedAntExecution.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/JBossArchivesTask.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/ResourceModel.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/antlib.xml
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/tasks.properties
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListenerWithRefresh.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelRootNode.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
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/xml/packages.xsd
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/JBIDE1406/.packages
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/StringSubstitutionTest.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE1406Test.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE2439Test.java
Log:
JBIDE-1406 - allowing version id's for the descriptor and associated UI changes and
test
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/J2EEArchiveType.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -38,11 +38,13 @@
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
/**
@@ -151,4 +153,11 @@
public abstract String getAssociatedModuleType();
+ /*
+ * Creates a directory scanner for some global path
+ */
+ public static DirectoryScannerExtension createDirectoryScanner (String rawPath, String
includes, String excludes, boolean scan) {
+ return DirectoryScannerFactory.createDirectoryScanner(rawPath, null, includes,
excludes, null, false, 1, scan);
+ }
+
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -42,7 +42,6 @@
import org.jboss.ide.eclipse.archives.core.ArchivesCorePlugin;
import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
@@ -100,8 +99,7 @@
protected void addWebContentFileset(IProject project, IArchiveNode packageRoot) throws
ArchivesModelException {
try {
IPath projectPath = project.getLocation();
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(projectPath.toString(),
"**/WEB-INF/web.xml", null, true);
+ DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(),
"**/WEB-INF/web.xml", null, true);
String[] files = scanner.getIncludedFiles();
// just take the first
if( files.length > 0 ) {
@@ -133,8 +131,7 @@
protected void addWebinfFileset(IProject project, IArchiveFolder folder) throws
ArchivesModelException {
try {
IPath projectPath = project.getLocation();
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(projectPath.toString(),
"**/web.xml", null, true);
+ DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(),
"**/web.xml", null, true);
String[] files = scanner.getIncludedFiles();
// just take the first
if( files.length > 0 ) {
@@ -155,8 +152,7 @@
String sourcePath = null;
IPath projectPath = project.getLocation();
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(projectPath.toString(),
"**/WEB-INF/web.xml", null, true);
+ DirectoryScanner scanner = createDirectoryScanner(projectPath.toString(),
"**/WEB-INF/web.xml", null, true);
String[] files = scanner.getIncludedFiles();
if(files != null && files.length > 0) {
@@ -167,8 +163,7 @@
} else {
//having failed to find 'lib' directory, let us make source of the project
itself
sourcePath = project.getName();
- DirectoryScanner scanner2 =
- DirectoryScannerFactory.createDirectoryScanner(projectPath.toString(),
"**/*.jar", null, true);
+ DirectoryScanner scanner2 = createDirectoryScanner(projectPath.toString(),
"**/*.jar", null, true);
String[] files2 = scanner2.getIncludedFiles();
IPath p;
ArrayList list = new ArrayList();
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -51,6 +51,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
/**
@@ -289,14 +290,6 @@
parent.addChild(emf);
}
- public void removeFilesetPathAsChild(IArchiveFileSet fs, IPath path) {
- IPath globalSource = fs.getGlobalSourcePath();
- IPath fsRelative = path.removeFirstSegments(globalSource.segmentCount());
- ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), false);
- if( parent != null )
- parent.removeFilesetPathAsChild(fs, path);
- }
-
protected ArchiveContainerResource find(IArchiveFileSet fs, IPath fsRelative, boolean
create) {
ArchiveContainerResource resource = this;
ArchiveContainerResource tmpResource;
@@ -336,7 +329,7 @@
public IPath getDeepDestination() {
IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET
? moduleRelativePath : node.getRootArchiveRelativePath();
- return node.getRootArchive().getGlobalDestinationPath().append(tmp);
+ return PathUtils.getGlobalLocation(node.getRootArchive()).append(tmp);
}
public IPath getConcreteDestFile() {
@@ -369,7 +362,7 @@
public IPath getPath() { return new Path(wrapper.getAbsolutePath()); }
public IArchiveNode getNode() { return node; }
public IPath getDeepDestination() {
- return
node.getRootArchive().getGlobalDestinationPath().append(wrapper.getRootArchiveRelative());
+ return
PathUtils.getGlobalLocation(node.getRootArchive()).append(wrapper.getRootArchiveRelative());
}
public IPath getSourcePath() {
return new Path(this.wrapper.getAbsolutePath());
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -37,6 +37,7 @@
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.IModuleResourceDelta;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
import org.jboss.ide.eclipse.as.core.extensions.events.EventLogModel.EventLogTreeItem;
import org.jboss.ide.eclipse.as.core.modules.PackageModuleFactory.ExtendedModuleFile;
@@ -112,7 +113,7 @@
IPath destPathRoot = new Path(server.getDeployDirectory());
// if destination is deploy directory... no need to re-copy!
- if( destPathRoot.toOSString().equals(pack.getGlobalDestinationPath().toOSString())) {
+ if( destPathRoot.toOSString().equals(PathUtils.getGlobalLocation(pack).toOSString()))
{
// fire null publish event
return;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/packages/PreviewPage.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -129,7 +129,7 @@
protected abstract void addToPackage();
protected void fillWidgets(IArchive pkg) {
- previewViewer.setInput(new IArchive[] {pkg});
+ previewViewer.setInput(pkg);
previewViewer.expandAll();
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -595,7 +595,7 @@
try {
if( dir != null ) {
DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(dir, includes, excludes, true);
+ DirectoryScannerFactory.createDirectoryScanner(dir, null, includes, excludes, null,
false, 1, true);
if( scanner != null ) {
String[] files = scanner.getIncludedFiles();
paths = new IPath[files.length];
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/WorkspaceChangeListener.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -67,6 +67,7 @@
if(delta!=null) {
delta.accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
+ // TODO modify to make sure this file is a descriptor in use / registered
if( delta.getResource() != null && delta.getResource().getLocation() !=
null &&
delta.getResource().getLocation().lastSegment().equals(IArchiveModel.DEFAULT_PACKAGES_FILE))
{
projects.add(delta.getResource().getProject());
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListenerWithRefresh.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListenerWithRefresh.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/build/ModelChangeListenerWithRefresh.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -37,7 +37,7 @@
proj.setSessionProperty(new QualifiedName(ArchivesCorePlugin.PLUGIN_ID,
"localname"), "inUse");
if( pack.isDestinationInWorkspace() ) {
// refresh the root package node
- IResource res = root.getContainerForLocation(pack.getGlobalDestinationPath());
+ IResource res = root.getContainerForLocation(pack.getProjectPath());
if( res != null ) {
try {
// refresh infinitely in case the output is exploded
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVFS.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -17,11 +17,6 @@
public WorkspaceVFS() {
}
- public String performStringSubstitution(String expression,
- boolean reportUndefinedVariables) throws CoreException {
- return performStringSubstitution(expression, null, reportUndefinedVariables);
- }
-
public IPath[] getWorkspaceChildren(IPath path) {
IResource res = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
if( res != null || !(res instanceof IContainer)) {
@@ -51,13 +46,6 @@
return null;
}
- public IPath[] workspacePathToAbsolutePath(IPath[] paths) {
- IPath[] results = new IPath[paths.length];
- for( int i = 0; i < paths.length; i++ )
- results[i] = workspacePathToAbsolutePath(paths[i]);
- return results;
- }
-
public String getProjectName(IPath absolutePath) {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for( int i = 0; i < projects.length; i++ )
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -25,6 +25,7 @@
import java.util.Map;
import java.util.TreeSet;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
@@ -44,6 +45,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
/**
@@ -69,8 +71,8 @@
IProject[] interestingProjects = getInterestingProjectsInternal();
- final TreeSet addedChanged = createDefaultTreeSet();
- final TreeSet removed = createDefaultTreeSet();
+ final TreeSet<IPath> addedChanged = createPathTreeSet();
+ final TreeSet<IPath> removed = createPathTreeSet();
ArchiveBuildDelegate delegate = new ArchiveBuildDelegate();
if (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD || kind ==
IncrementalProjectBuilder.AUTO_BUILD) {
@@ -109,7 +111,7 @@
* @param addedChanged A collection of resources that have been added or changed
* @param removed A collection of resources that have been removed.
*/
- protected void fillDeltas(IProject[] projects, final TreeSet addedChanged, final TreeSet
removed) {
+ protected void fillDeltas(IProject[] projects, final TreeSet<IPath> addedChanged,
final TreeSet<IPath> removed) {
for( int i = 0; i < projects.length; i++ ) {
final IProject proj = projects[i];
IResourceDelta delta = getDelta(proj);
@@ -144,11 +146,10 @@
* @return The list of projects that matter
*/
protected IProject[] getInterestingProjectsInternal() {
- final TreeSet set = createDefaultTreeSet();
+ final TreeSet<IProject> set = createProjectTreeSet();
set.add(getProject());
final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- final int count = workspaceRoot.getLocation().segmentCount();
IArchiveModelRootNode root =
ArchivesModel.instance().getRoot(getProject().getLocation());
if(root!=null) {
@@ -156,11 +157,11 @@
public boolean visit (IArchiveNode node) {
if (node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
IArchiveFileSet fileset = (IArchiveFileSet)node;
- IPath p = fileset.getGlobalSourcePath();
+ IPath p = PathUtils.getGlobalLocation(fileset);
if( p != null ) {
- if( workspaceRoot.getLocation().isPrefixOf(p)) {
- IProject proj = workspaceRoot.getProject(p.segment(count));
- set.add(proj);
+ IContainer[] containers = workspaceRoot.findContainersForLocation(p);
+ for( int i = 0; i < containers.length; i++ ) {
+ set.add(containers[i].getProject());
}
}
}
@@ -177,13 +178,21 @@
* Default treeset with default comparator
* @return
*/
- protected TreeSet createDefaultTreeSet() {
- return new TreeSet(new Comparator () {
- public int compare(Object o1, Object o2) {
+ protected TreeSet<IProject> createProjectTreeSet() {
+ return new TreeSet<IProject>(new Comparator<IProject> () {
+ public int compare(IProject o1, IProject o2) {
if (o1.equals(o2)) return 0;
else return -1;
}
});
}
+ protected TreeSet<IPath> createPathTreeSet() {
+ return new TreeSet<IPath>(new Comparator<IPath> () {
+ public int compare(IPath o1, IPath o2) {
+ if (o1.equals(o2)) return 0;
+ else return -1;
+ }
+ });
+ }
}
\ No newline at end of file
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntArchivesCore.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -22,19 +22,19 @@
}
protected IExtensionManager createExtensionManager() {
- return new AntExtensionManager();
+ return null; // not necessary right now
}
protected IPreferenceManager createPreferenceManager() {
- return new AntPreferenceManager();
+ return null; // not necessary right now
}
protected IArchivesVFS createVFS() {
- return new AntVariables();
+ return new AntVFS();
}
public void preRegisterProject(IPath project) {
-
+ // do nothing
}
protected IArchivesLogger createLogger() {
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntExtensionManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntExtensionManager.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntExtensionManager.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,50 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.ide.eclipse.archives.core.model.IActionType;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveType;
-import org.jboss.ide.eclipse.archives.core.model.IExtensionManager;
-
-/**
- * The ant API to extensions, specifically archive types.
- * This is a stub and returns functional but bland implementations.
- * @author rob stryker (rob.stryker(a)redhat.com)
- *
- */
-public class AntExtensionManager implements IExtensionManager {
-
- public IArchiveType getArchiveType(String id) {
- final String typeId = id;
-
- return new IArchiveType () {
- public String getId() {
- return typeId;
- }
- public String getLabel() {
- return typeId;
- }
- public IArchive createDefaultConfiguration(String projectName, IProgressMonitor
monitor) {
- // do nothing, should not be called from ant
- return null;
- }
- public IArchive fillDefaultConfiguration(String projectName, IArchive topLevel,
IProgressMonitor monitor) {
- // do nothing, should not be called from ant
- return null;
- }
- };
- }
-
- public IArchiveType[] getArchiveTypes() {
- return new IArchiveType[0];
- }
-
- public IActionType getActionType(String id) {
- return null;
- }
-
- public IActionType[] getActionTypes() {
- return new IActionType[0];
- }
-
-}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntPreferenceManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntPreferenceManager.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntPreferenceManager.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,35 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import org.eclipse.core.runtime.IPath;
-import org.jboss.ide.eclipse.archives.core.model.IPreferenceManager;
-
-/**
- * This is to manage preferences relating to projects.
- * This is a candidate to be moved to eclipse-only API, or to be
- * fixed or changed to be more versatile.
- * @author rob stryker
- *
- */
-public class AntPreferenceManager implements IPreferenceManager {
-
- public boolean areProjectSpecificPrefsEnabled(IPath path) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public boolean isBuilderEnabled(IPath path) {
- // TODO Auto-generated method stub
- return false;
- }
-
- public void setBuilderEnabled(IPath path, boolean val) {
- // TODO Auto-generated method stub
-
- }
-
- public void setProjectSpecificPrefsEnabled(IPath path, boolean val) {
- // TODO Auto-generated method stub
-
- }
-
-}
Copied:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVFS.java
(from rev 9155,
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/AntVFS.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVFS.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -0,0 +1,52 @@
+package org.jboss.ide.eclipse.archives.core.ant;
+
+import org.apache.tools.ant.Task;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.IArchivesVFS;
+import org.jboss.ide.eclipse.archives.core.model.IVariableManager;
+import org.jboss.ide.eclipse.archives.core.xpl.StringSubstitutionEngineClone;
+
+public class AntVFS implements IArchivesVFS, IVariableManager {
+ private Task currentTask;
+ public void setCurrentTask(Task task) { currentTask = task; }
+ public Task getCurrentTask() { return currentTask; }
+
+ public String performStringSubstitution(String expression,
+ boolean reportUndefinedVariables) throws CoreException {
+ return new StringSubstitutionEngineClone().performStringSubstitution(expression,
reportUndefinedVariables, this);
+ }
+ public String performStringSubstitution(String expression,
+ String projectName, boolean reportUndefinedVariables)
+ throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public String[] getVariableNames() {
+ return new String[0];
+ }
+ public boolean containsVariable(String variable) {
+ return false;
+ }
+
+ public String getVariableValue(String variable, String arg) {
+ return null;
+ }
+ public IPath[] getWorkspaceChildren(IPath path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public IPath workspacePathToAbsolutePath(IPath path) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public String getVariableValue(String variable) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public String getProjectName(IPath absolutePath) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Deleted:
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-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/AntVariables.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,56 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import org.apache.tools.ant.Task;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.jboss.ide.eclipse.archives.core.model.IArchivesVFS;
-import org.jboss.ide.eclipse.archives.core.model.IVariableManager;
-import org.jboss.ide.eclipse.archives.core.xpl.StringSubstitutionEngineClone;
-
-public class AntVariables implements IArchivesVFS, IVariableManager {
- private Task currentTask;
- public void setCurrentTask(Task task) { currentTask = task; }
- public Task getCurrentTask() { return currentTask; }
-
- public String performStringSubstitution(String expression,
- boolean reportUndefinedVariables) throws CoreException {
- return new StringSubstitutionEngineClone().performStringSubstitution(expression,
reportUndefinedVariables, this);
- }
- public String performStringSubstitution(String expression,
- String projectName, boolean reportUndefinedVariables)
- throws CoreException {
- // TODO Auto-generated method stub
- return null;
- }
- public String[] getVariableNames() {
- return new String[0];
- }
- public boolean containsVariable(String variable) {
- return false;
- }
-
- public String getVariableValue(String variable, String arg) {
- return null;
- }
- public IPath[] getWorkspaceChildren(IPath path) {
- // TODO Auto-generated method stub
- return null;
- }
- public IPath workspacePathToAbsolutePath(IPath path) {
- // TODO Auto-generated method stub
- return null;
- }
- public IPath[] workspacePathToAbsolutePath(IPath[] paths) {
- // TODO Auto-generated method stub
- return null;
- }
- public String getVariableValue(String variable) {
- // TODO Auto-generated method stub
- return null;
- }
- public String getProjectName(IPath absolutePath) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceGroupTask.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceGroupTask.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceGroupTask.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,46 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import java.util.ArrayList;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.jboss.ide.eclipse.archives.core.ant.ResourceModel.EclipseResource;
-
-public class EclipseResourceGroupTask extends Task {
- private String id;
- private boolean global;
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public boolean isGlobal() {
- return global;
- }
- public void setGlobal(boolean global) {
- this.global = global;
- }
-
- public void execute() throws BuildException {
- if( id == null || id.equals("")) {
- throw new BuildException("id cannot be null or blank");
- } else {
- ResourceModel.getDefault().addResourceGroup(id, resources, global, this);
- }
- }
-
- ArrayList<EclipseResource> resources = new ArrayList<EclipseResource>();
- public EclipseResource createEclipseResource() {
- EclipseResource res = new EclipseResource();
- resources.add(res);
- return res;
- }
-}
-
-
-
-
-
-
-
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceTask.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceTask.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/EclipseResourceTask.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,49 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-
-public class EclipseResourceTask extends Task {
- private String eclipsePath;
- private String loc;
- private boolean global = false;
-
- public void execute() throws BuildException {
- if( eclipsePath == null )
- log("eclipsePath is null. Skipping " + getLocation(), Project.MSG_WARN);
- else if( loc == null )
- log("loc is null. Skipping " + getLocation(), Project.MSG_WARN);
- else {
- if( global ) {
- ResourceModel.getDefault().addGlobalReference(eclipsePath, loc,this);
- } else if( getOwningTarget() == null ||
getOwningTarget().getName().equals("")) {
- ResourceModel.getDefault().addProjectReference(getProject(), eclipsePath, loc,
this);
- } else {
- ResourceModel.getDefault().addTargetReference(getOwningTarget(), eclipsePath, loc,
this);
- }
- }
- }
-
- public String getEclipsePath() {
- return eclipsePath;
- }
- public void setEclipsePath(String eclipsePath) {
- this.eclipsePath = eclipsePath;
- }
- public String getLoc() {
- return loc;
- }
- public void setLoc(String loc) {
- this.loc = loc;
- }
-
- public boolean isGlobal() {
- return global;
- }
-
- public void setGlobal(boolean global) {
- this.global = global;
- }
-
-}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedAntExecution.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedAntExecution.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedAntExecution.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,293 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.util.Collection;
-import java.util.HashMap;
-
-import javax.xml.parsers.SAXParserFactory;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Ear;
-import org.apache.tools.ant.taskdefs.Jar;
-import org.apache.tools.ant.taskdefs.War;
-import org.apache.tools.ant.taskdefs.Zip;
-import org.apache.tools.ant.types.ZipFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModel;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.DefaultHandler;
-
-/************************************************************
- * IsolatedAntExecution is responsible for
- * IsolatedAntExecution functionality when antOnly=true
- * or a prerequisite is not met in the IsolatedTruezipExecution.
- *
- * @author Tom Crosman
- ***********************************************************/
-public class IsolatedAntExecution {
- /**
- * Packages file defaults to ".packages"
- */
- private String jbossPackages = IArchiveModel.DEFAULT_PACKAGES_FILE;
- private JBossArchivesTask parentTask;
-
- public IsolatedAntExecution(JBossArchivesTask parent) {
- parentTask = parent;
- }
-
- /**
- * Invoked by the handler to create a task specific to
- * the JBoss package. Initializes new task to the
- * parent environment. Package scope so only the handler
- * can invoke it.
- * @param type The ant task type to create.
- * @return the initialed task created.
- **/
- Zip createTask(String type) {
- Zip task = null;
- if ("jar".equals(type)) {
- task = new Jar();
- } else if ("war".equals(type)) {
- task = new War();
- } else if (type.indexOf("ear") != -1) {
- task = new Ear();
- } else if (type.indexOf("ejb") != -1) {
- task = new Jar();
- } else {
- throw new IllegalArgumentException("Unsupported type: " + type);
- }
-
- /** copy as much over as possible **/
- task.setDescription(parentTask.getDescription());
- task.setLocation(parentTask.getLocation());
- task.setOwningTarget(parentTask.getOwningTarget());
- task.setProject(parentTask.getProject());
- task.setRuntimeConfigurableWrapper(parentTask.getRuntimeConfigurableWrapper());
- task.setTaskName(parentTask.getTaskName());
- task.setTaskType(parentTask.getTaskType());
-
- return task;
- }
-
- /**
- * Configures and launches the parsing of our xml file.
- *
- * @param handler the DocumentHandler that support parsing the
- * authenticate.dtd formatted xml file.
- */
- private void parseMe(DefaultHandler handler) {
- try {
- SAXParserFactory parseFact = SAXParserFactory.newInstance();
- XMLReader parser = parseFact.newSAXParser().getXMLReader();
-
parser.setFeature("http://xml.org/sax/features/namespaces", true);
-
parser.setFeature("http://xml.org/sax/features/validation",
false);
- parser.setContentHandler(handler);
- parser
- .parse(new InputSource(
- new InputStreamReader(
- new FileInputStream(
- parentTask.getProject().getBaseDir()+ "/" +
jbossPackages))));
- } catch (Exception e) {
- e.printStackTrace();
-
- }
- }
-
- public void execute() throws BuildException {
- JBossPackagesHandler hndlr = new JBossPackagesHandler(parentTask);
- parseMe(hndlr);
- if (parentTask.isOutputAntTargetsOnly()) {
- parentTask.log("**** No Packages Created -- Ant Targets Only ****",
Project.MSG_INFO);
-
- HashMap<String, StringBuilder> antDefs = hndlr.getArchives();
- if (parentTask.getProcessArchive() != null) {
- StringBuilder b = antDefs.get(parentTask.getProcessArchive());
- if (b != null) {
- parentTask.log("Archive \"" +
parentTask.getProcessArchive() + "\" as a string: \n" + b);
- } else {
- String msg = "Archive \""+ parentTask.getProcessArchive()
+ "\" does not exist in the chosen project.";
- parentTask.log(msg, Project.MSG_ERR);
- throw new BuildException(msg);
- }
- } else {
- Collection<StringBuilder> antTasks = antDefs.values();
- for (StringBuilder b : antTasks) {
- parentTask.log("\n" + b.toString());
- }
- }
- parentTask.log("**** No Packages Created -- Ant Targets Only
****");
- } else {
- HashMap<String, Zip> tasks = hndlr.getTasks();
- if (parentTask.getProcessArchive() != null) {
- Zip task = tasks.get(parentTask.getProcessArchive());
- if (task != null) {
- parentTask.log("Executing ant task for " +
parentTask.getProcessArchive());
- task.execute();
- } else {
- parentTask.log("No Archive found: " +
parentTask.getProcessArchive(), Project.MSG_ERR);
- }
- } else {
- parentTask.log("Executing all tasks", Project.MSG_INFO);
- for (Zip tsk : tasks.values()) {
- tsk.execute();
- }
- }
- }
- }
-
- public class JBossPackagesHandler extends DefaultHandler {
-
- private final HashMap<String, StringBuilder> antTaskDefs;
- private final HashMap<String, Zip> tasks;
- private StringBuilder currArchive;
- private String folder;
- private HashMap<String, String> fileset;
- private Zip currentTask;
-
- /**
- * Creates a new JBossPackagesHandler.
- * @param bossArchiveAntTask
- */
- public JBossPackagesHandler(JBossArchivesTask jbossArchiveAntTask) {
- antTaskDefs = new HashMap<String, StringBuilder>();
- tasks = new HashMap<String, Zip>();
- }
-
- /**
- * The doFileset method.
- */
- private void doFileset(String fldr) {
- ZipFileSet set = new ZipFileSet();
- set.setDir(new File(fileset.get("dir")));
- currArchive.append(" <zipfileset dir='");
- currArchive.append(fileset.get("xmlDir") + "' ");
- if (folder != null) {
- currArchive.append("prefix='" + folder + "'
");
- set.setPrefix(folder);
-
- }
- String includes = fileset.get("includes");
- String excludes = fileset.get("excludes");
- if (includes != null) {
- currArchive.append("includes='" + includes + "'
");
- set.setIncludes(includes);
- } else {
- set.setIncludes("");
- }
- if (excludes != null) {
- currArchive.append("excludes='" + excludes + "'
");
- set.setExcludes(excludes);
- } else {
- set.setExcludes("");
- }
-
- currArchive.append("/>\n");
- currentTask.addFileset(set);
- fileset = null;
- }
-
- /**
- * {@inheritDoc}.
- * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String,
java.lang.String, java.lang.String)
- */
- @Override
- public void endElement(String uri, String localName, String name)
- throws SAXException {
- if ("package".equals(localName) && (currArchive != null))
{
- currArchive.append(" </jar>\n");
- currArchive.append("</target>\n");
-
- } else if ("folder".equals(localName)) {
- if (folder != null) {
- int slash = folder.lastIndexOf('/');
- if (slash == -1) {
- folder = null;
- } else {
- folder = folder.substring(0, slash);
- }
-
- }
-
- } else if ("fileset".equals(localName)) {
- doFileset(folder);
- }
- }
-
- /**
- * Property getter for archives.
- * @return Returns the archives.
- */
- public HashMap<String, StringBuilder> getArchives() {
- return antTaskDefs;
- }
-
- /**
- * Property getter for tasks.
- * @return Returns the tasks.
- */
- public HashMap<String, Zip> getTasks() {
- return tasks;
- }
-
- /**
- * {@inheritDoc}.
- * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String,
java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- @Override
- public void startElement(String uri, String localName, String name,
- Attributes attributes) throws SAXException {
- if ("package".equals(localName)) {
- String type = attributes.getValue("type");
- String taskName = attributes.getValue("name");
- currentTask = createTask(type);
- tasks.put(taskName, currentTask);
-
- try {
- currArchive = new StringBuilder("<target name='");
-
- antTaskDefs.put(taskName, currArchive);
-
- String tName = attributes.getValue("name");
- currArchive.append(tName);
- currArchive.append("' description='build " + tName
+ "' >\n");
- String tmpToDir = attributes.getValue("todir");
- String toDir =
- tmpToDir.substring(tmpToDir.lastIndexOf("/") + 1);
- currArchive.append(" <mkdir dir='" + toDir +
"' />\n");
-
- currArchive.append(" <jar destfile='" + toDir +
"/" + tName
- + "'>\n");
-
- currentTask.setDestFile(new File(currentTask.getProject()
- .getBaseDir()
- + "/" + toDir + "/" + tName));
- } catch (IllegalArgumentException iae) {
- currArchive = null;
- currentTask = null;
- iae.printStackTrace();
- }
- } else if ("folder".equals(localName)) {
- if (folder == null) {
- folder = attributes.getValue("name");
- } else {
- folder = folder + "/" +
attributes.getValue("name");
- }
- } else if ("fileset".equals(localName)) {
- fileset = new HashMap<String, String>();
- String dir = attributes.getValue("dir").substring(1);
- String xmlDir = dir.substring(dir.indexOf("/") + 1);
- String includes = attributes.getValue("includes");
- String excludes = attributes.getValue("excludes");
- fileset.put("includes", includes);
- fileset.put("excludes", excludes);
- fileset.put("dir", xmlDir);
- fileset.put("xmlDir", xmlDir);
- }
- }
- }
-}
\ No newline at end of file
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,163 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import java.util.ArrayList;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-import org.jboss.ide.eclipse.archives.core.model.IArchive;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
-import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
-
-public class IsolatedTruezipExecution {
- private JBossArchivesTask task;
- public IsolatedTruezipExecution(JBossArchivesTask task) {
- this.task = task;
- }
- public void execute() {
- ClassLoader original = Thread.currentThread().getContextClassLoader();
- IArchiveBuildListener listener = getListener();
-
- task.log("Executing task using truezip. " + task.getLocation(),
Project.MSG_VERBOSE);
- ResourceModel.getDefault();
-
- // needed so the correct XML binding / TrueZIP jars are loaded
- ClassLoader myCL = getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(myCL);
-
- ((AntVariables)ArchivesCore.getInstance().getVFS()).setCurrentTask(task);
- // figure out which one to build
- ArchivesModel.instance().addBuildListener(listener);
- IPath path = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new
Path(task.getEclipseProject()));
- if( verifyBuildPrereqs(path) ) {
- task.log("Building archives for project project: " + path,
Project.MSG_VERBOSE);
- new ArchiveBuildDelegate().fullProjectBuild(path);
- } else {
- throw new BuildException("Eclipse-relative paths missing absolute path
mappings.");
- }
-
- ArchivesModel.instance().removeBuildListener(listener);
- Thread.currentThread().setContextClassLoader(original);
- }
-
-
- protected boolean verifyBuildPrereqs(IPath path) {
- // get the project's location
- if( path == null ) {
- task.log("Could not find a project location for " +
task.getEclipseProject(), Project.MSG_ERR);
- return false;
- }
-
- if( ArchivesModel.instance().getRoot(path) == null) {
- task.log("Registering project: " + path + ". ",
Project.MSG_VERBOSE);
- try {
- ArchivesModel.instance().registerProject(path, null);
- } catch( ArchivesModelException ame ) {
- // log it
- }
- }
-
- IArchiveModelRootNode node = ArchivesModel.instance().getRoot(path);
- final ArrayList<String> requiredProjects = new ArrayList<String>();
- node.accept(new IArchiveNodeVisitor() {
- public boolean visit(IArchiveNode node) {
- if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
- IArchive archive = (IArchive)node;
- if( archive.isTopLevel() && archive.isDestinationInWorkspace() ) {
- IPath p = archive.getDestinationPath();
- if( p != null ) {
- String projName = p.segment(0);
- if( !requiredProjects.contains(projName))
- requiredProjects.add(projName);
- }
- }
- } else if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET) {
- IArchiveFileSet fs = (IArchiveFileSet)node;
- if( fs.isInWorkspace() ) {
- IPath p = fs.getSourcePath();
- if( p != null ) {
- String projName = p.segment(0);
- if(!requiredProjects.contains(projName))
- requiredProjects.add(projName);
- }
- }
- }
- return true;
- }
- });
-
- boolean retVal = true;
- AntVariables vars = ((AntVariables)ArchivesCore.getInstance().getVFS());
- for( int i = 0; i < requiredProjects.size(); i++ ) {
- IPath p = vars.workspacePathToAbsolutePath(new Path(requiredProjects.get(i)));
- if( p == null ) {
- retVal = false;
- task.log("Required project \"" + requiredProjects.get(i) +
- "\" has unknown location. " + task.getLocation(), Project.MSG_ERR);
- }
- }
-
- return retVal;
- }
-
- protected IArchiveBuildListener getListener() {
- return new IArchiveBuildListener() {
-
- public void buildFailed(IArchive pkg, IStatus status) {
- task.log("buildFailed: ", Project.MSG_DEBUG);
- }
-
- public void cleanArchive(IArchive pkg) {
- task.log("cleanArchive", Project.MSG_DEBUG);
- }
-
- public void cleanProject(IPath project) {
- task.log("cleanProject", Project.MSG_DEBUG);
- }
-
- public void fileUpdated(IArchive topLevelArchive,
- IArchiveFileSet fileset, IPath filePath) {
- task.log("fileUpdated", Project.MSG_DEBUG);
- }
-
- public void finishedBuild(IPath project) {
- task.log("finishedBuild", Project.MSG_DEBUG);
- }
-
- public void finishedBuildingArchive(IArchive pkg) {
- task.log("finishedBuildingArchive", Project.MSG_DEBUG);
- }
-
- public void finishedCollectingFileSet(IArchiveFileSet fileset) {
- task.log("finishedCollectingFileSet", Project.MSG_DEBUG);
- }
-
- public void startedBuild(IPath project) {
- task.log("startedBuild", Project.MSG_DEBUG);
- }
-
- public void startedBuildingArchive(IArchive pkg) {
- task.log("startedBuildingArchive", Project.MSG_DEBUG);
- }
-
- public void startedCollectingFileSet(IArchiveFileSet fileset) {
- task.log("startedCollectingFileSet", Project.MSG_DEBUG);
- }
-
- public void fileRemoved(IArchive topLevelArchive,
- IArchiveFileSet fileset, IPath filePath) {
- task.log("fileRemoved: " + filePath, Project.MSG_DEBUG);
- }
-
- };
- }
-}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/JBossArchivesTask.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/JBossArchivesTask.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/JBossArchivesTask.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,97 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import java.util.ArrayList;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.jboss.ide.eclipse.archives.core.ant.ResourceModel.EclipseResource;
-
-public class JBossArchivesTask extends Task {
- private static boolean linkError = false;
-
- private boolean antOnly = false;
- private boolean outputAntTargetsOnly = false;
- private String processArchive;
- private String eclipseProject;
- private String refs;
-
- public void init() throws BuildException {
- }
-
- public void execute() throws BuildException {
- // parse children and add them to the map
- ResourceModel.getDefault().setTaskEnvironment(this, resources, refs);
- Throwable t = null;
- if( !antOnly && !linkError) {
- try {
- executeTrueZip();
- } catch( LinkageError le ) {
- t = le;
- linkError = true;
- log("Linkage Error using Truezip. Falling back to ant", Project.MSG_WARN);
- }
- }
- if( antOnly || t != null ) {
- executeAntOnly();
- }
- }
-
-
- ArrayList<EclipseResource> resources = new ArrayList<EclipseResource>();
- public EclipseResource createEclipseResource() {
- EclipseResource res = new EclipseResource();
- resources.add(res);
- return res;
- }
-
-
- protected void executeTrueZip() {
- // isolating to another file to avoid ant errors.
- new IsolatedTruezipExecution(this).execute();
- }
-
- protected void executeAntOnly() {
- new IsolatedAntExecution(this).execute();
- }
-
- public boolean isAntOnly() {
- return antOnly;
- }
-
- public void setAntOnly(boolean antOnly) {
- this.antOnly = antOnly;
- }
-
- public boolean isOutputAntTargetsOnly() {
- return outputAntTargetsOnly;
- }
-
- public void setOutputAntTargetsOnly(boolean outputAntTargetsOnly) {
- this.outputAntTargetsOnly = outputAntTargetsOnly;
- }
-
- public String getProcessArchive() {
- return processArchive;
- }
-
- public void setProcessArchive(String processArchive) {
- this.processArchive = processArchive;
- }
-
- public String getEclipseProject() {
- return eclipseProject;
- }
-
- public void setEclipseProject(String eclipseProject) {
- this.eclipseProject = eclipseProject;
- }
-
- public String getRefs() {
- return refs;
- }
-
- public void setRefs(String environment) {
- this.refs = environment;
- }
-}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/ResourceModel.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/ResourceModel.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/ResourceModel.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,239 +0,0 @@
-package org.jboss.ide.eclipse.archives.core.ant;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
-import org.apache.tools.ant.Task;
-import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-
-public class ResourceModel {
- private static ResourceModel model;
- private static ArchivesCore archivesCore = null;
- public static ResourceModel getDefault() {
- if( model == null ) {
- model = new ResourceModel();
- try {
- archivesCore = new AntArchivesCore();
- ArchivesCore.setInstance(archivesCore);
- } catch( LinkageError le ) {
- // ignore. the archives task will figure it out later
- }
- }
- return model;
- }
-
- private HashMap globals, globalGroups;
- private HashMap projects, projectGroups;
- private HashMap targets, targetGroups;
- private HashMap tasks;
-
- public ResourceModel() {
- globals = new HashMap();
- globalGroups = new HashMap();
- projects = new HashMap();
- projectGroups = new HashMap();
- targets = new HashMap();
- targetGroups = new HashMap();
- tasks = new HashMap();
- }
-
- public void addGlobalReference(String path, String loc, Task task) {
- if( !globals.containsKey(path)) {
- globals.put(path, loc);
- task.log("added global-scoped reference for " + path, Project.MSG_VERBOSE);
- } else {
- task.log("eclipse path " + path + " already declared globally.
Skipping. " + task.getLocation(), Project.MSG_INFO);
- }
- }
-
- public void addProjectReference(Project project, String path, String loc, Task task) {
- HashMap map = (HashMap)projects.get(project);
- if( map == null ) {
- map = new HashMap();
- projects.put(project, map);
- }
- if( !map.containsKey(path)) {
- map.put(path, loc);
- task.log("added project-scoped reference for " + path,
Project.MSG_VERBOSE);
- } else {
- task.log("eclipse path " + path + " already declared in this project.
Skipping. " + task.getLocation(), Project.MSG_INFO);
- }
- }
-
-
- public void addTargetReference(Target target, String path, String loc, Task task) {
- HashMap map = (HashMap)targets.get(target);
- if( map == null ) {
- map = new HashMap();
- targets.put(target, map);
- }
- if( !map.containsKey(path)) {
- map.put(path, loc);
- task.log("added target-scoped reference for " + path + ", target="
+ target, Project.MSG_VERBOSE);
- } else {
- task.log("eclipse path " + path + " already declared in this target.
Skipping. " + task.getLocation(), Project.MSG_INFO);
- }
- }
-
- public void addResourceGroup(String id, ArrayList resources, boolean global, Task task)
{
- boolean hasTarget = !(task.getOwningTarget() == null ||
task.getOwningTarget().getName().equals(""));
- HashMap map = global ? globalGroups : hasTarget ? targetGroups : projectGroups;
- String scope = global ? "global" : hasTarget ? "target" :
"project";
- HashMap inner = getInnerResourceMap(task, resources);
-
- if( global && map.containsKey(id)) {
- task.log("Cannot add " + id + " with scope " + scope + ". An
item with that id has already been added. " + task.getLocation(), Project.MSG_INFO);
- } else if( global ) {
- map.put(id, inner);
- task.log("added " + scope + "-scoped map with id \"" + id +
"\" to " + map, Project.MSG_VERBOSE);
- } else {
- Object mainKey = hasTarget ? (Object)task.getOwningTarget() : task.getProject();
- HashMap midMap = (HashMap)map.get(mainKey);
- if( midMap == null ) {
- midMap = new HashMap();
- map.put(mainKey, midMap);
- }
- if( midMap.containsKey(id)) {
- task.log("Cannot add " + id + " with scope " + scope + ". An
item with that id has already been added. " + task.getLocation(), Project.MSG_INFO);
- } else {
- midMap.put(id, inner);
- task.log("added " + scope + "-scoped map with id \"" + id +
"\" to " + map, Project.MSG_VERBOSE);
- }
- }
- }
-
- protected HashMap getInnerResourceMap(Task task, ArrayList resources) {
- HashMap ret = new HashMap();
- for (Iterator it=resources.iterator(); it.hasNext(); ) {
- EclipseResource resource = (EclipseResource)it.next();
- if( resource.getEclipsePath() == null )
- task.log("eclipsePath is null. skipping " + task.getLocation(),
Project.MSG_INFO);
- else if( resource.getLoc() == null )
- task.log("loc is null. skipping " + task.getLocation(),
Project.MSG_INFO);
- else {
- ret.put(resource.getEclipsePath(), resource.getLoc());
- }
- }
- return ret;
- }
-
- public void setTaskEnvironment(Task task, ArrayList resources, String refs) {
- // add the directly added stuff
- HashMap pathToLoc = new HashMap();
- for (Iterator it=resources.iterator(); it.hasNext(); ) {
- EclipseResource resource = (EclipseResource)it.next();
- if( resource.getEclipsePath() == null ) {
- task.log("eclipsePath is null. skipping " + task.getLocation(),
Project.MSG_INFO);
- } else if( resource.getLoc() == null ) {
- task.log("loc is null. skipping " + task.getLocation(),
Project.MSG_INFO);
- } else if( pathToLoc.containsKey(resource.getEclipsePath())){
- task.log("path " + resource.getEclipsePath() + " already added.
Ignoring.", Project.MSG_INFO);
- pathToLoc.put(resource.getEclipsePath(), resource.getLoc());
- }
- }
-
- // add anything in the current target
- if( task.getOwningTarget() != null ) {
- HashMap inner = (HashMap)targets.get(task.getOwningTarget());
- if( inner != null ) {
- Iterator i = inner.keySet().iterator();
- while(i.hasNext()) {
- String key = (String)i.next();
- if( !pathToLoc.containsKey(key)) {
- pathToLoc.put(key, inner.get(key));
- }
- }
- }
- }
-
- // add projects
- if( task.getProject() != null ) {
- HashMap inner = (HashMap)projects.get(task.getProject());
- if( inner != null ) {
- Iterator i = inner.keySet().iterator();
- while(i.hasNext()) {
- String key = (String)i.next();
- if( !pathToLoc.containsKey(key)) {
- pathToLoc.put(key, inner.get(key));
- }
- }
- }
- }
-
- // add globals
- Iterator i = globals.keySet().iterator();
- while(i.hasNext()) {
- String key = (String)i.next();
- if( !pathToLoc.containsKey(key)) {
- pathToLoc.put(key, globals.get(key));
- }
- }
-
- // add referenced groups
- if( refs != null ) {
- String[] refIDs = refs.split(",");
- for( int j = 0; j < refIDs.length; j++ ) {
- HashMap tmp = getGroup(task, refIDs[j]);
- i = tmp.keySet().iterator();
- while(i.hasNext()) {
- String key = (String)i.next();
- if( pathToLoc.containsKey(key))
- task.log("Path " + key + " already included. Overriding. " +
task.getLocation(), Project.MSG_INFO);
- pathToLoc.put(key, tmp.get(key));
- }
- }
- }
- tasks.put(task, pathToLoc);
- }
-
- protected HashMap getGroup(Task task, String id) {
- if( id.equals("")) return new HashMap();
- if( task.getOwningTarget() != null ) {
- Target t = task.getOwningTarget();
- HashMap group = (HashMap)targetGroups.get(t);
- if( group != null && group.containsKey(id))
- return (HashMap)group.get(id);
- }
-
- if( task.getProject() != null ) {
- Project p = task.getProject();
- HashMap group = (HashMap)projectGroups.get(p);
- if( group != null && group.containsKey(id))
- return (HashMap)group.get(id);
- }
-
- if( globalGroups.containsKey(id) && globalGroups.get(id) != null)
- return (HashMap)globalGroups.get(id);
- task.log("Group refid " + id + " not found. " + task.getLocation(),
Project.MSG_INFO);
- return new HashMap();
- }
-
- public HashMap getTaskEnvironment(Task t) {
- HashMap map = (HashMap)tasks.get(t);
- if( map == null ) return new HashMap();
- return (HashMap)(map.clone());
- }
-
-
- public static class EclipseResource {
- private String eclipsePath;
- private String loc;
- public String getEclipsePath() {
- return eclipsePath;
- }
- public void setEclipsePath(String eclipsePath) {
- this.eclipsePath = eclipsePath;
- }
- public String getLoc() {
- return loc;
- }
- public void setLoc(String loc) {
- this.loc = loc;
- }
- }
-
-
-}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/antlib.xml
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/antlib.xml 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/antlib.xml 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,3 +0,0 @@
-<antlib>
- <taskdef
resource="org/jboss/ide/eclipse/archives/core/ant/tasks.properties"/>
-</antlib>
\ No newline at end of file
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/tasks.properties
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/tasks.properties 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/tasks.properties 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,3 +0,0 @@
-eclipseResource=org.jboss.ide.eclipse.archives.core.ant.EclipseResourceTask
-eclipseResourceGroup=org.jboss.ide.eclipse.archives.core.ant.EclipseResourceGroupTask
-jbossArchives=org.jboss.ide.eclipse.archives.core.ant.JBossArchivesTask
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -38,6 +38,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
@@ -90,11 +91,12 @@
EventManager.startedBuildingArchive(pkg);
ModelTruezipBridge.deleteArchive(pkg);
- if( !pkg.getGlobalDestinationPath().toFile().exists() ) {
- if( !pkg.getGlobalDestinationPath().toFile().mkdirs() ) {
+ IPath dest = PathUtils.getGlobalLocation(pkg);
+ if( dest != null && !dest.toFile().exists() ) {
+ if( !dest.toFile().mkdirs() ) {
ArchivesCore.getInstance().getLogger().log(IStatus.WARNING,
"Cannot Build archive \"" + pkg.getName() +
- "\". Output location " + pkg.getGlobalDestinationPath() +
+ "\". Output location " + dest +
" is not writeable", null);
return;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -25,11 +25,12 @@
import java.util.ArrayList;
import java.util.HashMap;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
/**
* Utility methods to create scanners for matching
@@ -43,19 +44,20 @@
public String excludes;
public boolean inWorkspace;
public String projectName;
+ public double version;
};
public static DirectoryScannerExtension createDirectoryScanner(IArchiveFileSet fs,
boolean scan) {
- return createDirectoryScanner(fs.getRawSourcePath(), fs.getRootArchiveRelativePath(),
fs.getIncludesPattern(), fs.getExcludesPattern(), fs.getProjectName(), fs.isInWorkspace(),
scan);
+ return createDirectoryScanner(fs.getRawSourcePath(), fs.getRootArchiveRelativePath(),
+ fs.getIncludesPattern(), fs.getExcludesPattern(), fs.getProjectName(),
+ fs.isInWorkspace(), fs.getDescriptorVersion(), scan);
}
-
- // THIS SHOULD NOT BE USED ;) just here for now
- // eradicate all uses!
- public static DirectoryScannerExtension createDirectoryScanner (String rawPath, String
includes, String excludes, boolean scan) {
- return createDirectoryScanner(rawPath, null, includes, excludes, null, false, scan);
- }
- public static DirectoryScannerExtension createDirectoryScanner (String rawPath, IPath
rootArchiveRelativePath, String includes, String excludes, String projectName, boolean
inWorkspace, boolean scan) {
+ public static DirectoryScannerExtension createDirectoryScanner (
+ String rawPath, IPath rootArchiveRelativePath,
+ String includes, String excludes, String projectName,
+ boolean inWorkspace, double version, boolean scan) {
+
ScannableFileSet fs = new ScannableFileSet();
fs.rawPath = rawPath;
fs.rootArchiveRelativePath = rootArchiveRelativePath;
@@ -63,6 +65,7 @@
fs.excludes = excludes;
fs.inWorkspace = inWorkspace;
fs.projectName = projectName;
+ fs.version = version;
DirectoryScannerExtension scanner = new DirectoryScannerExtension(fs);
if (scan) {
scanner.scan();
@@ -97,34 +100,17 @@
}
public void setBasedir2(String path) {
- String translatedPath = refine(path);
- if( translatedPath != null ) {
- IPath translatedPath2 = new Path(translatedPath);
- if( workspaceRelative ) {
- IPath p = ArchivesCore.getInstance().getVFS()
- .workspacePathToAbsolutePath(translatedPath2);
- setBasedir(new FileWrapper(p.toFile(), translatedPath2));
- } else {
- setBasedir(new FileWrapper(new File(translatedPath), translatedPath2));
- }
+
+ IPath translatedPath = new Path(PathUtils.getAbsoluteLocation(path, fs.projectName,
fs.inWorkspace, fs.version));
+ if( workspaceRelative ) {
+ IPath p = PathUtils.getGlobalLocation(path, fs.projectName, true, fs.version);
+ setBasedir(new FileWrapper(p.toFile(), translatedPath));
+ } else {
+ setBasedir(new FileWrapper(translatedPath.toFile(), translatedPath));
}
}
- public String refine(String rawPath) {
- try {
- String refined = ArchivesCore.getInstance().getVFS().
- performStringSubstitution(rawPath, fs.projectName, true);
- if( workspaceRelative ) {
- IPath p = new Path(refined);
- if( !p.isAbsolute() )
- p = new Path(fs.projectName).append(p).makeAbsolute();
- return p.toString();
- }
- return refined;
- } catch( CoreException ce ) {
- }
- return null;
- }
- protected String getName(File file) {
+
+ protected String getName(File file) {
return workspaceRelative ? ((FileWrapper)file).getOutputName() :
super.getName(file);
}
@@ -143,8 +129,7 @@
IPath[] childrenWorkspace = ArchivesCore.getInstance()
.getVFS().getWorkspaceChildren(workspaceRelative);
- IPath[] childrenAbsolute = ArchivesCore.getInstance()
- .getVFS().workspacePathToAbsolutePath(childrenWorkspace);
+ IPath[] childrenAbsolute = globalize(childrenWorkspace);
File[] files = new File[childrenAbsolute.length];
for( int i = 0; i < files.length; i++ ) {
files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i]);
@@ -152,6 +137,14 @@
return files;
}
+ protected IPath[] globalize(IPath[] paths) {
+ IPath[] results = new IPath[paths.length];
+ for( int i = 0; i < paths.length; i++ )
+ results[i] = ArchivesCore.getInstance()
+ .getVFS().workspacePathToAbsolutePath(paths[i]);
+ return results;
+ }
+
protected File[] list2absolute(File file) {
File[] children = file.listFiles();
FileWrapper[] children2 = new FileWrapper[children.length];
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchive.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -77,28 +77,8 @@
* @return the path
*/
public IPath getArchiveFilePath();
-
- /**
- * If top level:
- * The absolute raw file system path to the
- * destination (containing folder) of this archive
- * Else
- * The empty path
- * @return An IPath to this package's destination folder
- */
- public IPath getGlobalDestinationPath();
/**
- * If top level:
- * A path representing the string from the delegate
- * May be work-space relative or global
- * Else
- * The empty path
- * @return
- */
- public IPath getDestinationPath();
-
- /**
* Exactly as from the delegate
* @return
*/
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -54,25 +54,11 @@
public boolean isFlattened();
/**
- * Returns the absolute file-system relative source path
- * @return The path to the source folder ("basedir" in ant terminology) for
this fileset.
- */
- public IPath getGlobalSourcePath();
-
- /**
* @return the source path from the delegate with no translation at all
*/
public String getRawSourcePath();
/**
- * Return a source path that is file-system or workspace
- * relative but has all of its variables translated already.
- *
- * @return the source path from the delegate (file-system or workspace-relative)
- */
- public IPath getSourcePath();
-
- /**
* Force the scanner to check for matched files again
*/
public void resetScanner();
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelRootNode.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelRootNode.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveModelRootNode.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding.XbException;
@@ -32,7 +33,12 @@
*
*/
public interface IArchiveModelRootNode extends IArchiveNode {
+ public static final double DESCRIPTOR_VERSION_1_0 = 1.0;
+ public static final double DESCRIPTOR_VERSION_1_2 = 1.2;
+
public void setModel(IArchiveModel model);
public IArchiveModel getModel();
public void save(IProgressMonitor monitor) throws ArchivesModelException;
+ public double getDescriptorVersion();
+ public void setDescriptorVersion(double d);
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveNode.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -164,6 +164,13 @@
public IArchiveModelRootNode getModelRootNode();
/**
+ * Get the descriptor version that this node is using.
+ * If the node is unattached to a descriptor object,
+ * use the latest descriptor version.
+ */
+ public double getDescriptorVersion();
+
+ /**
* Get the path relative to the root archive,
* or null if not applicable.
* @return
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchivesVFS.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -45,8 +45,21 @@
* @return
*/
public IPath workspacePathToAbsolutePath(IPath path);
- public IPath[] workspacePathToAbsolutePath(IPath[] paths);
+
+ /**
+ * Get the project name that matches this path
+ * @param absolutePath
+ * @return
+ */
public String getProjectName(IPath absolutePath);
- public String performStringSubstitution(String expression, boolean
reportUndefinedVariables) throws CoreException;
+
+ /**
+ * Substitute some strings
+ * @param expression
+ * @param projectName
+ * @param reportUndefinedVariables
+ * @return
+ * @throws CoreException
+ */
public String performStringSubstitution(String expression, String projectName, boolean
reportUndefinedVariables) throws CoreException;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -25,16 +25,15 @@
import java.util.HashMap;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
/**
* An implementation for filesets
@@ -79,44 +78,15 @@
}
/*
- * @see IArchiveFileSet#getGlobalSourcePath()
- */
- public IPath getGlobalSourcePath() {
- IPath ret;
- String path = getFileSetDelegate().getDir();
- if (path == null || path.equals(".") || path.equals("")) {
- ret = getProjectPath();
- } else if( isInWorkspace()){
- ret = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new Path(path));
- } else {
- ret = new Path(path);
- }
- return ret;
- }
-
- /*
* (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#getRawSourcePath()
*/
public String getRawSourcePath() {
return getFileSetDelegate().getDir();
}
+
/*
- * @see IArchiveFileSet#getSourcePath()
- */
- public IPath getSourcePath() {
- try {
- String out = ArchivesCore.getInstance().getVFS().
- performStringSubstitution(getRawSourcePath(),
- getProjectName(), true);
- return new Path(out);
- } catch( CoreException ce ) {
- }
- return null;
- }
-
- /*
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#isFlattened()
*/
public boolean isFlattened() {
@@ -272,8 +242,7 @@
}
public boolean canBuild() {
- return getGlobalSourcePath() != null
- && super.canBuild();
+ return PathUtils.getGlobalLocation(this) != null && super.canBuild();
}
public String toString() {
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveImpl.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -23,7 +23,6 @@
import java.util.ArrayList;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
@@ -36,6 +35,7 @@
import org.jboss.ide.eclipse.archives.core.model.INamedContainerArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackage;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
/**
* An archive
@@ -68,34 +68,6 @@
return packageDelegate.isInWorkspace();
}
- /*
- * @see IArchive#getDestinationPath()
- */
- public IPath getGlobalDestinationPath () {
- if (!isTopLevel() || packageDelegate.getToDir() == null ||
packageDelegate.getToDir().equals(""))
- return Path.EMPTY;
- if( packageDelegate.getToDir().equals("."))
- return getProjectPath() == null ? Path.EMPTY : getProjectPath();
-
- try {
- String replaced = ArchivesCore.getInstance().getVFS().
- performStringSubstitution(packageDelegate.getToDir(), getProjectName(), true);
- if (isDestinationInWorkspace()) {
- return ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new
Path(replaced));
- } else {
- return new Path(replaced);
- }
- } catch( CoreException ce ) {
- }
- return null;
- }
-
- public IPath getDestinationPath() {
- if( !isTopLevel() )
- return Path.EMPTY;
- return packageDelegate.getToDir() == null ? Path.EMPTY : new
Path(packageDelegate.getToDir());
- }
-
public String getRawDestinationPath() {
if( !isTopLevel() )
return "";
@@ -107,7 +79,8 @@
* @see IArchive#getArchiveFilePath()
*/
public IPath getArchiveFilePath() {
- return getGlobalDestinationPath().append(getName());
+ IPath p = PathUtils.getGlobalLocation(this);
+ return p == null ? null : p.append(getName());
}
/*
@@ -200,7 +173,7 @@
* @see IArchive#setDestinationPath(IPath, boolean)
*/
public void setDestinationPath(IPath path) {
- IPath destPath = getDestinationPath();
+ String destPath = getRawDestinationPath();
attributeChanged(DESTINATION_ATTRIBUTE, destPath == null ? null : destPath.toString(),
path == null ? null : path.toString());
packageDelegate.setToDir(path.toString());
}
@@ -284,7 +257,6 @@
}
public boolean canBuild() {
- return getGlobalDestinationPath() != null
- && super.canBuild();
+ return PathUtils.getGlobalLocation(this) != null && super.canBuild();
}
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -33,7 +33,6 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
-import org.jboss.ide.eclipse.archives.core.model.INamedContainerArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbPackages;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XMLBinding.XbException;
@@ -145,6 +144,14 @@
this.model = model;
}
+ public double getDescriptorVersion() {
+ return ((XbPackages)getNodeDelegate()).getVersion();
+ }
+
+ public void setDescriptorVersion(double d) {
+ ((XbPackages)getNodeDelegate()).setVersion(d);
+ }
+
/**
* I have no relative path. I'm above the root archive
* @see
org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRootArchiveRelativePath()
@@ -180,10 +187,10 @@
for( int i = 0; i < children.length; i++ ) {
child = (IArchive)children[i];
- if( child.getGlobalDestinationPath() != null )
- p = child.getGlobalDestinationPath().append(child.getName());
+ if( child.getArchiveFilePath() != null )
+ p = child.getArchiveFilePath();
else
- p = child.getDestinationPath().append(child.getName());
+ return false;
if( list.contains(p))
return false;
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveNodeImpl.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -89,6 +89,16 @@
/*
* (non-Javadoc)
+ * @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getDescriptorVersion()
+ */
+ public double getDescriptorVersion() {
+ IArchiveModelRootNode root = getModelRootNode();
+ return root != null ? root.getDescriptorVersion() :
+ IArchiveModelRootNode.DESCRIPTOR_VERSION_1_2;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.ide.eclipse.archives.core.model.IArchiveNode#getRootArchive()
*/
public IArchive getRootArchive() {
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/xb/XbPackages.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -25,7 +25,7 @@
public class XbPackages extends XbPackageNodeWithProperties {
- private float version;
+ private double version;
public XbPackages () {
super();
}
@@ -47,11 +47,11 @@
return getChildren(XbPackage.class);
}
- public float getVersion() {
+ public double getVersion() {
return version;
}
- public void setVersion(float version) {
+ public void setVersion(double version) {
this.version = version;
}
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -27,6 +27,7 @@
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
Added:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/PathUtils.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/PathUtils.java
(rev 0)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/PathUtils.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -0,0 +1,79 @@
+package org.jboss.ide.eclipse.archives.core.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+
+public class PathUtils {
+ public static IPath getGlobalLocation(IArchiveNode node) {
+ if( node instanceof IArchive ) {
+ IArchive a = (IArchive)node;
+ return getGlobalLocation(a.getRawDestinationPath(),
+ a.getProjectName(), a.isDestinationInWorkspace(),
+ a.getDescriptorVersion());
+ }
+ else if( node instanceof IArchiveFileSet ) {
+ IArchiveFileSet a = (IArchiveFileSet)node;
+ return getGlobalLocation(a.getRawSourcePath(),
+ a.getProjectName(), a.isInWorkspace(),
+ a.getDescriptorVersion());
+ }
+ return null;
+ }
+
+ public static String getAbsoluteLocation(IArchiveNode node) {
+ if( node instanceof IArchive ) {
+ IArchive a = (IArchive)node;
+ return getAbsoluteLocation(a.getRawDestinationPath(), a.getProjectName(),
a.isDestinationInWorkspace(), a.getDescriptorVersion());
+ }
+ else if( node instanceof IArchiveFileSet ) {
+ IArchiveFileSet a = (IArchiveFileSet)node;
+ return getAbsoluteLocation(a.getRawSourcePath(), a.getProjectName(),
a.isInWorkspace(), a.getDescriptorVersion());
+ }
+ return null;
+ }
+
+ // Get the actual file located on the filesystem
+ public static IPath getGlobalLocation(String expression,
+ String projectName, boolean inWorkspace, double version) {
+ String absolute = getAbsoluteLocation(expression, projectName, inWorkspace, version);
+ if( absolute != null ) {
+ if( inWorkspace ) {
+ IPath p = ArchivesCore.getInstance().getVFS()
+ .workspacePathToAbsolutePath(new Path(absolute));
+ return p;
+ }
+ return new Path(absolute);
+ }
+ return null;
+ }
+
+ // Get an absolute path, workspace-absolute or fs-absolute
+ public static String getAbsoluteLocation(String expression,
+ String projectName, boolean inWorkspace, double version) {
+
+ if( "".equals(expression) || ".".equals(expression))
+ return new Path(projectName).makeAbsolute().toString();
+
+ try {
+ String translated = ArchivesCore.getInstance().getVFS().
+ performStringSubstitution(expression, projectName, true);
+ if( inWorkspace && version >= 1.2) {
+ IPath p = new Path(translated);
+ if( !p.isAbsolute() )
+ p = new Path(projectName).append(p).makeAbsolute();
+ return p.toString();
+ } else {
+ // should be workspace relative already
+ return new Path(translated).makeAbsolute().toString();
+ }
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ }
+ return null;
+ }
+}
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-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -33,6 +33,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import de.schlichtherle.io.ArchiveDetector;
import de.schlichtherle.io.File;
@@ -54,7 +55,7 @@
public class ModelTruezipBridge {
public static void deleteArchive(IArchive archive) {
final File file = getFile(archive);
- file.deleteAll();
+ boolean b = file.deleteAll();
TrueZipUtil.sync();
}
@@ -255,7 +256,7 @@
ArchiveDetector detector = exploded ? ArchiveDetector.NULL :
TrueZipUtil.getJarArchiveDetector();
if( parentFile == null ) {
// we're a root archive, and so the destination folder must be a real folder
- IPath p = node2.getGlobalDestinationPath();
+ IPath p = PathUtils.getGlobalLocation(node2);
if( p == null ) return null;
parentFile = new File(p.toOSString(), ArchiveDetector.NULL);
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd 2008-08-06
15:40:35 UTC (rev 9583)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/xml/packages.xsd 2008-08-06
23:37:56 UTC (rev 9584)
@@ -35,7 +35,7 @@
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="package" type="package-type"/>
<xsd:element maxOccurs="1" minOccurs="0"
name="properties" type="properties-type"/>
</xsd:sequence>
- <xsd:attribute name="version" type="xsd:float"
use="optional"/>
+ <xsd:attribute name="version" type="xsd:double"
use="optional"/>
</xsd:complexType>
<xsd:complexType name="package-type">
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/providers/ArchivesLabelProvider.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -10,6 +10,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PrefsInitializer;
import
org.jboss.ide.eclipse.archives.ui.providers.ArchivesContentProviderDelegate.DelayProxy;
@@ -105,7 +106,7 @@
private String getPackageText (IArchive pkg) {
String text = pkg.getName();
if (PrefsInitializer.getBoolean( PrefsInitializer.PREF_SHOW_PACKAGE_OUTPUT_PATH)) {
- text += " [" + pkg.getGlobalDestinationPath() + "]";
+ text += " [" + PathUtils.getGlobalLocation(pkg) + "]";
}
return text;
}
@@ -128,11 +129,11 @@
}
if (showFullPath) {
- text += fileset.getGlobalSourcePath().toString();
+ text += PathUtils.getGlobalLocation(fileset);
} else if( inWorkspace ){
text += fileset.getRawSourcePath();
} else {
- text += fileset.getGlobalSourcePath().lastSegment();
+ text += PathUtils.getGlobalLocation(fileset).lastSegment();
}
return text;
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/util/composites/ArchiveSourceDestinationComposite.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -36,6 +36,7 @@
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.INamedContainerArchiveNode;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.PackagesUIPlugin;
@@ -51,11 +52,13 @@
private String path;
private boolean error;
private String errorString;
+ private double version;
private ArrayList<ChangeListener> listeners = new
ArrayList<ChangeListener>();
- public ArchiveSourceDestinationComposite(Composite parent, String project) {
+ public ArchiveSourceDestinationComposite(Composite parent, String project, double
version) {
super(parent, SWT.NONE);
this.projectName = project;
+ this.version = version;
setLayout(new FormLayout());
createWidgets();
layoutWidgets();
@@ -163,7 +166,7 @@
} else if( result instanceof IContainer ) {
destinationNode = null;
IPath tmpPath = ((IContainer)result).getFullPath();
- if( tmpPath.segment(0).equals(projectName))
+ if( tmpPath.segment(0).equals(projectName) && getDescriptorVersion() <
2.0)
path = tmpPath.removeFirstSegments(1).makeRelative().toString();
else
path = ((IContainer)result).getFullPath().makeAbsolute().toString();
@@ -223,7 +226,7 @@
translated=""; img=null;
} else {
translated = getTranslatedGlobalPath();
- if( !new Path(translated).toFile().exists()) {
+ if( translated == null || !new Path(translated).toFile().exists()) {
translated=translated + " does not exist in the filesystem.";
img =
PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
} else {
@@ -262,19 +265,11 @@
protected String getTranslatedGlobalPath() throws CoreException {
try {
- String postSub = ArchivesCore.getInstance().getVFS().
- performStringSubstitution(path, projectName, true);
- if( workspaceRelative ) {
- IPath p2 = new Path(postSub);
- if( !p2.isAbsolute())
- p2 = new Path(projectName).append(p2).makeAbsolute();
- IPath p = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(p2);
- if( p != null ) return p.toString();
- String ERROR ="Unable to convert workspace path into global path: " +
postSub;
- Status s = new Status(IStatus.WARNING, PackagesUIPlugin.PLUGIN_ID, ERROR);
- throw new CoreException(s);
- }
- return postSub;
+ IPath p = PathUtils.getGlobalLocation(path, projectName, workspaceRelative,
getDescriptorVersion());
+ if( p != null ) return p.toString();
+ String ERROR ="Unable to convert workspace path into global path: " +
p.toOSString();
+ Status s = new Status(IStatus.WARNING, PackagesUIPlugin.PLUGIN_ID, ERROR);
+ throw new CoreException(s);
} catch( CoreException e ) {
String ERROR = "Error during string substitution: " + e.getMessage();
Status s = new Status(IStatus.ERROR, PackagesUIPlugin.PLUGIN_ID, ERROR, e);
@@ -351,15 +346,13 @@
return path;
}
- public String getTranslatedPath() {
- try {
- return ArchivesCore.getInstance().getVFS().
- performStringSubstitution(path, projectName, true);
- } catch( CoreException ce ) {}
- return null;
+ public void setDescriptorVersion(double version) {
+ this.version = version;
}
+ public double getDescriptorVersion() {
+ return version;
+ }
-
public static interface ChangeListener {
public void compositeChanged();
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/FilesetWizard.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -4,7 +4,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard;
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/ArchiveInfoWizardPage.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -22,10 +22,12 @@
import org.eclipse.swt.widgets.Text;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
import
org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveSourceDestinationComposite;
@@ -101,7 +103,7 @@
buttonData.horizontalSpan = 3;
buttonData.horizontalAlignment = SWT.END;
- destinationComposite = new ArchiveSourceDestinationComposite(infoGroup,
wizard.getProject().getName());
+ destinationComposite = new ArchiveSourceDestinationComposite(infoGroup,
wizard.getProject().getName(), getDescriptorVersion());
destinationComposite.addChangeListener(new ChangeListener () {
public void compositeChanged() {
validate();
@@ -148,7 +150,7 @@
if( parent != null && !(parent instanceof IArchiveModelRootNode)) {
destinationComposite.init(parent);
} else {
- destinationComposite.init(archive.getDestinationPath().toString(),
archive.isDestinationInWorkspace());
+ destinationComposite.init(PathUtils.getGlobalLocation(archive).toString(),
archive.isDestinationInWorkspace());
}
} else {
if(wizard.getInitialNode() != null )
@@ -178,14 +180,11 @@
}
}
} else if( destinationComposite.getPath() != null ) {
+ // checking for another archive with the same destination / name
boolean relative = destinationComposite.isWorkspaceRelative();
- IPath destinationLocation;
- if( relative ) {
- IPath translatedPath = new Path(destinationComposite.getTranslatedPath());
- destinationLocation =
ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(translatedPath);
- } else {
- destinationLocation = new Path(destinationComposite.getPath());
- }
+ IPath destinationLocation =
+ PathUtils.getGlobalLocation(destinationComposite.getPath(),
+ wizard.getProject().getName(), relative, 1);
ArrayList<IArchive> allArchives = new ArrayList<IArchive>();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
@@ -197,7 +196,7 @@
for( int i = 0; i < packages.length; i++ ) {
IArchive pkg = (IArchive) packages[i];
if (pkg.getName().equals(packageNameText.getText())
- && (pkg.getGlobalDestinationPath() != null &&
pkg.getGlobalDestinationPath().equals(destinationLocation))
+ && (PathUtils.getGlobalLocation(pkg)!= null &&
PathUtils.getGlobalLocation(pkg).equals(destinationLocation))
&& (!pkg.equals(this.archive))) {
errorMessage = ArchivesUIMessages.bind(
ArchivesUIMessages.PackageInfoWizardPage_error_packageAlreadyExists,
packageNameText.getText());
@@ -253,6 +252,13 @@
return archive;
}
+ protected double getDescriptorVersion() {
+ IPath loc = wizard.getProject().getLocation();
+ if( ArchivesModel.instance().isProjectRegistered(loc))
+ return ArchivesModel.instance().getRoot(loc).getDescriptorVersion();
+ return (float)2.0;
+ }
+
// Getters for the wizard to call
public String getDestinationPath() {
return destinationComposite.getPath();
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -148,7 +148,7 @@
// root dir
Label rootDirectoryLabel = new Label(infoGroup, SWT.NONE);
- srcDestComposite = new ArchiveSourceDestinationComposite(infoGroup, projectName);
+ srcDestComposite = new ArchiveSourceDestinationComposite(infoGroup, projectName,
getDescriptorVersion());
Composite rootDirValue = srcDestComposite;
rootDirectoryLabel.setLayoutData(createFormData(destinationComposite,10,null,0,null,5,0,100));
rootDirValue.setLayoutData(createFormData(destinationComposite,5,null,0,rootDirectoryLabel,5,100,-5));
@@ -312,7 +312,8 @@
Runnable r;
try {
ds = DirectoryScannerFactory.createDirectoryScanner(
- replaceVariables(), null, includes, excludes, parentNode.getProjectName(),
srcDestComposite.isWorkspaceRelative(), true);
+ replaceVariables(), null, includes, excludes, parentNode.getProjectName(),
+ srcDestComposite.isWorkspaceRelative(),
parentNode.getModelRootNode().getDescriptorVersion(), true);
String[] fsRelative = ds.getIncludedFiles();
IPath filesetRelative;
final ArrayList<IPath> list = new ArrayList<IPath>();
@@ -342,4 +343,8 @@
}
}
}
+
+ protected double getDescriptorVersion() {
+ return parentNode.getModelRootNode().getDescriptorVersion();
+ }
}
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/expectedOutputs/emptyPackages.xml 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<packages>
+<packages version="0.0">
<properties></properties>
</packages>
\ No newline at end of file
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/JBIDE1406/.packages
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/JBIDE1406/.packages 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/inputs/projects/JBIDE1406/.packages 2008-08-06
23:37:56 UTC (rev 9584)
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<packages>
- <package name="JBIDE1406.jar" type="jar"
todir="${current.project}/output" exploded="true"
inWorkspace="true">
- <fileset dir="${current.project}" includes="**"
excludes="**/*.jar" inWorkspace="true" flatten="false">
+ <package name="JBIDE1406.jar" type="jar"
todir="${archives_current_project}/output" exploded="true"
inWorkspace="true">
+ <fileset dir="${archives_current_project}" includes="**"
excludes="**/*.jar,**/.packages" inWorkspace="true"
flatten="false">
<properties></properties>
</fileset>
<properties>
<property
name="org.jboss.ide.eclipse.as.core.packages.ModuleIDPropertyKey"
value="1214949466221"></property>
</properties>
</package>
- <properties></properties>
</packages>
\ No newline at end of file
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelTruezipBridgeTest.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -38,6 +38,7 @@
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
import org.jboss.ide.eclipse.archives.test.ArchivesTest;
@@ -103,7 +104,7 @@
explodedInExploded.setExploded(true);
exploded.addChild(explodedInExploded);
ModelTruezipBridge.createFile(explodedInExploded);
- File eIeF =
exploded.getGlobalDestinationPath().append("exploded.war").append("explodedInExploded.jar").toFile();
+ File eIeF =
PathUtils.getGlobalLocation(exploded).append("exploded.war").append("explodedInExploded.jar").toFile();
assertTrue(eIeF.exists());
// zip inside exploded
@@ -111,7 +112,7 @@
ZipInExploded.setExploded(false);
exploded.addChild(ZipInExploded);
ModelTruezipBridge.createFile(ZipInExploded);
- File zIeF =
exploded.getGlobalDestinationPath().append("exploded.war").append("zipInExploded.jar").toFile();
+ File zIeF =
PathUtils.getGlobalLocation(exploded).append("exploded.war").append("zipInExploded.jar").toFile();
assertTrue(zIeF.exists());
assertFalse(zIeF.isDirectory());
@@ -136,7 +137,7 @@
}
public void testCreateFileInWorkspace() {
- IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").toString());
+ IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
zipped.setExploded(false);
ModelTruezipBridge.createFile(zipped);
@@ -181,7 +182,7 @@
public void testDeleteArchive() {
- IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").toString());
+ IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
zipped.setExploded(false);
ModelTruezipBridge.createFile(zipped);
@@ -215,7 +216,7 @@
* Fileset-related
*/
public void testFileset() {
- IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").toString());
+ IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
zipped.setExploded(false);
ModelTruezipBridge.createFile(zipped);
@@ -223,7 +224,7 @@
assertTrue(zippedF.exists());
assertTrue(!zippedF.isDirectory());
- IArchiveFileSet fs = createFileSet("**/*.gif", proj.getName());
+ IArchiveFileSet fs = createFileSet("**/*.gif", new
Path(proj.getName()).makeAbsolute().toString());
fs.setInWorkspace(true);
zipped.addChild(fs);
ModelTruezipBridge.fullFilesetBuild(fs);
@@ -231,7 +232,7 @@
}
public void testFlattenedFileset() {
- IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").toString());
+ IArchive zipped = createArchive("zipped.war", new
Path(proj.getName()).append("outputs").makeAbsolute().toString());
zipped.setInWorkspace(true);
zipped.setExploded(false);
ModelTruezipBridge.createFile(zipped);
@@ -239,7 +240,7 @@
assertTrue(zippedF.exists());
assertTrue(!zippedF.isDirectory());
- IArchiveFileSet fs = createFileSet("**/*.gif", proj.getName());
+ IArchiveFileSet fs = createFileSet("**/*.gif", new
Path(proj.getName()).makeAbsolute().toString());
fs.setInWorkspace(true);
fs.setFlattened(true);
zipped.addChild(fs);
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/StringSubstitutionTest.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/StringSubstitutionTest.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/StringSubstitutionTest.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -16,7 +16,7 @@
public void testNoVariables() {
WorkspaceVFS vfs = (WorkspaceVFS)ArchivesCore.getInstance().getVFS();
try {
- String out1 = vfs.performStringSubstitution(ONE, true);
+ String out1 = vfs.performStringSubstitution(ONE, null, true);
assertEquals(ONE, out1);
} catch( CoreException ce ) {
fail();
@@ -26,7 +26,7 @@
public void testVariableNotSet() {
WorkspaceVFS vfs = (WorkspaceVFS)ArchivesCore.getInstance().getVFS();
try {
- vfs.performStringSubstitution(TWO, true);
+ vfs.performStringSubstitution(TWO, null, true);
} catch( CoreException ce ) {
return;
}
@@ -36,7 +36,7 @@
public void testVariableNotSet2() {
WorkspaceVFS vfs = (WorkspaceVFS)ArchivesCore.getInstance().getVFS();
try {
- String out2 = vfs.performStringSubstitution(TWO, false);
+ String out2 = vfs.performStringSubstitution(TWO, null, false);
assertEquals(TWO, out2);
} catch( CoreException ce ) {
fail();
@@ -47,7 +47,7 @@
try {
ResourcesPlugin.getWorkspace().getPathVariableManager().setValue("test_variable",
new Path("/here"));
WorkspaceVFS vfs = (WorkspaceVFS)ArchivesCore.getInstance().getVFS();
- String out = vfs.performStringSubstitution("${test_variable}", true);
+ String out = vfs.performStringSubstitution("${test_variable}",null, true);
assertEquals("/here", out);
ResourcesPlugin.getWorkspace().getPathVariableManager().setValue("test_variable",
null);
} catch( CoreException ce ) {
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE1406Test.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE1406Test.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE1406Test.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -9,9 +9,23 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
+import org.jboss.ide.eclipse.archives.core.util.PathUtils;
import org.jboss.ide.eclipse.archives.test.ArchivesTest;
import org.jboss.tools.common.test.util.TestProjectProvider;
+/**
+ * This class tests first and foremost
+ * the presence of a ${archives_current_project}
+ * extension to allow the currently building
+ * project to be agnostic
+ *
+ * During this JIRA, workspace paths became conscious of
+ * their absolute / relative status and are now interpreted
+ * differently according to their status.
+ * @author rob
+ *
+ */
public class JBIDE1406Test extends TestCase {
private TestProjectProvider provider;
private IProject project;
@@ -44,4 +58,46 @@
fail(re.getMessage());
}
}
+
+ /*
+ * Time to test that this commit has not ruined other things.
+ * Specifically, with an older archives descriptor
+ * all workspace paths should still be interpreted as
+ * absolute paths even if they're not visibly absolute.
+ */
+
+ public void testJBIDE1406_descriptor_path_utils() {
+ // These 3 should work regardless of version.
+ // they are "", ".", and anything absolute "/proj/out"
+ assertEquals(new Path("JBIDE1406").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation("", "JBIDE1406", true, 1.0));
+ assertEquals(new Path("JBIDE1406").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation(".", "JBIDE1406", true, 1.0));
+ assertEquals(new
Path("JBIDE1406").append("output").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation("/JBIDE1406/output", "JBIDE1406",
true, 1.0));
+
+ // Test 1.2
+ assertEquals(new Path("JBIDE1406").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation("", "JBIDE1406", true, 1.2));
+ assertEquals(new Path("JBIDE1406").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation(".", "JBIDE1406", true, 1.2));
+ assertEquals(new
Path("JBIDE1406").append("output").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation("/JBIDE1406/output", "JBIDE1406",
true, 1.2));
+
+
+ // in 1.0, a leading slash does not matter
+ assertEquals(new
Path("JBIDE1406").append("output").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation("JBIDE1406/output", "JBIDE1406",
true, 1.0));
+
+ assertEquals(
+ PathUtils.getAbsoluteLocation("JBIDE1406/output", "JBIDE1406",
true, 1.0),
+ PathUtils.getAbsoluteLocation("/JBIDE1406/output", "JBIDE1406",
true, 1.0));
+
+ // In 1.2 the leading slash matters
+ assertEquals(new
Path("JBIDE1406").append("output").makeAbsolute().toString(),
+ PathUtils.getAbsoluteLocation("output", "JBIDE1406", true,
1.2));
+ assertNotSame(
+ PathUtils.getAbsoluteLocation("JBIDE1406/output", "JBIDE1406",
true, 1.2),
+ PathUtils.getAbsoluteLocation("/JBIDE1406/output", "JBIDE1406",
true, 1.2));
+ }
}
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE2439Test.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE2439Test.java 2008-08-06
15:40:35 UTC (rev 9583)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/projects/JBIDE2439Test.java 2008-08-06
23:37:56 UTC (rev 9584)
@@ -61,7 +61,8 @@
public boolean visit(IResource resource) throws CoreException {
if( resource instanceof IFile ) {
- list.add(resource);
+ if( !resource.getFullPath().toString().contains(".svn"))
+ list.add(resource);
}
return true;
}