Remove dependency on IPath (FELIX-1509)
Created new Resource concept to encode BND concepts foo, foo=foo, {foo=foo}, @foo (FELIX-1814)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@980146 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java b/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java
index ca371fd..faf5104 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/bnd/BundleBuilder.java
@@ -36,6 +36,7 @@
import org.apache.felix.sigil.common.osgi.VersionRange;
import org.apache.felix.sigil.config.BldAttr;
import org.apache.felix.sigil.config.IBldProject;
+import org.apache.felix.sigil.config.Resource;
import org.apache.felix.sigil.config.IBldProject.IBldBundle;
import org.apache.felix.sigil.core.repository.SystemRepositoryProvider;
import org.apache.felix.sigil.model.osgi.IPackageExport;
@@ -188,7 +189,12 @@
if (log != null)
{
- log.verbose("BND instructions: " + spec.toString());
+ log.verbose("Generated " + bundle.getSymbolicName());
+ log.verbose("-----------------------------");
+ for(Map.Entry<Object, Object> e : spec.entrySet()) {
+ log.verbose(e.getKey() + "=" + e.getValue());
+ log.verbose("-----------------------------");
+ }
log.verbose("BND classpath: " + Arrays.asList(classpath));
}
@@ -449,7 +455,7 @@
addVersions(fh.getVersions(), sb);
spec.setProperty(Constants.FRAGMENT_HOST, sb.toString());
}
-
+
return spec;
}
@@ -540,109 +546,21 @@
private void addResources(IBldBundle bundle, Properties spec)
{
- Map<String, String> resources = bundle.getResources();
+ List<Resource> resources = bundle.getResources();
StringBuilder sb = new StringBuilder();
- for (String bPath : resources.keySet())
+ for (Resource bPath : resources)
{
- if (bPath.startsWith("@"))
- {
- handleInlineJar(bundle, sb, bPath);
- }
- else if (bPath.startsWith("{"))
- {
- handlePreprocessedResource(bundle, resources, sb, bPath);
- }
- else
- {
- handleStandardResource(bundle, resources, sb, bPath);
- }
+ if (sb.length() > 0)
+ sb.append(",");
+
+ sb.append(bPath.toBNDInstruction(classpath));
}
if (sb.length() > 0)
spec.setProperty(Constants.INCLUDE_RESOURCE, sb.toString());
}
- private void handlePreprocessedResource(IBldBundle bundle,
- Map<String, String> resources, StringBuilder sb, String bPath)
- {
- String fsPath = resources.get(bPath);
-
- bPath = bPath.substring(1, bPath.length() - 1);
-
- if ("".equals(fsPath))
- fsPath = bPath;
-
- fsPath = findFileSystemPath(bundle, fsPath);
-
- if (sb.length() > 0)
- sb.append(",");
- sb.append("{");
- sb.append(bPath);
- sb.append('=');
- sb.append(fsPath);
- sb.append("}");
- }
-
- private void handleStandardResource(IBldBundle bundle, Map<String, String> resources,
- StringBuilder sb, String bPath)
- {
- String fsPath = resources.get(bPath);
- if ("".equals(fsPath))
- fsPath = bPath;
-
- fsPath = findFileSystemPath(bundle, fsPath);
-
- if (sb.length() > 0)
- sb.append(",");
- sb.append(bPath);
- sb.append('=');
- sb.append(fsPath);
- }
-
- private String findFileSystemPath(IBldBundle bundle, String fsPath)
- {
- File resolved = bundle.resolve(fsPath);
-
- // fsPath may contain Bnd variable, making path appear to not exist
-
- if (!resolved.exists())
- {
- // Bnd already looks for classpath jars
- File found = findInClasspathDir(fsPath);
- if (found != null)
- {
- fsPath = found.getPath();
- }
- else
- {
- fsPath = resolved.getAbsolutePath();
- }
- }
- else
- {
- fsPath = resolved.getAbsolutePath();
- }
-
- return fsPath;
- }
-
- private void handleInlineJar(IBldBundle bundle, StringBuilder sb, String bPath)
- {
- if (sb.length() > 0)
- sb.append(",");
-
- File f = bundle.resolve(bPath.substring(1));
-
- if (f.exists())
- {
- sb.append('@');
- sb.append(f);
- }
- else
- sb.append(bPath);
- }
-
private List<IPackageImport> getImports(IBldBundle bundle)
{
List<IPackageImport> imports = bundle.getImports();
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java b/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java
index 176b79f..a651fc9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/BldConverter.java
@@ -42,8 +42,6 @@
import org.apache.felix.sigil.model.osgi.IPackageExport;
import org.apache.felix.sigil.model.osgi.IPackageImport;
import org.apache.felix.sigil.model.osgi.IRequiredBundle;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import aQute.lib.osgi.Constants;
@@ -139,15 +137,10 @@
// resources
// FIXME: UI doesn't support -resources: path1=path2
- Map<String, String> resources = bundle.getResources();
- for ( String resource : resources.keySet() )
+ List<Resource> resources = bundle.getResources();
+ for ( Resource resource : resources )
{
- String fsPath = resources.get( resource );
- if ( !"".equals( fsPath ) )
- {
- BldCore.error( "FIXME: can't convert resource: " + resource + "=" + fsPath );
- }
- sigilBundle.addSourcePath( new Path( resource ) );
+ sigilBundle.addSourcePath( resource );
}
////////////////////
@@ -328,7 +321,7 @@
{
// resources
ArrayList<String> resources = new ArrayList<String>();
- for ( IPath ipath : bundle.getSourcePaths() )
+ for ( Resource ipath : bundle.getSourcePaths() )
{
resources.add( ipath.toString() );
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java b/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java
index 3999081..31c616f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/BldProject.java
@@ -36,7 +36,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -44,6 +43,9 @@
import org.apache.felix.sigil.common.osgi.VersionRange;
import org.apache.felix.sigil.common.osgi.VersionTable;
+import org.apache.felix.sigil.config.internal.InlineResource;
+import org.apache.felix.sigil.config.internal.PreprocessedResource;
+import org.apache.felix.sigil.config.internal.StandardResource;
import org.apache.felix.sigil.core.internal.model.osgi.BundleModelElement;
import org.apache.felix.sigil.core.internal.model.osgi.PackageExport;
import org.apache.felix.sigil.core.internal.model.osgi.PackageImport;
@@ -183,7 +185,7 @@
}
file = file.getCanonicalFile();
- URL url = file.toURL();
+ URL url = file.toURI().toURL();
BldProperties bp = new BldProperties(file.getParentFile(), bldOverrides);
if (dflt == null)
@@ -287,6 +289,23 @@
}
return file;
}
+
+ public Resource newResource(String location) {
+ String[] paths = location.split("=", 2);
+ String bPath = paths[0];
+ String fsPath = (paths.length > 1 ? paths[1] : null);
+ if (bPath.startsWith("@")) {
+ bPath = bPath.substring(1);
+ return new InlineResource(BldProject.this, bPath);
+ }
+ else if (bPath.startsWith("{")) {
+ bPath = bPath.substring(1, bPath.length() -1);
+ return new PreprocessedResource(BldProject.this, bPath, fsPath);
+ }
+ else {
+ return new StandardResource(BldProject.this, bPath, fsPath);
+ }
+ }
public String getVersion()
{
@@ -960,23 +979,21 @@
return getList(BldConfig.L_CONTENTS);
}
- public Map<String, String> getResources()
+ public List<Resource> getResources()
{
- Map<String, String> map = new LinkedHashMap<String, String>();
List<String> resources = getList(BldConfig.L_RESOURCES);
-
- if (resources != null)
- {
- for (String resource : resources)
- {
- String[] paths = resource.split("=", 2);
- String fsPath = (paths.length > 1 ? paths[1] : "");
- map.put(paths[0], fsPath);
- }
+ if (resources == null) {
+ return Collections.emptyList();
}
- return map;
+
+ List<Resource> ret = new ArrayList<Resource>(resources.size());
+ for (String resource : resources)
+ {
+ ret.add(newResource(resource));
+ }
+ return ret;
}
-
+
public Properties getHeaders()
{
Properties headers = config.getProps(id, BldConfig.P_HEADER);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/IBldProject.java b/sigil/common/core/src/org/apache/felix/sigil/config/IBldProject.java
index 47b1e58..2c62954 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/config/IBldProject.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/IBldProject.java
@@ -136,6 +136,13 @@
* resolves a relative path against the project file location.
*/
File resolve( String path );
+
+ /**
+ * Creates a new resource for this bundle
+ * @param location
+ * @return
+ */
+ Resource newResource(String location);
/**
@@ -211,9 +218,8 @@
* @return map with key as path in bundle, value as path in file system.
* Paths are resolved relative to location of project file and also from classpath.
*/
- Map<String, String> getResources();
-
-
+ List<Resource> getResources();
+
/**
* gets additional bundle headers.
*/
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/Resource.java b/sigil/common/core/src/org/apache/felix/sigil/config/Resource.java
new file mode 100644
index 0000000..0b36902
--- /dev/null
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/Resource.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.config;
+
+import java.io.File;
+
+/**
+ * @author dave
+ *
+ */
+public interface Resource
+{
+ String toBNDInstruction(File[] classpath);
+
+ /**
+ * @return
+ */
+ String getLocalFile();
+}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/internal/AbstractResource.java b/sigil/common/core/src/org/apache/felix/sigil/config/internal/AbstractResource.java
new file mode 100644
index 0000000..3afaf35
--- /dev/null
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/internal/AbstractResource.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.config.internal;
+
+import java.io.File;
+
+import org.apache.felix.sigil.config.IBldProject;
+import org.apache.felix.sigil.config.Resource;
+
+/**
+ * @author dave
+ *
+ */
+public abstract class AbstractResource implements Resource
+{
+ protected final String bPath;
+ protected final IBldProject project;
+
+ protected AbstractResource(IBldProject project, String bPath) {
+ if (bPath == null)
+ throw new NullPointerException();
+
+ if(project == null)
+ throw new NullPointerException();
+
+ this.bPath = bPath;
+ this.project = project;
+ }
+
+ protected String findFileSystemPath(String fsPath, File[] classpath)
+ {
+ File resolved = project.resolve(fsPath);
+
+ // fsPath may contain Bnd variable, making path appear to not exist
+
+ if (!resolved.exists())
+ {
+ // Bnd already looks for classpath jars
+ File found = findInClasspathDir(fsPath, classpath);
+ if (found != null)
+ {
+ fsPath = found.getPath();
+ }
+ else
+ {
+ fsPath = resolved.getAbsolutePath();
+ }
+ }
+ else
+ {
+ fsPath = resolved.getAbsolutePath();
+ }
+
+ return fsPath;
+ }
+
+ private File findInClasspathDir(String file, File[] classpath)
+ {
+ for (File cp : classpath)
+ {
+ if (cp.isDirectory())
+ {
+ File path = new File(cp, file);
+ if (path.exists())
+ {
+ return path;
+ }
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/internal/InlineResource.java b/sigil/common/core/src/org/apache/felix/sigil/config/internal/InlineResource.java
new file mode 100644
index 0000000..a8673f0
--- /dev/null
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/internal/InlineResource.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.config.internal;
+
+import java.io.File;
+
+import org.apache.felix.sigil.config.IBldProject;
+
+/**
+ * @author dave
+ *
+ */
+public class InlineResource extends AbstractResource
+{
+
+ /**
+ * @param bPath
+ */
+ public InlineResource(IBldProject project, String bPath)
+ {
+ super(project, bPath);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.felix.sigil.core.Resource#getLocalFile()
+ */
+ public String getLocalFile()
+ {
+ return bPath;
+ }
+
+ public String toString() {
+ return '@' + bPath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.felix.sigil.core.Resource#toBNDInstruction(java.io.File[])
+ */
+ public String toBNDInstruction(File[] classpath)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append('@');
+
+ File f = project.resolve(bPath);
+
+ if (f.exists())
+ {
+ sb.append(f);
+ }
+ else
+ sb.append(bPath);
+
+ return sb.toString();
+ }
+
+}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/internal/PreprocessedResource.java b/sigil/common/core/src/org/apache/felix/sigil/config/internal/PreprocessedResource.java
new file mode 100644
index 0000000..4d8f7ed
--- /dev/null
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/internal/PreprocessedResource.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.config.internal;
+
+import java.io.File;
+
+import org.apache.felix.sigil.config.IBldProject;
+
+/**
+ * @author dave
+ *
+ */
+public class PreprocessedResource extends AbstractResource
+{
+ private final String fsPath;
+
+ public PreprocessedResource(IBldProject project, String bPath, String fsPath)
+ {
+ super(project, bPath);
+ this.fsPath = fsPath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.felix.sigil.core.Resource#getLocalFile()
+ */
+ public String getLocalFile()
+ {
+ return fsPath == null ? bPath : fsPath;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append('{');
+ sb.append(bPath);
+ if (fsPath != null) {
+ sb.append('=');
+ sb.append(fsPath);
+ }
+ sb.append('}');
+ return sb.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.felix.sigil.core.Resource#toBNDInstruction(java.io.File[])
+ */
+ public String toBNDInstruction(File[] classpath)
+ {
+ StringBuilder sb = new StringBuilder();
+ String fsp = fsPath;
+ if (fsp == null)
+ fsp = bPath;
+
+ fsp = findFileSystemPath(fsp, classpath);
+
+ sb.append('{');
+ sb.append(bPath);
+ sb.append('=');
+ sb.append(fsp);
+ sb.append('}');
+
+ return sb.toString();
+ }
+
+}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/config/internal/StandardResource.java b/sigil/common/core/src/org/apache/felix/sigil/config/internal/StandardResource.java
new file mode 100644
index 0000000..fe536c4
--- /dev/null
+++ b/sigil/common/core/src/org/apache/felix/sigil/config/internal/StandardResource.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.config.internal;
+
+import java.io.File;
+
+import org.apache.felix.sigil.config.IBldProject;
+
+/**
+ * @author dave
+ *
+ */
+public class StandardResource extends AbstractResource
+{
+ private final String fsPath;
+
+ /**
+ * @param bldProject
+ * @param bPath2
+ * @param fsPath2
+ */
+ public StandardResource(IBldProject project, String bPath, String fsPath)
+ {
+ super(project, bPath);
+ this.fsPath = fsPath;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.felix.sigil.core.Resource#getLocalFile()
+ */
+ public String getLocalFile()
+ {
+ return fsPath == null ? bPath : fsPath;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(bPath);
+ if (fsPath != null) {
+ sb.append('=');
+ sb.append(fsPath);
+ }
+ return sb.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.felix.sigil.core.Resource#toBNDInstruction(java.io.File[])
+ */
+ public String toBNDInstruction(File[] classpath)
+ {
+ StringBuilder sb = new StringBuilder();
+ String fsp = fsPath;
+ if (fsp == null)
+ fsp = bPath;
+
+ fsp = findFileSystemPath(fsp, classpath);
+
+ sb.append(bPath);
+ sb.append('=');
+ sb.append(fsp);
+
+ return sb.toString();
+ }
+
+}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/BldCore.java b/sigil/common/core/src/org/apache/felix/sigil/core/BldCore.java
index 2e9ef95..898cf33 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/BldCore.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/BldCore.java
@@ -99,6 +99,5 @@
{
// TODO Auto-generated method stub
- }
-
+ }
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/SigilBundle.java b/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/SigilBundle.java
index f2ff433..808735d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/SigilBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/internal/model/eclipse/SigilBundle.java
@@ -35,6 +35,7 @@
import java.util.Collection;
import java.util.jar.JarFile;
+import org.apache.felix.sigil.config.Resource;
import org.apache.felix.sigil.core.BldCore;
import org.apache.felix.sigil.core.util.ManifestUtil;
import org.apache.felix.sigil.model.AbstractCompoundModelElement;
@@ -43,7 +44,6 @@
import org.apache.felix.sigil.model.osgi.IBundleModelElement;
import org.apache.felix.sigil.model.osgi.IPackageExport;
import org.apache.felix.sigil.model.osgi.IPackageImport;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.osgi.framework.Version;
@@ -59,19 +59,19 @@
private static final long serialVersionUID = 1L;
private IBundleModelElement bundle;
- private IPath[] sourcePaths;
+ private Resource[] sourcePaths;
private String[] classpath;
private String[] packages;
- private IPath location;
+ private File location;
- private IPath sourcePathLocation;
- private IPath licencePathLocation;
- private IPath sourceRootPath;
+ private File sourcePathLocation;
+ private File licencePathLocation;
+ private String sourceRootPath;
public SigilBundle()
{
super( "Sigil Bundle" );
- sourcePaths = new IPath[0];
+ sourcePaths = new Resource[0];
classpath = new String[0];
packages = new String[0];
}
@@ -113,10 +113,10 @@
}
- private void updateManifest(IPath location) throws IOException
+ private void updateManifest(File location) throws IOException
{
if ( location != null ) {
- JarFile f = new JarFile(location.toFile());
+ JarFile f = new JarFile(location);
try {
setBundleInfo(ManifestUtil.buildBundleModelElement(f.getManifest()));
}
@@ -129,17 +129,17 @@
public boolean isSynchronized()
{
- return location == null || location.toFile().exists();
+ return location == null || location.exists();
}
- private static void sync( IPath local, URI remote, IProgressMonitor monitor ) throws IOException
+ private static void sync( File local, URI remote, IProgressMonitor monitor ) throws IOException
{
try
{
if ( remote != null )
{
- if ( local != null && !local.toFile().exists() )
+ if ( local != null && !local.exists() )
{
URL url = remote.toURL();
URLConnection connection = url.openConnection();
@@ -159,9 +159,8 @@
http.setReadTimeout( 5000 );
}
in = conn.getInputStream();
- File f = local.toFile();
- f.getParentFile().mkdirs();
- out = new FileOutputStream( f );
+ local.getParentFile().mkdirs();
+ out = new FileOutputStream( local );
stream( in, out, monitor );
}
finally
@@ -181,7 +180,7 @@
}
catch ( IOException e )
{
- local.toFile().delete();
+ local.delete();
throw e;
}
}
@@ -230,24 +229,24 @@
}
- public void addSourcePath( IPath path )
+ public void addSourcePath( Resource path )
{
- ArrayList<IPath> tmp = new ArrayList<IPath>(getSourcePaths());
+ ArrayList<Resource> tmp = new ArrayList<Resource>(getSourcePaths());
tmp.add(path);
- sourcePaths = tmp.toArray( new IPath[tmp.size()] );
+ sourcePaths = tmp.toArray( new Resource[tmp.size()] );
}
- public void removeSourcePath( IPath path )
+ public void removeSourcePath( Resource path )
{
- ArrayList<IPath> tmp = new ArrayList<IPath>(getSourcePaths());
+ ArrayList<Resource> tmp = new ArrayList<Resource>(getSourcePaths());
if ( tmp.remove(path) ) {
- sourcePaths = tmp.toArray( new IPath[tmp.size()] );
+ sourcePaths = tmp.toArray( new Resource[tmp.size()] );
}
}
- public Collection<IPath> getSourcePaths()
+ public Collection<Resource> getSourcePaths()
{
return Arrays.asList(sourcePaths);
}
@@ -255,7 +254,7 @@
public void clearSourcePaths()
{
- sourcePaths = new IPath[0];
+ sourcePaths = new Resource[0];
}
@@ -282,49 +281,49 @@
}
- public IPath getLocation()
+ public File getLocation()
{
return location;
}
- public void setLocation( IPath location )
+ public void setLocation( File location )
{
this.location = location;
}
- public IPath getSourcePathLocation()
+ public File getSourcePathLocation()
{
return sourcePathLocation;
}
- public IPath getSourceRootPath()
- {
- return sourceRootPath;
- }
-
-
- public void setSourcePathLocation( IPath location )
+ public void setSourcePathLocation( File location )
{
this.sourcePathLocation = location;
}
- public void setSourceRootPath( IPath location )
+ public String getSourceRootPath()
+ {
+ return sourceRootPath;
+ }
+
+
+ public void setSourceRootPath( String location )
{
this.sourceRootPath = location;
}
- public IPath getLicencePathLocation()
+ public File getLicencePathLocation()
{
return licencePathLocation;
}
- public void setLicencePathLocation( IPath licencePathLocation )
+ public void setLicencePathLocation( File licencePathLocation )
{
this.licencePathLocation = licencePathLocation;
}
@@ -443,7 +442,7 @@
SigilBundle b = (SigilBundle) super.clone();
b.bundle = (IBundleModelElement) b.bundle.clone();
- IPath[] newPaths = new IPath[b.sourcePaths.length];
+ Resource[] newPaths = new Resource[b.sourcePaths.length];
System.arraycopy(b.sourcePaths, 0, newPaths, 0, b.sourcePaths.length);
b.sourcePaths = newPaths;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/repository/DirectoryHelper.java b/sigil/common/core/src/org/apache/felix/sigil/core/repository/DirectoryHelper.java
index 047c774..b8505cc 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/repository/DirectoryHelper.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/repository/DirectoryHelper.java
@@ -32,17 +32,13 @@
import org.apache.felix.sigil.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.model.osgi.IBundleModelElement;
import org.apache.felix.sigil.repository.AbstractBundleRepository;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
public class DirectoryHelper
{
- public static void scanBundles( AbstractBundleRepository repository, List<ISigilBundle> bundles, IPath path,
- IPath source, boolean recursive )
+ public static void scanBundles( AbstractBundleRepository repository, List<ISigilBundle> bundles, File dir,
+ File source, boolean recursive )
{
- File dir = path.toFile();
-
if ( dir.exists() )
{
for ( File f : dir.listFiles() )
@@ -51,7 +47,7 @@
{
if ( recursive )
{
- scanBundles( repository, bundles, new Path( f.getAbsolutePath() ), source, recursive );
+ scanBundles( repository, bundles, f, source, recursive );
}
}
else if ( f.isFile() && f.getName().endsWith( ".jar" ) )
@@ -64,7 +60,8 @@
if ( bundle != null )
{
bundle.setSourcePathLocation( source );
- bundle.setSourceRootPath( new Path( "src" ) );
+ // TODO shouldn't be hard coded
+ bundle.setSourceRootPath( "src" );
bundles.add( bundle );
}
}
@@ -110,7 +107,7 @@
{
bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
bundle.addChild( info );
- bundle.setLocation( new Path( f.getAbsolutePath() ) );
+ bundle.setLocation( f );
}
return bundle;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepository.java b/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepository.java
index dd95eb6..5dfb7c1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepository.java
@@ -20,26 +20,26 @@
package org.apache.felix.sigil.core.repository;
+import java.io.File;
import java.util.ArrayList;
import org.apache.felix.sigil.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.repository.AbstractBundleRepository;
import org.apache.felix.sigil.repository.IRepositoryVisitor;
-import org.eclipse.core.runtime.IPath;
public class FileSystemRepository extends AbstractBundleRepository
{
private ArrayList<ISigilBundle> bundles;
- private IPath path;
+ private File dir;
private boolean recurse;
- public FileSystemRepository( String id, IPath path, boolean recurse )
+ public FileSystemRepository( String id, File dir, boolean recurse )
{
super( id );
- this.path = path;
+ this.dir = dir;
this.recurse = recurse;
}
@@ -52,7 +52,7 @@
if ( bundles == null )
{
bundles = new ArrayList<ISigilBundle>();
- DirectoryHelper.scanBundles( this, bundles, path, null, recurse );
+ DirectoryHelper.scanBundles( this, bundles, dir, null, recurse );
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepositoryProvider.java
index 58c85aa..bf05003 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/repository/FileSystemRepositoryProvider.java
@@ -26,7 +26,6 @@
import org.apache.felix.sigil.repository.IBundleRepository;
import org.apache.felix.sigil.repository.IRepositoryProvider;
import org.apache.felix.sigil.repository.RepositoryException;
-import org.eclipse.core.runtime.Path;
public class FileSystemRepositoryProvider implements IRepositoryProvider
@@ -34,13 +33,14 @@
public IBundleRepository createRepository( String id, Properties preferences ) throws RepositoryException
{
- String dir = preferences.getProperty( "dir" );
- if ( !new File( dir ).isDirectory() )
+ String dirStr = preferences.getProperty( "dir" );
+ File dir = new File( dirStr );
+ if ( !dir.isDirectory() )
{
throw new RepositoryException( "directory '" + dir + "' does not exist." );
}
boolean recurse = Boolean.valueOf( preferences.getProperty( "recurse" ) );
- return new FileSystemRepository( id, new Path( dir ), recurse );
+ return new FileSystemRepository( id, dir, recurse );
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java b/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java
index b39a7b2..2f5d971 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepository.java
@@ -20,6 +20,7 @@
package org.apache.felix.sigil.core.repository;
+import java.io.File;
import java.io.IOException;
import java.util.jar.JarFile;
@@ -31,17 +32,16 @@
import org.apache.felix.sigil.model.osgi.IPackageExport;
import org.apache.felix.sigil.repository.AbstractBundleRepository;
import org.apache.felix.sigil.repository.IRepositoryVisitor;
-import org.eclipse.core.runtime.IPath;
public class SystemRepository extends AbstractBundleRepository
{
private final String packages;
- private final IPath frameworkPath;
+ private final File frameworkPath;
- public SystemRepository( String id, IPath frameworkPath, String packages )
+ public SystemRepository( String id, File frameworkPath, String packages )
{
super( id );
this.frameworkPath = frameworkPath;
@@ -77,7 +77,7 @@
if ( frameworkPath != null )
{
systemBundle.setLocation( frameworkPath );
- jar = new JarFile( frameworkPath.toFile() );
+ jar = new JarFile(frameworkPath);
info = buildBundleModelElement( jar.getManifest() );
}
else
diff --git a/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java
index 23fb3ab..322e29f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/core/repository/SystemRepositoryProvider.java
@@ -20,6 +20,7 @@
package org.apache.felix.sigil.core.repository;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -28,7 +29,6 @@
import org.apache.felix.sigil.repository.IBundleRepository;
import org.apache.felix.sigil.repository.IRepositoryProvider;
import org.apache.felix.sigil.repository.RepositoryException;
-import org.eclipse.core.runtime.Path;
public class SystemRepositoryProvider implements IRepositoryProvider
{
@@ -36,7 +36,7 @@
public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
{
String fw = properties.getProperty( "framework" );
- Path frameworkPath = fw == null ? null : new Path( fw );
+ File frameworkPath = fw == null ? null : new File( fw );
String extraPkgs = properties.getProperty( "packages" );
String profile = properties.getProperty( "profile" );
diff --git a/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ISigilBundle.java b/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ISigilBundle.java
index 14c81ff..1b6f4bf 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ISigilBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/model/eclipse/ISigilBundle.java
@@ -20,11 +20,12 @@
package org.apache.felix.sigil.model.eclipse;
+import java.io.File;
import java.io.IOException;
import java.util.Collection;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.apache.felix.sigil.config.Resource;
import org.apache.felix.sigil.model.ICompoundModelElement;
import org.apache.felix.sigil.model.osgi.IBundleModelElement;
import org.apache.felix.sigil.model.osgi.IPackageExport;
@@ -53,13 +54,14 @@
void setBundleInfo( IBundleModelElement bundle );
- void addSourcePath( IPath path );
+ // TODO rename this method...
+ void addSourcePath( Resource path );
- void removeSourcePath( IPath path );
+ void removeSourcePath( Resource path );
- Collection<IPath> getSourcePaths();
+ Collection<Resource> getSourcePaths();
void clearSourcePaths();
@@ -74,28 +76,30 @@
void removeClasspathEntry( String encodedClasspath );
- IPath getLocation();
+ // XXX must be file due to SiglCore.isBundlePath
+ File getLocation();
- void setLocation( IPath location );
+ // XXX must be file due to SiglCore.isBundlePath
+ void setLocation( File location );
- IPath getSourcePathLocation();
+ File getSourcePathLocation();
- void setSourcePathLocation( IPath location );
+ void setSourcePathLocation( File location );
- IPath getSourceRootPath();
+ String getSourceRootPath();
- void setSourceRootPath( IPath location );
+ void setSourceRootPath( String location );
- void setLicencePathLocation( IPath cacheSourceLocation );
+ void setLicencePathLocation( File cacheSourceLocation );
- IPath getLicencePathLocation();
+ File getLicencePathLocation();
/**
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java b/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java
index 19b0aab..ceb0ab5 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/obr/impl/OBRHandler.java
@@ -148,7 +148,7 @@
URI l = makeAbsolute( uri );
info.setUpdateLocation( l );
if ( "file".equals( l.getScheme() ) ) {
- b.setLocation( new Path( new File( l ).getAbsolutePath() ) );
+ b.setLocation( new File( l ) );
}
else {
b.setLocation( cachePath( info ) );
@@ -181,10 +181,9 @@
}
- private IPath cachePath( IBundleModelElement info )
+ private File cachePath( IBundleModelElement info )
{
- return new Path( cacheDir.getAbsolutePath() )
- .append( info.getSymbolicName() + "_" + info.getVersion() + ".jar" );
+ return new File( cacheDir, info.getSymbolicName() + "_" + info.getVersion() + ".jar" );
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
new file mode 100644
index 0000000..e3a524b
--- /dev/null
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.eclipse;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * @author dave
+ *
+ */
+public class PathUtil
+{
+ /**
+ * @param sourceRootPath
+ * @return
+ */
+ public static IPath newPathIfNotNull(String path)
+ {
+ return path == null ? null : new Path(path);
+ }
+
+
+ /**
+ * @param absolutePath
+ * @return
+ */
+ public static IPath newPathIfExists(File file)
+ {
+ if (file == null) return null;
+ if (file.exists()) return new Path(file.getAbsolutePath());
+ // fine
+ return null;
+ }
+
+
+}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
index 3648ad1..8210e0f 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
@@ -20,6 +20,7 @@
package org.apache.felix.sigil.eclipse;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -364,8 +365,8 @@
{
public boolean visit( ISigilBundle b )
{
- IPath path = b.getLocation();
- if ( path != null && path.toOSString().equals( bp ) )
+ File path = b.getLocation();
+ if ( path != null && path.getAbsolutePath().equals( bp ) )
{
flag.set( true );
return false;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
index 602e5a9..96327cf 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
@@ -22,6 +22,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -34,6 +35,7 @@
import org.apache.felix.sigil.config.BldFactory;
import org.apache.felix.sigil.config.IBldProject;
+import org.apache.felix.sigil.eclipse.PathUtil;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.job.ThreadProgressMonitor;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
@@ -504,7 +506,7 @@
public IPath findBundleLocation() throws CoreException
{
- IPath p = getBundle().getLocation();
+ IPath p = PathUtil.newPathIfExists(getBundle().getLocation());
if ( p == null )
{
p = SigilCore.getDefault().findDefaultBundleLocation( this );
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
index 8dc8461..97085e2 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
@@ -117,9 +117,10 @@
ISigilBundle bundle = buildBundle( jar.getManifest(), f );
if ( bundle != null )
{
- bundle.setLocation( p );
- bundle.setSourcePathLocation( source );
- bundle.setSourceRootPath( new Path( "src" ) );
+ bundle.setLocation( f );
+ bundle.setSourcePathLocation( source.toFile() );
+ // XXX hard coded src location
+ bundle.setSourceRootPath( "src" );
bundles.add( bundle );
}
}
@@ -162,7 +163,7 @@
{
bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
bundle.addChild( info );
- bundle.setLocation( new Path( f.getAbsolutePath() ) );
+ bundle.setLocation( f );
}
return bundle;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
index 4ba57f7..dd49f0b 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
@@ -42,7 +42,8 @@
import java.util.regex.Pattern;
import org.apache.felix.sigil.common.osgi.VersionRange;
-import org.apache.felix.sigil.common.osgi.VersionRangeBoundingRule;
+import org.apache.felix.sigil.config.Resource;
+import org.apache.felix.sigil.eclipse.PathUtil;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.model.IModelElement;
@@ -65,7 +66,6 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
@@ -83,7 +83,6 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IParent;
@@ -93,7 +92,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jface.preference.IPreferenceStore;
import org.osgi.framework.Version;
@@ -484,7 +482,7 @@
if ( entries == null )
{
- IPath path = bundle.getLocation();
+ Path path = new Path(bundle.getLocation().getAbsolutePath());
if ( path == null )
{
@@ -527,7 +525,8 @@
IPath cache = bundleCache.append( name );
Collection<String> classpath = bundle.getBundleInfo().getClasspaths();
ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>( classpath.size() );
- IPath source = bundle.getSourcePathLocation();
+ IPath source = PathUtil.newPathIfExists(bundle.getSourcePathLocation());
+ IPath rootPath = PathUtil.newPathIfNotNull(bundle.getSourceRootPath());
if ( source != null && !source.toFile().exists() )
{
@@ -542,7 +541,7 @@
IPath p = ".".equals( cp ) ? path : cache.append( cp );
if ( p.toFile().exists() )
{
- IClasspathEntry e = JavaCore.newLibraryEntry( p, source, bundle.getSourceRootPath(), rules,
+ IClasspathEntry e = JavaCore.newLibraryEntry( p, source, rootPath, rules,
attributes, exported );
entries.add( e );
}
@@ -550,7 +549,7 @@
}
else
{ // default classpath is .
- IClasspathEntry e = JavaCore.newLibraryEntry( path, source, bundle.getSourceRootPath(), rules,
+ IClasspathEntry e = JavaCore.newLibraryEntry( path, source, rootPath, rules,
attributes, exported );
entries.add( e );
}
@@ -587,7 +586,7 @@
FileInputStream fin = null;
try
{
- fin = new FileInputStream( bundle.getLocation().toFile() );
+ fin = new FileInputStream( bundle.getLocation() );
JarInputStream in = new JarInputStream( fin );
JarEntry entry;
while ( ( entry = in.getNextJarEntry() ) != null )
@@ -867,9 +866,9 @@
{
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
IContentType txt = contentTypeManager.getContentType( "org.eclipse.core.runtime.text" );
- for ( IPath p : project.getBundle().getSourcePaths() )
+ for ( Resource p : project.getBundle().getSourcePaths() )
{
- IFile f = project.getProject().getFile( p );
+ IFile f = project.getProject().getFile( p.getLocalFile() );
if ( f.exists() )
{
try
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
index 2c4a399..ace847b 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
@@ -62,7 +62,7 @@
}
else {
b.synchronize(null);
- uris.add( b.getLocation().toFile().toURI() );
+ uris.add( b.getLocation().toURI() );
}
}
}
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
index bf871ff..e3055ca 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
@@ -34,6 +34,7 @@
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.classfile.JavaClass;
+import org.apache.felix.sigil.eclipse.PathUtil;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.model.util.JavaHelper;
@@ -162,7 +163,7 @@
{
if ( bundle.isSynchronized() )
{
- IPath loc = bundle.getLocation();
+ IPath loc = PathUtil.newPathIfExists(bundle.getLocation());
if ( loc == null ) {
SigilCore.error("Location is null for " + bundle);
}
diff --git a/sigil/eclipse/ui/sigil.properties b/sigil/eclipse/ui/sigil.properties
index bcce8bd..f7ab9a0 100644
--- a/sigil/eclipse/ui/sigil.properties
+++ b/sigil/eclipse/ui/sigil.properties
@@ -27,6 +27,7 @@
-imports: \
org.apache.felix.sigil.common.osgi, \
+ org.apache.felix.sigil.config, \
org.apache.felix.sigil.eclipse, \
org.apache.felix.sigil.eclipse.install, \
org.apache.felix.sigil.eclipse.job, \
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java
index 0bd889c..1237678 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java
@@ -20,9 +20,11 @@
package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
+import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.felix.sigil.config.Resource;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.model.eclipse.ISigilBundle;
@@ -33,6 +35,7 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@@ -128,22 +131,32 @@
bundle.clearSourcePaths();
- SigilUI.runInUISync( new Runnable()
+ try
{
- public void run()
+ SigilUI.runInUISync( new Callable<Void>()
{
- for ( Object o : viewer.getCheckedElements() )
+ public Void call() throws Exception
{
- if ( !viewer.getGrayed( o ) )
+ for ( Object o : viewer.getCheckedElements() )
{
- IResource r = ( IResource ) o;
- getProjectModel().getBundle().addSourcePath( r.getProjectRelativePath() );
+ if ( !viewer.getGrayed( o ) )
+ {
+ IResource r = ( IResource ) o;
+
+ getProjectModel().getBundle().addSourcePath( toBldResource(r) );
+ }
}
+
+ return null;
}
- }
- } );
+ } );
- super.commit( onSave );
+ super.commit( onSave );
+ }
+ catch (Exception e)
+ {
+ SigilCore.warn("Failed to update resource", e);
+ }
}
@@ -151,9 +164,9 @@
protected void refreshSelections()
{
// zero the state
- for ( IPath path : getProjectModel().getBundle().getSourcePaths() )
+ for ( Resource path : getProjectModel().getBundle().getSourcePaths() )
{
- IResource r = findResource( path );
+ IResource r = findResource( new Path(path.getLocalFile()) );
if ( r != null )
{
viewer.expandToLevel( r, 0 );
@@ -172,16 +185,35 @@
@Override
protected void syncResourceModel( IResource element, boolean checked )
{
- if ( checked )
+ try
{
- getProjectModel().getBundle().addSourcePath( element.getProjectRelativePath() );
- }
- else
- {
- getProjectModel().getBundle().removeSourcePath( element.getProjectRelativePath() );
- }
+ Resource resource = toBldResource(element);
+
+ if ( checked )
+ {
+ getProjectModel().getBundle().addSourcePath( resource );
+ }
+ else
+ {
+ getProjectModel().getBundle().removeSourcePath( resource );
+ }
- markDirty();
+ markDirty();
+ }
+ catch (CoreException e)
+ {
+ SigilCore.warn("Failed to sync resource " + element, e);
+ }
+ }
+
+ /**
+ * @param element
+ * @return
+ * @throws CoreException
+ */
+ private Resource toBldResource(IResource element) throws CoreException
+ {
+ return getProjectModel().getBldProject().newResource(element.getProjectRelativePath().toString());
}
private AtomicBoolean disposed = new AtomicBoolean();
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
index dc5c099..0896812 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
@@ -55,7 +55,6 @@
import org.apache.ivy.plugins.resolver.BasicResolver;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.FileUtil;
-import org.eclipse.core.runtime.IPath;
/**
@@ -212,7 +211,7 @@
try
{
- URL url = ( uri != null ) ? uri.toURL() : bundle.getLocation().toFile().toURL();
+ URL url = ( uri != null ) ? uri.toURL() : bundle.getLocation().toURL();
if ( name.contains( "!" ) )
{
String[] split = name.split( "!" );
@@ -466,11 +465,11 @@
return uri.toURL();
}
else {
- IPath path = bundle.getLocation();
+ File path = bundle.getLocation();
if ( path == null ) {
throw new NullPointerException( "Missing location for " + bundle.getSymbolicName() );
}
- return path.toFile().toURI().toURL();
+ return path.toURI().toURL();
}
}