Skip to content

Commit 847e02d

Browse files
committed
Remove compatibility with pre 1.6 Ant
Ant 1.6.0 was released in 2003(!). Complicating the codebase to be compatible with 22+ years old Ant versions is just not worth it.
1 parent a848846 commit 847e02d

File tree

7 files changed

+15
-79
lines changed

7 files changed

+15
-79
lines changed

ant/org.eclipse.ant.launching/common/org/eclipse/ant/internal/launching/debug/AntDebugState.java

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2015 IBM Corporation and others.
2+
* Copyright (c) 2005, 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
@@ -225,7 +225,7 @@ public Location getBreakpointLocation() {
225225
if (considerTargetBreakpoints()) {
226226
Target targetExecuting = getTargetExecuting();
227227
if (targetExecuting != null) {
228-
return getLocation(targetExecuting);
228+
return targetExecuting.getLocation();
229229
}
230230
}
231231
return null;
@@ -320,77 +320,15 @@ public void targetStarted(BuildEvent event) {
320320
setConsiderTargetBreakpoints(true);
321321
}
322322

323-
public int getLineNumber(Location location) {
324-
try { // succeeds with Ant newer than 1.6
325-
return location.getLineNumber();
326-
}
327-
catch (NoSuchMethodError e) {
328-
// Ant before 1.6
329-
String locationString = location.toString();
330-
if (locationString.length() == 0) {
331-
return 0;
332-
}
333-
// filename: lineNumber: ("c:\buildfile.xml: 12: ")
334-
int lastIndex = locationString.lastIndexOf(':');
335-
int index = locationString.lastIndexOf(':', lastIndex - 1);
336-
if (index != -1) {
337-
try {
338-
return Integer.parseInt(locationString.substring(index + 1, lastIndex));
339-
}
340-
catch (NumberFormatException nfe) {
341-
return 0;
342-
}
343-
}
344-
return 0;
345-
}
346-
}
347-
348-
public static Location getLocation(Target target) {
349-
try {// succeeds with Ant newer than 1.6.2
350-
return target.getLocation();
351-
}
352-
catch (NoSuchMethodError e) {
353-
return Location.UNKNOWN_LOCATION;
354-
}
355-
}
356-
357-
public String getFileName(Location location) {
358-
try {// succeeds with Ant newer than 1.6
359-
return location.getFileName();
360-
}
361-
catch (NoSuchMethodError e) {
362-
// Ant before 1.6
363-
String locationString = location.toString();
364-
if (locationString.length() == 0) {
365-
return null;
366-
}
367-
// filename: lineNumber: ("c:\buildfile.xml: 12: ")
368-
int lastIndex = locationString.lastIndexOf(':');
369-
int index = locationString.lastIndexOf(':', lastIndex - 1);
370-
if (index == -1) {
371-
index = lastIndex; // only the filename is known
372-
}
373-
if (index != -1) {
374-
// bug 84403
375-
// if (locationString.startsWith("file:")) {
376-
// return FileUtils.newFileUtils().fromURI(locationString);
377-
// }
378-
// remove file:
379-
return locationString.substring(5, index);
380-
}
381-
return null;
382-
}
383-
}
384-
385323
private void appendToStack(StringBuffer stackRepresentation, String targetName, String taskName, Location location) {
386324
stackRepresentation.append(targetName);
387325
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
388326
stackRepresentation.append(taskName);
389327
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
390328

391-
stackRepresentation.append(getFileName(location));
329+
stackRepresentation.append(location.getFileName());
392330
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
393-
stackRepresentation.append(getLineNumber(location));
331+
stackRepresentation.append(location.getLineNumber());
394332
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
395333
}
396334

@@ -412,7 +350,7 @@ public void marshalStack(StringBuffer stackRepresentation) {
412350
}
413351

414352
if (!isAfterTaskEvent()) {
415-
appendToStack(stackRepresentation, targetExecuting.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(targetExecuting));
353+
appendToStack(stackRepresentation, targetExecuting.getName(), IAntCoreConstants.EMPTY_STRING, targetExecuting.getLocation());
416354
}
417355
for (int i = tasks.size() - 1; i >= 0; i--) {
418356
Task task = tasks.get(i);
@@ -450,7 +388,7 @@ private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Targ
450388
for (int i = startIndex; i <= dependancyStackDepth; i++) {
451389
stackTarget = buildSequence.get(i);
452390
if (stackTarget.dependsOn(targetExecuting.getName())) {
453-
appendToStack(stackRepresentation, stackTarget.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(stackTarget));
391+
appendToStack(stackRepresentation, stackTarget.getName(), IAntCoreConstants.EMPTY_STRING, stackTarget.getLocation());
454392
}
455393
}
456394
}
-510 Bytes
Binary file not shown.
-43 Bytes
Binary file not shown.

ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessBuildLogger.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.eclipse.ant.internal.launching.AntLaunch;
2929
import org.eclipse.ant.internal.launching.AntLaunching;
3030
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
31-
import org.eclipse.ant.internal.launching.debug.AntDebugState;
3231
import org.eclipse.ant.internal.launching.launchConfigurations.AntProcess;
3332
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamMonitor;
3433
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamsProxy;
@@ -287,7 +286,7 @@ public void targetStarted(BuildEvent event) {
287286
msg.append(targetName);
288287
msg.append(':');
289288
String message = msg.toString();
290-
Location location = AntDebugState.getLocation(target);
289+
Location location = target.getLocation();
291290
if (location != null && location != Location.UNKNOWN_LOCATION) {
292291
IRegion region = new Region(0, targetName.length());
293292
AntProcess antProcess = getAntProcess(fProcessId);

ant/org.eclipse.ant.launching/loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessDebugBuildLogger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2004, 2016 IBM Corporation and others.
2+
* Copyright (c) 2004, 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
@@ -219,8 +219,8 @@ private IBreakpoint breakpointAtLineNumber(Location location) {
219219
if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
220220
return null;
221221
}
222-
int lineNumber = fDebugState.getLineNumber(location);
223-
File locationFile = new File(fDebugState.getFileName(location));
222+
int lineNumber = location.getLineNumber();
223+
File locationFile = new File(location.getFileName());
224224
for (IBreakpoint bp : fBreakpoints) {
225225
ILineBreakpoint breakpoint = (ILineBreakpoint) bp;
226226
int breakpointLineNumber;

ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBuildLogger.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2003, 2016 IBM Corporation and others.
2+
* Copyright (c) 2003, 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
@@ -30,7 +30,6 @@
3030
import org.apache.tools.ant.Project;
3131
import org.apache.tools.ant.Target;
3232
import org.apache.tools.ant.util.StringUtils;
33-
import org.eclipse.ant.internal.launching.debug.AntDebugState;
3433
import org.eclipse.ant.internal.launching.remote.AntSecurityException;
3534
import org.eclipse.ant.internal.launching.remote.IAntCoreConstants;
3635
import org.eclipse.ant.internal.launching.remote.InternalAntRunner;
@@ -358,7 +357,7 @@ private void marshalTaskMessage(BuildEvent event) throws IOException {
358357

359358
private void marshalTargetMessage(BuildEvent event) {
360359
Target target = event.getTarget();
361-
Location location = AntDebugState.getLocation(target);
360+
Location location = target.getLocation();
362361

363362
StringBuilder message = new StringBuilder();
364363
message.append(MessageIds.TARGET);

ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntDebugBuildLogger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2003, 2016 IBM Corporation and others.
2+
* Copyright (c) 2003, 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
@@ -302,8 +302,8 @@ private RemoteAntBreakpoint breakpointAtLineNumber(Location location) {
302302
if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
303303
return null;
304304
}
305-
String fileName = fDebugState.getFileName(location);
306-
int lineNumber = fDebugState.getLineNumber(location);
305+
String fileName = location.getFileName();
306+
int lineNumber = location.getLineNumber();
307307
for (RemoteAntBreakpoint breakpoint : fBreakpoints) {
308308
if (breakpoint.isAt(fileName, lineNumber)) {
309309
return breakpoint;

0 commit comments

Comments
 (0)