Skip to content

Commit 805f9b4

Browse files
committed
Remove o.e.ant.tests.ui activator
In an effort to fix Java 21 warning about usage of deprecated URL constructor the code has been simplified and moved to the single place used.
1 parent 7d4ea6f commit 805f9b4

File tree

4 files changed

+19
-79
lines changed

4 files changed

+19
-79
lines changed

ant/org.eclipse.ant.tests.ui/META-INF/MANIFEST.MF

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.ant.tests.ui; singleton:=true
55
Bundle-Version: 3.12.0.qualifier
66
Bundle-ClassPath: anttestsui.jar
7-
Bundle-Activator: org.eclipse.ant.tests.ui.testplugin.AntUITestPlugin
87
Bundle-Vendor: %providerName
98
Bundle-Localization: plugin
109
Export-Package: org.eclipse.ant.tests.ui,

ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.UnsupportedEncodingException;
2626
import java.lang.reflect.InvocationTargetException;
2727
import java.lang.reflect.Method;
28+
import java.net.URL;
2829
import java.nio.file.Files;
2930

3031
import javax.xml.parsers.SAXParser;
@@ -42,6 +43,8 @@
4243
import org.eclipse.core.resources.ResourcesPlugin;
4344
import org.eclipse.core.runtime.Assert;
4445
import org.eclipse.core.runtime.CoreException;
46+
import org.eclipse.core.runtime.FileLocator;
47+
import org.eclipse.core.runtime.IPath;
4548
import org.eclipse.core.runtime.IProgressMonitor;
4649
import org.eclipse.core.runtime.IStatus;
4750
import org.eclipse.core.runtime.Status;
@@ -74,6 +77,8 @@
7477
import org.eclipse.ui.progress.UIJob;
7578
import org.junit.Before;
7679
import org.junit.Rule;
80+
import org.osgi.framework.Bundle;
81+
import org.osgi.framework.FrameworkUtil;
7782
import org.xml.sax.InputSource;
7883
import org.xml.sax.SAXException;
7984
import org.xml.sax.helpers.DefaultHandler;
@@ -161,7 +166,7 @@ public static void assertProject() throws Exception {
161166
IProject project = ProjectHelper.createProject(ProjectHelper.PROJECT_NAME);
162167
IFolder folder = ProjectHelper.addFolder(project, "buildfiles"); //$NON-NLS-1$
163168
ProjectHelper.addFolder(project, "launchConfigurations"); //$NON-NLS-1$
164-
File root = AntUITestPlugin.getDefault().getFileInPlugin(ProjectHelper.TEST_BUILDFILES_DIR);
169+
File root = getFileInPlugin(ProjectHelper.TEST_BUILDFILES_DIR);
165170
ProjectHelper.importFilesFromDirectory(root, folder.getFullPath(), null);
166171

167172
ProjectHelper.createLaunchConfigurationForBoth("echoing"); //$NON-NLS-1$
@@ -191,6 +196,17 @@ public static void assertProject() throws Exception {
191196
}
192197
}
193198

199+
public static File getFileInPlugin(IPath path) {
200+
try {
201+
Bundle bundle = FrameworkUtil.getBundle(AbstractAntUITest.class);
202+
URL installURL = bundle.getEntry("/" + path.toString()); //$NON-NLS-1$
203+
URL localURL = FileLocator.toFileURL(installURL);
204+
return new File(localURL.getFile());
205+
} catch (IOException e) {
206+
return null;
207+
}
208+
}
209+
194210
/**
195211
* Returns the 'AntUITests' project.
196212
*

ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/AntUITestPlugin.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

ant/org.eclipse.ant.tests.ui/test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2013 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,7 +17,6 @@
1717
import java.io.IOException;
1818
import java.lang.reflect.InvocationTargetException;
1919
import java.util.ArrayList;
20-
import java.util.Iterator;
2120
import java.util.List;
2221

2322
import org.eclipse.ant.internal.ui.IAntUIConstants;
@@ -91,13 +90,6 @@ private static void addNatureToProject(IProject proj, String natureId, IProgress
9190
proj.setDescription(description, monitor);
9291
}
9392

94-
/**
95-
* Removes an IProject.
96-
*/
97-
public static void delete(IProject project) throws CoreException {
98-
project.delete(true, true, null);
99-
}
100-
10193
/**
10294
* Adds a folder to an IProject.
10395
*/
@@ -135,9 +127,7 @@ private static void addFiles(File dir, List<File> collection) throws IOException
135127
subDirs.add(file);
136128
}
137129
}
138-
Iterator<File> iter = subDirs.iterator();
139-
while (iter.hasNext()) {
140-
File subDir = iter.next();
130+
for (File subDir : subDirs) {
141131
addFiles(subDir, collection);
142132
}
143133
}

0 commit comments

Comments
 (0)