|
15 | 15 |
|
16 | 16 | import java.text.MessageFormat; |
17 | 17 | import java.util.Arrays; |
18 | | -import java.util.Optional; |
19 | 18 |
|
20 | 19 | import org.eclipse.core.resources.IFile; |
21 | 20 | import org.eclipse.core.resources.IProject; |
@@ -196,25 +195,24 @@ protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws Co |
196 | 195 | } |
197 | 196 | BundleDescription requiredBundle = getChangeObject(); |
198 | 197 | String pluginId = requiredBundle.getSymbolicName(); |
| 198 | + VersionRange versionRange = ManifestUtils |
| 199 | + .createConsumerRequirementRange(requiredBundle.getVersion()).orElse(null); |
199 | 200 | IPluginImport[] imports = base.getPluginBase().getImports(); |
200 | 201 | if (!isUndo()) { |
201 | 202 | if (Arrays.stream(imports).map(IPluginImport::getId).anyMatch(pluginId::equals)) { |
202 | 203 | return; |
203 | 204 | } |
204 | 205 | IPluginImport impt = base.getPluginFactory().createImport(); |
205 | 206 | impt.setId(pluginId); |
206 | | - Optional<String> versionRange = ManifestUtils |
207 | | - .createConsumerRequirementRange(requiredBundle.getVersion()) |
208 | | - .map(VersionRange::toString); |
209 | | - if (versionRange.isPresent()) { |
210 | | - impt.setVersion(versionRange.get()); |
| 207 | + if (versionRange != null) { |
| 208 | + impt.setVersion(versionRange.toString()); |
211 | 209 | } |
212 | 210 | base.getPluginBase().add(impt); |
213 | 211 | } else { |
214 | 212 | for (IPluginImport pluginImport : imports) { |
215 | | - if (pluginImport.getId().equals(pluginId)) { |
| 213 | + if (pluginImport.getId().equals(pluginId) && (versionRange == null |
| 214 | + || versionRange.includes(Version.parseVersion(pluginImport.getVersion())))) { |
216 | 215 | base.getPluginBase().remove(pluginImport); |
217 | | - // TODO: Consider version too! |
218 | 216 | } |
219 | 217 | } |
220 | 218 | } |
|
0 commit comments