Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 264338 | Differences between
and this patch

Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 7-13 Link Here
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.ant.core,
9
Export-Package: org.eclipse.ant.core,
10
 org.eclipse.ant.internal.core;x-friends:="org.eclipse.ant.ui",
10
 org.eclipse.ant.internal.core;x-friends:="org.eclipse.ant.ui,org.eclipse.ant.launching",
11
 org.eclipse.ant.internal.core.contentDescriber;x-internal:=true
11
 org.eclipse.ant.internal.core.contentDescriber;x-internal:=true
12
Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)",
12
Require-Bundle: org.eclipse.core.variables;bundle-version="[3.1.0,4.0.0)",
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
13
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)"
(-).classpath (+3 lines)
Lines 3-7 Link Here
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="src" output="loggers_bin" path="loggers"/>
7
	<classpathentry kind="src" output="common_bin" path="common"/>
8
	<classpathentry kind="src" output="remote_bin" path="remote"/>
6
	<classpathentry kind="output" path="bin"/>
9
	<classpathentry kind="output" path="bin"/>
7
</classpath>
10
</classpath>
(-).cvsignore (-1 / +6 lines)
Line 1 Link Here
1
bin
1
bin
2
lib
3
temp.folder
4
loggers_bin
5
common_bin
6
remote_bin
(-).externalToolBuilders/build (+21 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
5
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1254539808328_112&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.ant.launching/lib&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
7
<listEntry value="/org.eclipse.ant.launching/buildfiles/buildCommonDebug.xml"/>
8
</listAttribute>
9
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
10
<listEntry value="1"/>
11
</listAttribute>
12
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
13
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ant.launching"/>
15
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
16
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1254539834953_113&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.ant.launching/common&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
17
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.ant.launching/buildfiles/buildCommonDebug.xml}"/>
18
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
19
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
20
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
21
</launchConfiguration>
(-).externalToolBuilders/build (+22 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
5
<booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/>
6
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1254539604968_29&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.ant.launching/lib&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
7
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
8
<listEntry value="/org.eclipse.ant.launching/buildfiles/buildLoggers.xml"/>
9
</listAttribute>
10
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
11
<listEntry value="1"/>
12
</listAttribute>
13
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
14
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
15
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ant.launching"/>
16
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
17
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1254539671875_56&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.ant.launching/loggers&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
18
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.ant.launching/buildfiles/buildLoggers.xml}"/>
19
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
20
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
21
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
22
</launchConfiguration>
(-).externalToolBuilders/build (+21 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
5
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1254617191468_44&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.ant.launching/lib&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
7
<listEntry value="/org.eclipse.ant.launching/buildfiles/buildRemote.xml"/>
8
</listAttribute>
9
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
10
<listEntry value="1"/>
11
</listAttribute>
12
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
13
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ant.launching"/>
15
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
16
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;launchConfigurationWorkingSet factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; id=&quot;1254617206453_45&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#13;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/org.eclipse.ant.launching/remote&quot; type=&quot;2&quot;/&gt;&#13;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/>
17
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.ant.launching/buildfiles/buildRemote.xml}"/>
18
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
19
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
20
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
21
</launchConfiguration>
(-).project (+30 lines)
Lines 25-30 Link Here
25
			<arguments>
25
			<arguments>
26
			</arguments>
26
			</arguments>
27
		</buildCommand>
27
		</buildCommand>
28
		<buildCommand>
29
			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
30
			<triggers>auto,full,incremental,</triggers>
31
			<arguments>
32
				<dictionary>
33
					<key>LaunchConfigHandle</key>
34
					<value>&lt;project&gt;/.externalToolBuilders/build loggers [Builder].launch</value>
35
				</dictionary>
36
			</arguments>
37
		</buildCommand>
38
		<buildCommand>
39
			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
40
			<triggers>auto,full,incremental,</triggers>
41
			<arguments>
42
				<dictionary>
43
					<key>LaunchConfigHandle</key>
44
					<value>&lt;project&gt;/.externalToolBuilders/build common debug [Builder].launch</value>
45
				</dictionary>
46
			</arguments>
47
		</buildCommand>
48
		<buildCommand>
49
			<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
50
			<triggers>auto,full,incremental,</triggers>
51
			<arguments>
52
				<dictionary>
53
					<key>LaunchConfigHandle</key>
54
					<value>&lt;project&gt;/.externalToolBuilders/build remote support [Builder].launch</value>
55
				</dictionary>
56
			</arguments>
57
		</buildCommand>
28
	</buildSpec>
58
	</buildSpec>
29
	<natures>
59
	<natures>
30
		<nature>org.eclipse.pde.PluginNature</nature>
60
		<nature>org.eclipse.pde.PluginNature</nature>
(-).settings/org.eclipse.jdt.core.prefs (-2 / +2 lines)
Lines 1-6 Link Here
1
#Wed Sep 16 09:44:05 CDT 2009
1
#Sun Sep 20 13:08:07 CEST 2009
2
eclipse.preferences.version=1
2
eclipse.preferences.version=1
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6
org.eclipse.jdt.core.compiler.compliance=1.4
6
org.eclipse.jdt.core.compiler.compliance=1.4
(-).settings/org.eclipse.pde.prefs (+25 lines)
Added Link Here
1
#Wed Oct 07 12:57:43 CDT 2009
2
compilers.f.unresolved-features=1
3
compilers.f.unresolved-plugins=1
4
compilers.incompatible-environment=1
5
compilers.p.build=1
6
compilers.p.deprecated=1
7
compilers.p.discouraged-class=1
8
compilers.p.internal=1
9
compilers.p.missing-packages=1
10
compilers.p.missing-version-export-package=2
11
compilers.p.missing-version-import-package=2
12
compilers.p.missing-version-require-bundle=1
13
compilers.p.no-required-att=0
14
compilers.p.not-externalized-att=1
15
compilers.p.unknown-attribute=1
16
compilers.p.unknown-class=1
17
compilers.p.unknown-element=1
18
compilers.p.unknown-identifier=1
19
compilers.p.unknown-resource=1
20
compilers.p.unresolved-ex-points=0
21
compilers.p.unresolved-import=0
22
compilers.s.create-docs=false
23
compilers.s.doc-folder=doc
24
compilers.s.open-tags=1
25
eclipse.preferences.version=1
(-)META-INF/MANIFEST.MF (-4 / +17 lines)
Lines 1-16 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Localization: plugin
3
Bundle-Name: %pluginName
4
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.ant.launching
5
Bundle-SymbolicName: org.eclipse.ant.launching;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching
7
Bundle-Activator: org.eclipse.ant.internal.launching.AntLaunching
7
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
8
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
8
 org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)",
9
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
9
 org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
10
 org.eclipse.jdt.launching;bundle-version="[3.5.0,4.0.0)",
10
 org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)",
11
 org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
12
 org.eclipse.ant.core;bundle-version="[3.2.0,4.0.0)",
12
 org.apache.ant;bundle-version="1.7.1"
13
 org.apache.ant;bundle-version="1.7.1",
14
 org.eclipse.jdt.core;bundle-version="3.5.0",
15
 org.eclipse.core.commands;bundle-version="3.5.0",
16
 org.eclipse.core.externaltools;bundle-version="1.0.0"
13
Bundle-RequiredExecutionEnvironment: J2SE-1.4
17
Bundle-RequiredExecutionEnvironment: J2SE-1.4
14
Bundle-ActivationPolicy: lazy
18
Bundle-ActivationPolicy: lazy
15
Bundle-Vendor: %providerName
19
Bundle-Vendor: %providerName
16
Export-Package: org.eclipse.ant.internal.launching;x-internal:=true
20
Export-Package: org.eclipse.ant.internal.launching;x-friends:="org.eclipse.ant.ui",
21
 org.eclipse.ant.internal.launching.debug;x-friends:="org.eclipse.ant.ui",
22
 org.eclipse.ant.internal.launching.debug.model;x-friends:="org.eclipse.ant.ui",
23
 org.eclipse.ant.internal.launching.launchConfigurations;x-friends:="org.eclipse.ant.ui",
24
 org.eclipse.ant.launching
25
Import-Package: com.ibm.icu.text,
26
 org.eclipse.ant.internal.launching.launchConfigurations,
27
 org.eclipse.core.filebuffers,
28
 org.eclipse.jface.preference,
29
 org.eclipse.jface.text
(-)build.properties (-2 / +29 lines)
Lines 1-4 Link Here
1
source.. = src/
1
###############################################################################
2
# Copyright (c) 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
# 
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
source.. = src/                           
2
output.. = bin/
12
output.. = bin/
3
bin.includes = META-INF/,\
13
bin.includes = META-INF/,\
4
               .
14
               .,\
15
               plugin.xml,\
16
               plugin.properties,\
17
               lib/antdebug.jar,\
18
               lib/loggers.jar,\
19
               lib/remote.jar
20
21
jars.compile.order = .,\
22
				                     lib/antdebug.jar,\
23
                     lib/loggers.jar,\
24
                     lib/remote.jar
25
source.lib/loggers.jar = loggers/
26
output.lib/loggers.jar = loggers_bin/
27
source.lib/antdebug.jar = common/
28
output.lib/antdebug.jar = common_bin/
29
source.lib/remote.jar = remote/
30
output.lib/remote.jar = remote_bin
31
src.includes = about.html
(-)buildfiles/buildCommonDebug.xml (+39 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
     Copyright (c) 2005, 2009 IBM Corporation and others.
4
     All rights reserved. This program and the accompanying materials
5
     are made available under the terms of the Eclipse Public License v1.0
6
     which accompanies this distribution, and is available at
7
     http://www.eclipse.org/legal/epl-v10.html
8
    
9
     Contributors:
10
         IBM Corporation - initial API and implementation
11
 -->
12
13
<project name="Build Ant common debug support JAR" default="build" basedir="..">
14
	
15
	<target name="build" description="Cleans, builds and refreshes" depends="clean, lib/antdebuglib.jar"/>
16
17
	<target name="init">
18
		<property name="temp.folder" value="${basedir}/temp.folder"/>
19
		<property name="build.result.folder" value="${basedir}"/>
20
	</target>
21
	
22
	<target name="lib/antdebuglib.jar" description= "Creates the antdebug.jar" depends="init">
23
		<property name="destdir" value="${temp.folder}/lib/antdebug.jar.bin"/>
24
		<delete dir="${destdir}"/>
25
		<mkdir dir="${destdir}"/>
26
		<!-- copy necessary class files resources -->
27
		<copy todir="${destdir}">
28
			<fileset dir="${basedir}/common_bin"/>
29
		</copy>
30
		<mkdir dir="${build.result.folder}/lib"/>
31
		<jar destfile="${build.result.folder}/lib/antdebug.jar" basedir="${destdir}"/>
32
		<delete dir="${temp.folder}"/>
33
	</target>
34
35
	<target name="clean" description="Deletes previous build remnants" depends="init">
36
		<delete file="${build.result.folder}/lib/antdebug.jar"/>
37
		<delete dir="${temp.folder}"/>
38
	</target>
39
</project>
(-)buildfiles/buildLoggers.xml (+39 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
     Copyright (c) 2005, 2009 IBM Corporation and others.
4
     All rights reserved. This program and the accompanying materials
5
     are made available under the terms of the Eclipse Public License v1.0
6
     which accompanies this distribution, and is available at
7
     http://www.eclipse.org/legal/epl-v10.html
8
    
9
     Contributors:
10
         IBM Corporation - initial API and implementation
11
 -->
12
13
<project name="Build Ant loggers support JAR" default="build" basedir="..">
14
	
15
	<target name="build" description="Cleans, builds and refreshes" depends="clean, lib/loggerslib.jar"/>
16
17
	<target name="init">
18
		<property name="temp.folder" value="${basedir}/temp.folder"/>
19
		<property name="build.result.folder" value="${basedir}"/>
20
	</target>
21
22
	<target name="lib/loggerslib.jar" description= "Creates the loggers.jar" depends="init">
23
		<property name="destdir" value="${temp.folder}/lib/loggers.jar.bin"/>
24
		<delete dir="${destdir}"/>
25
		<mkdir dir="${destdir}"/>
26
		<!-- copy necessary class files resources -->
27
		<copy todir="${destdir}">
28
			<fileset dir="${basedir}/loggers_bin/"/>
29
		</copy>
30
		<mkdir dir="${build.result.folder}/lib"/>
31
		<jar destfile="${build.result.folder}/lib/loggers.jar" basedir="${destdir}"/>
32
		<delete dir="${temp.folder}"/>
33
	</target>
34
35
	<target name="clean" description="Deletes previous build remnants" depends="init">
36
		<delete file="${build.result.folder}/lib/loggers.jar"/>
37
		<delete dir="${temp.folder}"/>
38
	</target>
39
</project>
(-)buildfiles/buildRemote.xml (+39 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
     Copyright (c) 2005, 2009 IBM Corporation and others.
4
     All rights reserved. This program and the accompanying materials
5
     are made available under the terms of the Eclipse Public License v1.0
6
     which accompanies this distribution, and is available at
7
     http://www.eclipse.org/legal/epl-v10.html
8
    
9
     Contributors:
10
         IBM Corporation - initial API and implementation
11
 -->
12
13
<project name="Build Ant remote support JAR" default="build" basedir="..">
14
	
15
	<target name="build" description="Cleans, builds and refreshes" depends="clean, lib/remotelib.jar"/>
16
17
	<target name="init">
18
		<property name="temp.folder" value="${basedir}/temp.folder"/>
19
		<property name="build.result.folder" value="${basedir}"/>
20
	</target>
21
	
22
	<target name="lib/remotelib.jar" description= "Creates the remote.jar" depends="init">
23
		<property name="destdir" value="${temp.folder}/lib/remote.jar.bin"/>
24
		<delete dir="${destdir}"/>
25
		<mkdir dir="${destdir}"/>
26
		<!-- copy necessary class files resources -->
27
		<copy todir="${destdir}">
28
			<fileset dir="${basedir}/remote_bin"/>
29
		</copy>
30
		<mkdir dir="${build.result.folder}/lib"/>
31
		<jar destfile="${build.result.folder}/lib/remote.jar" basedir="${destdir}"/>
32
		<delete dir="${temp.folder}"/>
33
	</target>
34
35
	<target name="clean" description="Deletes previous build remnants" depends="init">
36
		<delete file="${build.result.folder}/lib/remote.jar"/>
37
		<delete dir="${temp.folder}"/>
38
	</target>
39
</project>
(-)common/META-INF/eclipse.inf (+1 lines)
Added Link Here
1
jarprocessor.exclude.sign=true
(-)common/org/eclipse/ant/internal/launching/debug/AntDebugState.java (+530 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.debug;
13
14
import java.util.HashMap;
15
import java.util.Hashtable;
16
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Stack;
19
import java.util.Vector;
20
21
import org.apache.tools.ant.BuildEvent;
22
import org.apache.tools.ant.Location;
23
import org.apache.tools.ant.Project;
24
import org.apache.tools.ant.Target;
25
import org.apache.tools.ant.Task;
26
import org.apache.tools.ant.taskdefs.MacroInstance;
27
import org.eclipse.ant.internal.launching.debug.model.DebugMessageIds;
28
29
public class AntDebugState {
30
    
31
    private static final String fgAntTaskName= "ant"; //$NON-NLS-1$
32
    private static final String fgAntCallTaskName= "antcall"; //$NON-NLS-1$
33
    
34
	private IDebugBuildLogger fLogger;
35
	private Stack fTasks= new Stack();
36
	private Map fTaskToProxies= new HashMap();
37
	private Task fCurrentTask;
38
	private Task fStepOverTask;
39
	private Task fStepIntoTask;
40
	private Task fLastTaskFinished;
41
    
42
	//properties set before execution
43
    private Map fInitialProperties= null;
44
	private Map fProperties= null;
45
    
46
    private Map fProjectToTargetNames= null;
47
    private Map fProjectToMapOfTargetToBuildSequence= null;
48
    private Stack fTargetsToExecute= new Stack();
49
    private Stack fTargetsExecuting= new Stack();
50
	
51
	private boolean fConsiderTargetBreakpoints= false;
52
	private boolean fShouldSuspend;
53
	private boolean fClientSuspend= false;
54
	private boolean fStepIntoSuspend= false;
55
	private boolean fIsAfterTaskEvent= false;
56
	
57
	
58
	public AntDebugState(IDebugBuildLogger logger) {
59
		fLogger= logger;
60
	}
61
62
	public void waitIfSuspended() {
63
		fLogger.waitIfSuspended();
64
	}
65
66
	public Task getLastTaskFinished() {
67
		return fLastTaskFinished;
68
	}
69
70
	private void setLastTaskFinished(Task lastTaskFinished) {
71
		fLastTaskFinished= lastTaskFinished;
72
73
	}
74
75
	public Task getCurrentTask() {
76
		return fCurrentTask;
77
	}
78
79
	public void setCurrentTask(Task currentTask) {
80
		fCurrentTask= currentTask;
81
82
	}
83
84
	private Map getInitialProperties() {
85
		return fInitialProperties;
86
	}
87
88
	public Task getStepOverTask() {
89
		return fStepOverTask;
90
	}
91
92
	public void setStepOverTask(Task stepOverTask) {
93
		fStepOverTask= stepOverTask;
94
95
	}
96
97
	private boolean considerTargetBreakpoints() {
98
		return fConsiderTargetBreakpoints;
99
	}
100
101
	private void setConsiderTargetBreakpoints(boolean considerTargetBreakpoints) {
102
		fConsiderTargetBreakpoints= considerTargetBreakpoints;
103
	}
104
105
	private Stack getTasks() {
106
		return fTasks;
107
	}
108
	
109
	public void setShouldSuspend(boolean shouldSuspend) {
110
		fShouldSuspend= shouldSuspend;
111
	}
112
113
	public boolean shouldSuspend() {
114
		return fShouldSuspend;
115
	}
116
117
	private Map getTargetToBuildSequence(Project project) {
118
		return (Map) fProjectToMapOfTargetToBuildSequence.get(project);
119
	}
120
121
	public void setTargetToExecute(Target target) {
122
        if (target == null) {
123
            fTargetsToExecute.pop();
124
        } else {
125
            fTargetsToExecute.push(target);
126
        }
127
	}
128
129
	public void setTargetExecuting(Target target) {
130
        if (target == null) {
131
            fTargetsExecuting.pop();
132
        } else {
133
            fTargetsExecuting.push(target);
134
        }
135
	}
136
137
	private Target getTargetToExecute() {
138
	    if (fTargetsToExecute.isEmpty()) {
139
            return null;
140
        }
141
		return (Target) fTargetsToExecute.peek();
142
	}
143
	
144
	private Target getTargetExecuting() {
145
        if (fTargetsExecuting.isEmpty()) {
146
            return null;
147
        }
148
		return (Target) fTargetsExecuting.peek();
149
	}
150
151
	public boolean isStepIntoSuspend() {
152
		return isAfterTaskEvent() && fStepIntoSuspend;
153
	}
154
155
	public void setStepIntoSuspend(boolean stepIntoSuspend) {
156
		fStepIntoSuspend = stepIntoSuspend;
157
	}
158
159
	public boolean isClientSuspend() {
160
		return fClientSuspend;
161
	}
162
163
	public void setClientSuspend(boolean clientSuspend) {
164
		fClientSuspend = clientSuspend;
165
	}
166
167
	public Task getStepIntoTask() {
168
		return fStepIntoTask;
169
	}
170
171
	public void setStepIntoTask(Task stepIntoTask) {
172
		fStepIntoTask = stepIntoTask;
173
	}
174
	
175
	public void resume() {
176
		fLogger.notifyAll();
177
	}
178
179
	public Map getProperties() {
180
		return fProperties;
181
	}
182
	
183
	public Location getBreakpointLocation() {
184
		if (isAfterTaskEvent() && getCurrentTask() != null) {
185
			return getCurrentTask().getLocation();
186
		}
187
		if (considerTargetBreakpoints()) {
188
	        Target targetExecuting= getTargetExecuting();
189
	        if (targetExecuting != null) {
190
                return getLocation(targetExecuting);      
191
            }
192
		}
193
		return null;
194
	}
195
196
	private boolean isAfterTaskEvent() {
197
		return fIsAfterTaskEvent;
198
	}
199
200
	private void setAfterTaskEvent(boolean isAfterTaskEvent) {
201
		fIsAfterTaskEvent = isAfterTaskEvent;
202
	}
203
	
204
	public void taskStarted(BuildEvent event) {
205
		setAfterTaskEvent(true);
206
		if (getInitialProperties() == null) {//implicit or top level target does not fire targetStarted()
207
			fInitialProperties= event.getProject().getProperties();
208
		}
209
		
210
		setCurrentTask(event.getTask());
211
		setConsiderTargetBreakpoints(false);
212
		if (!getTasks().isEmpty()) {
213
			//cache the parent task proxy as when that task is started or finished the
214
			//proxy is not yet available or is nulled out
215
			Task parentTask = (Task) getTasks().peek();
216
			Object proxy = parentTask.getRuntimeConfigurableWrapper().getProxy();
217
			if (proxy != null) {
218
				fTaskToProxies.put(parentTask, proxy);
219
			}
220
		}
221
		getTasks().push(getCurrentTask());
222
		waitIfSuspended();
223
	}
224
	
225
226
    public void taskFinished() {
227
    	Task lastTask= (Task)getTasks().pop();
228
        setLastTaskFinished(lastTask);
229
        setCurrentTask(null);
230
        String taskName= lastTask.getTaskName();
231
       
232
        if (getStepOverTask() != null) {
233
        	if ((fgAntCallTaskName.equals(taskName) || fgAntTaskName.equals(taskName)) && (!fgAntCallTaskName.equals(getStepOverTask().getTaskName()) && !fgAntTaskName.equals(getStepOverTask().getTaskName()))) {
234
        		setShouldSuspend(true);
235
        	} else if (fTaskToProxies.remove(lastTask) instanceof MacroInstance) {
236
        		setShouldSuspend(true);
237
        	}
238
        }
239
        waitIfSuspended();
240
    }
241
242
    public void stepOver() {
243
       setStepOverTask(getCurrentTask());
244
        if (getCurrentTask() == null) {
245
            //stepping over target breakpoint
246
           setShouldSuspend(true);
247
        }
248
        resume();
249
    }
250
251
    public void targetStarted(BuildEvent event) {
252
		setAfterTaskEvent(false);
253
        Project eventProject = event.getProject();
254
        if (getInitialProperties() == null) {
255
            fInitialProperties= eventProject.getProperties();
256
        }
257
        if (fProjectToTargetNames.get(eventProject) == null) {
258
            Object ref= eventProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
259
            if (ref != null) {
260
                fProjectToTargetNames.put(eventProject, ref);
261
                Map targetToBuildSequence= new HashMap();
262
                setTargetToExecute(initializeBuildSequenceInformation(event, targetToBuildSequence));
263
                fProjectToMapOfTargetToBuildSequence.put(eventProject, targetToBuildSequence);
264
            }
265
        }
266
        
267
        setTargetExecuting(event.getTarget());
268
        if (event.getTarget().equals(getTargetToExecute())) {
269
            //the dependencies of the target to execute have been met
270
            //prepare for the next target
271
            Vector targets= (Vector) fProjectToTargetNames.get(eventProject);
272
            if (!targets.isEmpty()) {
273
                setTargetToExecute((Target) eventProject.getTargets().get(targets.remove(0)));
274
            } else {
275
                setTargetToExecute(null);
276
            }
277
        }
278
        setConsiderTargetBreakpoints(true);
279
    }
280
281
	public int getLineNumber(Location location) {
282
	    try { //succeeds with Ant newer than 1.6
283
	        return location.getLineNumber();
284
	    } catch (NoSuchMethodError e) {
285
	        //Ant before 1.6
286
	        String locationString= location.toString();
287
	        if (locationString.length() == 0) {
288
	            return 0;
289
	        }
290
	        //filename: lineNumber: ("c:\buildfile.xml: 12: ")
291
	        int lastIndex= locationString.lastIndexOf(':');
292
	        int index =locationString.lastIndexOf(':', lastIndex - 1);
293
	        if (index != -1) {
294
	            try {
295
	                return Integer.parseInt(locationString.substring(index+1, lastIndex));
296
	            } catch (NumberFormatException nfe) {
297
	                return 0;
298
	            }
299
	        }
300
	        return 0;
301
	    }
302
	}
303
304
	public static Location getLocation(Target target) {
305
	    try {//succeeds with Ant newer than 1.6.2
306
	        return target.getLocation();
307
	    } catch (NoSuchMethodError e) {
308
	        return Location.UNKNOWN_LOCATION;
309
	    }
310
	}
311
312
	public String getFileName(Location location) {
313
	    try {//succeeds with Ant newer than 1.6
314
	        return location.getFileName();
315
	    } catch (NoSuchMethodError e) {
316
	        //Ant before 1.6
317
	        String locationString= location.toString();
318
	        if (locationString.length() == 0) {
319
	            return null;
320
	        }
321
	        //filename: lineNumber: ("c:\buildfile.xml: 12: ")          
322
	        int lastIndex= locationString.lastIndexOf(':');
323
	        int index =locationString.lastIndexOf(':', lastIndex-1);
324
	        if (index == -1) {
325
	            index= lastIndex; //only the filename is known
326
	        }
327
	        if (index != -1) {
328
	        //bug 84403
329
	            //if (locationString.startsWith("file:")) {
330
	              //  return FileUtils.newFileUtils().fromURI(locationString);
331
	            //}
332
	            //remove file:
333
	            return locationString.substring(5, index);
334
	        }
335
	        return null;
336
	    }
337
	}
338
339
	private void appendToStack(StringBuffer stackRepresentation, String targetName, String taskName, Location location) {
340
	    stackRepresentation.append(targetName);
341
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
342
	    stackRepresentation.append(taskName);
343
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
344
	    
345
	    stackRepresentation.append(getFileName(location));
346
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
347
	    stackRepresentation.append(getLineNumber(location));
348
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
349
	}
350
351
	public void marshalStack(StringBuffer stackRepresentation) {
352
		Stack tasks= getTasks();
353
		
354
	    stackRepresentation.append(DebugMessageIds.STACK);
355
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
356
	    
357
		Target targetToExecute= getTargetToExecute();
358
		Target targetExecuting= getTargetExecuting();
359
      
360
        Project projectExecuting= null;
361
        if (targetExecuting != null) {
362
            projectExecuting= targetExecuting.getProject();
363
        } else { //no target...must be a task
364
            Task task= (Task) tasks.peek();
365
            projectExecuting= task.getProject();
366
        }
367
        
368
		if (!isAfterTaskEvent()) {
369
			appendToStack(stackRepresentation, targetExecuting.getName(), "", getLocation(targetExecuting)); //$NON-NLS-1$
370
		}
371
		for (int i = tasks.size() - 1; i >= 0 ; i--) {
372
			Task task= (Task) tasks.get(i);
373
            if (task.getProject() == projectExecuting) {
374
                appendToStack(stackRepresentation, task.getOwningTarget().getName(), task.getTaskName(), task.getLocation());
375
            } else {
376
                //sub build target dependencies
377
                String targetName= task.getOwningTarget().getName();
378
                if (targetName != null && targetName.length() != 0) { //skip for implicit target
379
                    Iterator itr= fTargetsToExecute.iterator();
380
                    while (itr.hasNext()) {
381
                        Target target= (Target) itr.next();
382
                        if (target.getProject() != projectExecuting) {
383
                        	targetToExecute= target;
384
                            continue;
385
                        }
386
                        marshalTargetDependancyStack(stackRepresentation, target, targetExecuting);
387
                    }
388
                }
389
                projectExecuting= task.getProject();
390
                targetExecuting= task.getOwningTarget();
391
                appendToStack(stackRepresentation, targetExecuting.getName(), task.getTaskName(), task.getLocation());
392
            }
393
		}
394
395
		//target dependency stack 
396
		marshalTargetDependancyStack(stackRepresentation, targetToExecute, targetExecuting);
397
	}
398
399
    private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Target targetToExecute, Target targetExecuting) {
400
        if (targetToExecute != null) {
401
	     	Vector buildSequence= (Vector) getTargetToBuildSequence(targetToExecute.getProject()).get(targetToExecute);
402
	     	int startIndex= buildSequence.indexOf(targetExecuting) + 1;
403
	     	int dependancyStackDepth= buildSequence.indexOf(targetToExecute);
404
	     	
405
	     	Target stackTarget;
406
	     	for (int i = startIndex; i <= dependancyStackDepth; i++) {
407
	     		stackTarget= (Target) buildSequence.get(i);
408
	            if (stackTarget.dependsOn(targetExecuting.getName())) {
409
	     		    appendToStack(stackRepresentation, stackTarget.getName(), "", getLocation(stackTarget)); //$NON-NLS-1$
410
	            }
411
	     	}
412
	     }
413
    }
414
415
	public void marshallProperties(StringBuffer propertiesRepresentation, boolean escapeLineSep) {
416
		if (getTasks().isEmpty()) {
417
			return;
418
		}
419
	    propertiesRepresentation.append(DebugMessageIds.PROPERTIES);
420
	    propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
421
		
422
		Project project= ((Task)getTasks().peek()).getProject();
423
		Map lastProperties= getProperties(); 
424
		
425
	    Map currentProperties= project.getProperties();
426
	    if (lastProperties != null && currentProperties.size() == lastProperties.size()) {
427
	        //no new properties
428
	        return;
429
	    }
430
	    
431
		Map initialProperties= getInitialProperties();
432
	    Map currentUserProperties= project.getUserProperties();
433
	    Iterator iter= currentProperties.keySet().iterator();
434
	    String propertyName;
435
		String originalPropertyName;
436
	    String propertyValue;
437
	    while (iter.hasNext()) {
438
	        propertyName = (String) iter.next();
439
			originalPropertyName= propertyName;
440
	        if (lastProperties == null || lastProperties.get(propertyName) == null) { //new property
441
				if (escapeLineSep) {
442
					propertyName= escapeLineSeparator(propertyName);
443
				}
444
	            propertiesRepresentation.append(propertyName.length());
445
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
446
	            propertiesRepresentation.append(propertyName);
447
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
448
	            propertyValue= (String) currentProperties.get(originalPropertyName);
449
				if (escapeLineSep) {
450
					propertyValue= escapeLineSeparator(propertyValue);
451
				}
452
	            propertiesRepresentation.append(propertyValue.length());
453
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
454
				propertiesRepresentation.append(propertyValue);
455
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
456
	            propertiesRepresentation.append(getPropertyType(initialProperties, currentUserProperties, originalPropertyName));
457
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
458
	        }
459
	    }
460
	    
461
	    propertiesRepresentation.deleteCharAt(propertiesRepresentation.length() - 1);
462
		fProperties= currentProperties;
463
	}
464
465
	private int getPropertyType(Map initialProperties, Map currentUserProperties, String propertyName) {
466
		if (initialProperties.get(propertyName) != null) { //properties set before the start of the build
467
		    if (currentUserProperties.get(propertyName) == null) {
468
		        return DebugMessageIds.PROPERTY_SYSTEM;
469
		    } 
470
			return DebugMessageIds.PROPERTY_USER;
471
		} else if (currentUserProperties.get(propertyName) == null){
472
		    return DebugMessageIds.PROPERTY_RUNTIME;
473
		} else {
474
		    return DebugMessageIds.PROPERTY_USER;
475
		}
476
	}
477
478
	private String escapeLineSeparator(String stringToEscape) {
479
		if (!(stringToEscape.indexOf('\r') != -1 || stringToEscape.indexOf('\n') != -1 || stringToEscape.indexOf("\\r") != -1 || stringToEscape.indexOf("\\n") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$
480
			return stringToEscape;
481
		}
482
		StringBuffer escapedValue= new StringBuffer(stringToEscape);		
483
		for (int i= 0; i < escapedValue.length(); i++) {
484
			switch (escapedValue.charAt(i)) {
485
			case '\r':
486
				escapedValue.replace(i, i+1, "\\r"); //$NON-NLS-1$
487
				i++;
488
				break;
489
			case '\n':
490
				escapedValue.replace(i, i+1, "\\n"); //$NON-NLS-1$
491
				i++;
492
				break;
493
			case '\\':
494
				if (escapedValue.charAt(i + 1) == 'r' || escapedValue.charAt(i + 1) == 'n') {
495
					escapedValue.replace(i, i+1, "\\\\"); //$NON-NLS-1$
496
					i++;
497
				}
498
				break;
499
			default:
500
				break;
501
			}
502
		}
503
504
		return escapedValue.toString();
505
	}
506
507
	private Target initializeBuildSequenceInformation(BuildEvent event, Map targetToBuildSequence) {
508
	    Project antProject= event.getProject();
509
	    Vector targets= (Vector) antProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
510
        if (targets == null) {
511
            return null;
512
        }
513
	    Iterator itr= targets.iterator();
514
	    Hashtable allTargets= antProject.getTargets();
515
	    String targetName;
516
	    Vector sortedTargets;
517
	    while (itr.hasNext()) {
518
	        targetName= (String) itr.next();
519
	        sortedTargets= antProject.topoSort(targetName, allTargets);
520
	        targetToBuildSequence.put(allTargets.get(targetName), sortedTargets);
521
	    }
522
	    //the target to execute
523
	    return (Target) allTargets.get(targets.remove(0));
524
	}
525
    
526
    public void buildStarted() {
527
        fProjectToTargetNames= new HashMap();
528
        fProjectToMapOfTargetToBuildSequence= new HashMap();
529
    }
530
}
(-)common/org/eclipse/ant/internal/launching/debug/IDebugBuildLogger.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
14
public interface IDebugBuildLogger {
15
16
	/**
17
	 * Requests to suspend the build if the current debug state
18
	 * indicates that suspension is required.
19
	 */
20
    public abstract void waitIfSuspended();
21
}
(-)loggers/META-INF/eclipse.inf (+1 lines)
Added Link Here
1
jarprocessor.exclude.sign=true
(-)loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessBuildLogger.java (+306 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Matt Conway - Patch for Bug 28052
11
 *******************************************************************************/
12
13
package org.eclipse.ant.internal.launching.runtime.logger;
14
15
import java.io.BufferedReader;
16
import java.io.IOException;
17
import java.io.StringReader;
18
19
import org.apache.tools.ant.BuildEvent;
20
import org.apache.tools.ant.Location;
21
import org.apache.tools.ant.Project;
22
import org.apache.tools.ant.Target;
23
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
24
import org.eclipse.ant.internal.launching.AntLaunch;
25
import org.eclipse.ant.internal.launching.AntLaunching;
26
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
27
import org.eclipse.ant.internal.launching.debug.AntDebugState;
28
import org.eclipse.ant.internal.launching.launchConfigurations.AntProcess;
29
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamMonitor;
30
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamsProxy;
31
import org.eclipse.core.runtime.OperationCanceledException;
32
import org.eclipse.debug.core.DebugPlugin;
33
import org.eclipse.debug.core.model.IProcess;
34
import org.eclipse.jface.text.IRegion;
35
import org.eclipse.jface.text.Region;
36
37
public class AntProcessBuildLogger extends NullBuildLogger {
38
39
	private long fStartTime;
40
41
	/**
42
	 * Associated process - discovered as needed to log messages
43
	 */
44
	private AntProcess fProcess = null;
45
	
46
	protected void logMessage(String message, BuildEvent event, int overridePriority) {
47
		int priority= overridePriority;
48
		if (priority == -1) {
49
			priority= event.getPriority();
50
		} 
51
		
52
		if (priority > getMessageOutputLevel()) {
53
			return;
54
		}
55
		AntProcess antProcess = getAntProcess(fProcessId);
56
		if (antProcess == null) {
57
			return;
58
		}
59
		
60
		StringBuffer fullMessage= new StringBuffer();
61
		 if (!loggingToLogFile()) {
62
			fullMessage.append(System.getProperty("line.separator")); //$NON-NLS-1$
63
		}
64
		if (event.getException() == null && event.getTask() != null && !fEmacsMode) {
65
			adornMessage(event, fullMessage);
66
		} else {
67
			fullMessage.append(message);
68
		}
69
		message= fullMessage.toString();
70
		
71
		if (loggingToLogFile()) {
72
			logMessageToLogFile(message, priority);
73
		} else {
74
			AntStreamMonitor monitor = getMonitor(priority);
75
			monitor.append(message);
76
		}
77
	}
78
79
	/**
80
	 * Builds a right justified task prefix for the given build event, placing it
81
	 * in the given string buffer. Creates the hyperlinks for the task prefix. 
82
	 *  
83
	 * @param event build event
84
	 * @param fullMessage buffer to place task prefix in
85
	 */
86
	private void adornMessage(BuildEvent event, StringBuffer fullMessage) {
87
		String name = event.getTask().getTaskName();
88
		if (name == null) {
89
			name = "null"; //$NON-NLS-1$
90
		}
91
		Location location = event.getTask().getLocation();
92
		StringBuffer column= new StringBuffer();
93
		int size = AntLaunching.LEFT_COLUMN_SIZE - (name.length() + 3);
94
		for (int i = 0; i < size; i++) {
95
			column.append(' ');
96
		}
97
		StringBuffer labelBuff= new StringBuffer();
98
		labelBuff.append('[');
99
		labelBuff.append(name);
100
		labelBuff.append("] "); //$NON-NLS-1$
101
		
102
		int offset = Math.max(size, 0) + 1;
103
		String label= labelBuff.toString();
104
		if (event.getMessage() == null) {
105
			return;
106
		}
107
		try {
108
			BufferedReader r = new BufferedReader(new StringReader(event.getMessage()));
109
			String line = r.readLine();
110
			fullMessage.append(column);
111
			appendAndLink(fullMessage, location, label, offset, line);
112
			line = r.readLine();
113
			while (line != null) {
114
				fullMessage.append(System.getProperty("line.separator")); //$NON-NLS-1$
115
				fullMessage.append(column);
116
				appendAndLink(fullMessage, location, label, offset, line);
117
				line = r.readLine();
118
			}
119
		} catch (IOException e) {
120
			if (event.getMessage() != null) {
121
				fullMessage.append(label).append(event.getMessage());
122
			}
123
		}
124
	}
125
	
126
	private void appendAndLink(StringBuffer fullMessage, Location location, String label, int offset, String line) {
127
		fullMessage.append(label);
128
		fullMessage.append(line);
129
		if (location != null) {
130
			String newLine= (label + line).trim();
131
			IRegion region= new Region(offset, label.length() - 3); // only
132
			// want
133
			// the
134
			// name
135
			// length
136
			// "[name] "
137
			AntProcess antProcess = getAntProcess(fProcessId);
138
			AntLaunch antLaunch = (AntLaunch)antProcess.getLaunch();
139
			antLaunch.addLinkDescriptor(newLine, location.getFileName(), location.getLineNumber(), region.getOffset(), region.getLength());
140
		}
141
	}
142
143
	private AntStreamMonitor getMonitor(int priority) {
144
		AntStreamsProxy proxy = (AntStreamsProxy)fProcess.getStreamsProxy();
145
		AntStreamMonitor monitor = null;
146
		switch (priority) {
147
			case Project.MSG_INFO:
148
				monitor = (AntStreamMonitor)proxy.getOutputStreamMonitor();
149
				break;
150
			case Project.MSG_ERR:
151
				monitor = (AntStreamMonitor)proxy.getErrorStreamMonitor();
152
				break;
153
			case Project.MSG_DEBUG:
154
				monitor = (AntStreamMonitor)proxy.getDebugStreamMonitor();
155
				break;
156
			case Project.MSG_WARN:
157
				monitor = (AntStreamMonitor)proxy.getWarningStreamMonitor();
158
				break;
159
			case Project.MSG_VERBOSE:
160
				monitor = (AntStreamMonitor)proxy.getVerboseStreamMonitor();
161
				break;
162
		}
163
		return monitor;
164
	}
165
166
	private void logMessageToLogFile(String message, int priority) {
167
		if (priority == Project.MSG_ERR) {
168
			getErrorPrintStream().println(message);
169
		} else {
170
			getOutputPrintStream().println(message);
171
		}
172
	}
173
	
174
	/**
175
	 * Returns the associated Ant process, finding it if necessary, if not
176
	 * already found.
177
	 */
178
	protected AntProcess getAntProcess(String processId) {
179
		if (fProcess == null && processId != null) {
180
			IProcess[] all = DebugPlugin.getDefault().getLaunchManager().getProcesses();
181
			for (int i = 0; i < all.length; i++) {
182
				IProcess process = all[i];
183
				if (process instanceof AntProcess && processId.equals(process.getAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID))) {
184
					fProcess = (AntProcess)process;
185
					break;
186
				}
187
			}
188
		}
189
		return fProcess;
190
	}
191
192
	/* (non-Javadoc)
193
	 * Set the start time.
194
	 * 
195
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
196
	 */
197
	public void buildStarted(BuildEvent event) {
198
		fStartTime= System.currentTimeMillis();
199
	}
200
	
201
	/* (non-Javadoc)
202
	 * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
203
	 */
204
	public void buildFinished(BuildEvent event) {
205
        String message= handleException(event);
206
        if (message != null) {
207
        	try {
208
    			BufferedReader r = new BufferedReader(new StringReader(message));
209
    			String line = r.readLine();
210
    			logMessage(line, event, Project.MSG_ERR);
211
    			line = r.readLine();
212
    			AntProcess antProcess = getAntProcess(fProcessId);
213
    			while (line != null) {
214
    				logMessage(line, event, Project.MSG_ERR);
215
    				if (!message.startsWith("Total time:")) { //$NON-NLS-1$
216
						AntLaunchingUtil.linkBuildFailedMessage(line, antProcess);
217
    				}
218
    				line = r.readLine();
219
    			}
220
    			logMessage("", event, Project.MSG_ERR); //$NON-NLS-1$
221
    		} catch (IOException e) {
222
    		}
223
        }
224
		fHandledException= null;
225
		if (!(event.getException() instanceof OperationCanceledException)) {
226
			logMessage(getTimeString(System.currentTimeMillis() - fStartTime), event, fMessageOutputLevel);
227
		}
228
		fProcess= null;
229
		event.getProject().removeBuildListener(this);
230
	}
231
	
232
	private String getTimeString(long milliseconds) {
233
			long seconds = milliseconds / 1000;
234
			long minutes = seconds / 60;
235
			seconds= seconds % 60;
236
		
237
			StringBuffer result= new StringBuffer(RuntimeMessages.AntProcessBuildLogger_Total_time);
238
			if (minutes > 0) {
239
				result.append(minutes);
240
				if (minutes > 1) {
241
					result.append(RuntimeMessages.AntProcessBuildLogger__minutes_2);
242
				} else {
243
					result.append(RuntimeMessages.AntProcessBuildLogger__minute_3);
244
				}
245
			}
246
			if (seconds > 0) {
247
				if (minutes > 0) {
248
					result.append(' ');
249
				}
250
				result.append(seconds);
251
			
252
				if (seconds > 1) {
253
					result.append(RuntimeMessages.AntProcessBuildLogger__seconds_4);
254
				} else {
255
					result.append(RuntimeMessages.AntProcessBuildLogger__second_5);
256
				} 
257
			}
258
			if (seconds == 0 && minutes == 0) {
259
				result.append(milliseconds);
260
				result.append(RuntimeMessages.AntProcessBuildLogger__milliseconds_6);
261
			}
262
			
263
			result.append(System.getProperty("line.separator")); //$NON-NLS-1$
264
			return result.toString();
265
		}
266
	
267
	/* (non-Javadoc)
268
	 * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
269
	 */
270
	public void messageLogged(BuildEvent event) {
271
		if (event.getPriority() > getMessageOutputLevel()) {
272
			return;
273
		}
274
		if (event.getMessage() != null && event.getMessage().length() > 0) {
275
			logMessage(event.getMessage(), event, -1);
276
		}
277
	}
278
279
	/* (non-Javadoc)
280
	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
281
	 */
282
	public void targetStarted(BuildEvent event) {
283
		if (Project.MSG_INFO > getMessageOutputLevel()) {
284
			return;
285
		}
286
		Target target= event.getTarget();
287
		StringBuffer msg= new StringBuffer(System.getProperty("line.separator")); //$NON-NLS-1$
288
		String targetName= target.getName();
289
		msg.append(targetName);
290
		msg.append(':');
291
		String message= msg.toString();
292
		Location location= AntDebugState.getLocation(target);
293
		if (location != null && location != Location.UNKNOWN_LOCATION) {
294
			IRegion region = new Region(0, targetName.length());
295
			AntProcess antProcess = getAntProcess(fProcessId);
296
			AntLaunch antLaunch = (AntLaunch)antProcess.getLaunch();
297
			antLaunch.addLinkDescriptor(message, location.getFileName(), location.getLineNumber(), region.getOffset(), region.getLength());
298
		}
299
		logMessage(message, event, Project.MSG_INFO);
300
	}
301
	
302
	private boolean loggingToLogFile() {
303
		//check if user has designated to log to a log file
304
		return getErrorPrintStream() != null && getErrorPrintStream() != System.err;
305
	}
306
}
(-)loggers/org/eclipse/ant/internal/launching/runtime/logger/AntProcessDebugBuildLogger.java (+246 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.runtime.logger;
12
13
import java.io.File;
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.apache.tools.ant.BuildEvent;
18
import org.apache.tools.ant.Location;
19
import org.eclipse.ant.internal.launching.debug.AntDebugState;
20
import org.eclipse.ant.internal.launching.debug.IAntDebugController;
21
import org.eclipse.ant.internal.launching.debug.IDebugBuildLogger;
22
import org.eclipse.ant.internal.launching.debug.model.AntDebugTarget;
23
import org.eclipse.ant.internal.launching.debug.model.AntThread;
24
import org.eclipse.ant.internal.launching.launchConfigurations.AntProcess;
25
import org.eclipse.core.resources.IFile;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.OperationCanceledException;
28
import org.eclipse.debug.core.DebugEvent;
29
import org.eclipse.debug.core.ILaunch;
30
import org.eclipse.debug.core.model.IBreakpoint;
31
import org.eclipse.debug.core.model.ILineBreakpoint;
32
import org.eclipse.debug.core.model.IProcess;
33
34
public class AntProcessDebugBuildLogger extends AntProcessBuildLogger implements IAntDebugController, IDebugBuildLogger {
35
	
36
	private AntDebugState fDebugState= null;
37
	
38
	private List fBreakpoints= null;
39
    
40
	private AntDebugTarget fAntDebugTarget;
41
	private boolean fResumed= false;
42
	
43
	/* (non-Javadoc)
44
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
45
	 */
46
	public void buildStarted(BuildEvent event) {
47
		fDebugState= new AntDebugState(this);
48
		super.buildStarted(event);
49
		IProcess process= getAntProcess(fProcessId);
50
		ILaunch launch= process.getLaunch();
51
		fAntDebugTarget= new AntDebugTarget(launch, process, this);
52
		launch.addDebugTarget(fAntDebugTarget);
53
        
54
        fAntDebugTarget.buildStarted();
55
        fDebugState.buildStarted();
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
60
	 */
61
	public void taskFinished(BuildEvent event) {
62
		super.taskFinished(event);
63
		fDebugState.taskFinished();
64
	}
65
	
66
	/* (non-Javadoc)
67
	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
68
	 */
69
	public void taskStarted(BuildEvent event) {
70
        super.taskStarted(event);
71
		fDebugState.taskStarted(event);
72
	}
73
	
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.util.IDebugBuildLogger#waitIfSuspended()
76
	 */
77
	public synchronized void waitIfSuspended() {
78
		fResumed= false;
79
		IBreakpoint breakpoint= breakpointAtLineNumber(fDebugState.getBreakpointLocation());
80
		if (breakpoint != null) {
81
			 fAntDebugTarget.breakpointHit(breakpoint);
82
			 try {
83
				 while (!fResumed) {
84
					 wait(500);
85
					 checkCancelled();
86
				 }
87
			 } catch (InterruptedException e) {
88
			 }
89
		} else if (fDebugState.getCurrentTask() != null) {
90
			int detail= -1;
91
	        boolean shouldSuspend= true;
92
	        if (fDebugState.isStepIntoSuspend()) {
93
	            detail= DebugEvent.STEP_END;
94
	            fDebugState.setStepIntoSuspend(false);               
95
	        } else if ((fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fDebugState.getStepOverTask()) || fDebugState.shouldSuspend()) {
96
				detail= DebugEvent.STEP_END;
97
				fDebugState.setShouldSuspend(false);
98
				fDebugState.setStepOverTask(null);
99
	        } else if (fDebugState.isClientSuspend()) {
100
	            detail= DebugEvent.CLIENT_REQUEST;
101
	            fDebugState.setClientSuspend(false);
102
	        } else {
103
	            shouldSuspend= false;
104
	        }
105
	        if (shouldSuspend) {
106
                fAntDebugTarget.suspended(detail);
107
	            try {
108
	            	while (!fResumed) {
109
	            		wait(500);
110
	            		checkCancelled();
111
	            	}
112
	            } catch (InterruptedException e) {
113
	            }
114
	        }
115
	    }
116
	}
117
118
	private void checkCancelled() {
119
		AntProcess process= getAntProcess(fProcessId);
120
		if (process != null && process.isCanceled()) {
121
			throw new OperationCanceledException(RuntimeMessages.AntProcessDebugBuildLogger_1);
122
		}
123
	}
124
125
	/* (non-Javadoc)
126
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#resume()
127
	 */
128
	public synchronized void resume() {
129
		fResumed= true;
130
        notifyAll();
131
	}
132
133
	/* (non-Javadoc)
134
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#suspend()
135
	 */
136
	public synchronized void suspend() {
137
		fDebugState.setClientSuspend(true);
138
	}
139
140
	/* (non-Javadoc)
141
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepInto()
142
	 */
143
	public synchronized void stepInto() {
144
		fDebugState.setStepIntoSuspend(true);
145
		fResumed= true;
146
		notifyAll();
147
	}
148
149
	/* (non-Javadoc)
150
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepOver()
151
	 */
152
	public synchronized void stepOver() {
153
		fResumed= true;
154
		fDebugState.stepOver();
155
	}
156
157
	/* (non-Javadoc)
158
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#handleBreakpoint(org.eclipse.debug.core.model.IBreakpoint, boolean)
159
	 */
160
	public void handleBreakpoint(IBreakpoint breakpoint, boolean added) {
161
		if (added) {
162
			if (fBreakpoints == null) {
163
				fBreakpoints= new ArrayList();
164
			}
165
			if (!fBreakpoints.contains(breakpoint)) {
166
				fBreakpoints.add(breakpoint);
167
			}
168
		} else {
169
			if (fBreakpoints != null) {
170
				fBreakpoints.remove(breakpoint);
171
			}
172
		}
173
	}
174
175
	/* (non-Javadoc)
176
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getProperties()
177
	 */
178
	public void getProperties() {
179
		if (!fAntDebugTarget.isSuspended()) {
180
			return;
181
		}
182
	    StringBuffer propertiesRepresentation= new StringBuffer();
183
		fDebugState.marshallProperties(propertiesRepresentation, false);
184
		if (fAntDebugTarget.getThreads().length > 0) {
185
			((AntThread) fAntDebugTarget.getThreads()[0]).newProperties(propertiesRepresentation.toString());
186
		}
187
	}
188
189
	/* (non-Javadoc)
190
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getStackFrames()
191
	 */
192
	public void getStackFrames() {
193
		StringBuffer stackRepresentation= new StringBuffer();
194
		fDebugState.marshalStack(stackRepresentation);
195
		((AntThread) fAntDebugTarget.getThreads()[0]).buildStack(stackRepresentation.toString());
196
	}
197
    
198
    private IBreakpoint breakpointAtLineNumber(Location location) {
199
        if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
200
            return null;
201
        }
202
        int lineNumber= fDebugState.getLineNumber(location);
203
        File locationFile= new File(fDebugState.getFileName(location));
204
        for (int i = 0; i < fBreakpoints.size(); i++) {
205
            ILineBreakpoint breakpoint = (ILineBreakpoint) fBreakpoints.get(i);
206
            int breakpointLineNumber;
207
            try {
208
            	if (!breakpoint.isEnabled()) {
209
                	continue;
210
                }
211
            	breakpointLineNumber = breakpoint.getLineNumber();
212
            } catch (CoreException e) {
213
               return null;
214
            }
215
            IFile resource= (IFile) breakpoint.getMarker().getResource();
216
            if (breakpointLineNumber == lineNumber && resource.getLocation().toFile().equals(locationFile)) {
217
                return breakpoint;
218
            }
219
        }
220
        return null;
221
    }
222
    
223
    /* (non-Javadoc)
224
     * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
225
     */
226
    public void targetStarted(BuildEvent event) {
227
		fDebugState.targetStarted(event);
228
		waitIfSuspended();
229
		super.targetStarted(event);
230
    }
231
	
232
	/* (non-Javadoc)
233
	 * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
234
	 */
235
	public void targetFinished(BuildEvent event) {
236
		super.targetFinished(event);
237
		fDebugState.setTargetExecuting(null);
238
	}
239
240
	/* (non-Javadoc)
241
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#unescapeString(java.lang.StringBuffer)
242
	 */
243
	public StringBuffer unescapeString(StringBuffer propertyValue) {
244
		return propertyValue;
245
	}
246
}
(-)loggers/org/eclipse/ant/internal/launching/runtime/logger/NullBuildLogger.java (+179 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.runtime.logger;
12
13
14
import java.io.PrintStream;
15
16
import org.apache.tools.ant.BuildEvent;
17
import org.apache.tools.ant.BuildException;
18
import org.apache.tools.ant.BuildLogger;
19
import org.apache.tools.ant.Project;
20
import org.apache.tools.ant.util.StringUtils;
21
import org.eclipse.ant.core.AntSecurityException;
22
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
23
import org.eclipse.core.runtime.OperationCanceledException;
24
25
public class NullBuildLogger extends AbstractEclipseBuildLogger implements BuildLogger{
26
27
	protected int fMessageOutputLevel = Project.MSG_INFO;
28
	private PrintStream fErr= null;
29
	private PrintStream fOut= null;
30
	protected boolean fEmacsMode= false;
31
	
32
	/**
33
	 * An exception that has already been logged.
34
	 */
35
	protected Throwable fHandledException= null;
36
	
37
	/**
38
	 * @see org.apache.tools.ant.BuildLogger#setMessageOutputLevel(int)
39
	 */
40
	public void setMessageOutputLevel(int level) {
41
		fMessageOutputLevel= level;
42
	}
43
	
44
	protected int getMessageOutputLevel() {
45
		return fMessageOutputLevel;
46
	}
47
48
	/**
49
	 * @see org.apache.tools.ant.BuildLogger#setEmacsMode(boolean)
50
	 */
51
	public void setEmacsMode(boolean emacsMode) {
52
		fEmacsMode= emacsMode;
53
	}
54
55
	/**
56
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
57
	 */
58
	public void buildStarted(BuildEvent event) {
59
	}
60
61
	/**
62
	 * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
63
	 */
64
	public void buildFinished(BuildEvent event) {
65
		String message= handleException(event);
66
        if (message != null) {
67
            logMessage(message, getMessageOutputLevel());
68
        }
69
		fHandledException= null;
70
	}
71
72
	/**
73
	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
74
	 */
75
	public void targetStarted(BuildEvent event) {
76
	}
77
78
	/**
79
	 * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
80
	 */
81
	public void targetFinished(BuildEvent event) {
82
	}
83
84
	/**
85
	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
86
	 */
87
	public void taskStarted(BuildEvent event) {
88
	}
89
90
	/**
91
	 * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
92
	 */
93
	public void taskFinished(BuildEvent event) {
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
98
	 */
99
	public void messageLogged(BuildEvent event) {
100
		logMessage(event.getMessage(), event.getPriority());
101
	}
102
103
	protected PrintStream getErrorPrintStream() {
104
		return fErr;
105
	}
106
	
107
	protected PrintStream getOutputPrintStream() {
108
		return fOut;
109
	}
110
	
111
	/**
112
	 * @see org.apache.tools.ant.BuildLogger#setErrorPrintStream(java.io.PrintStream)
113
	 */
114
	public void setErrorPrintStream(PrintStream err) {
115
		//this build logger logs to "null" unless
116
		//the user has explicitly set a logfile to use
117
		if (err == System.err) {
118
			fErr= null;
119
		} else {
120
			fErr= err;
121
		}
122
	}
123
124
	/**
125
	 * @see org.apache.tools.ant.BuildLogger#setOutputPrintStream(java.io.PrintStream)
126
	 */
127
	public void setOutputPrintStream(PrintStream output) {
128
		//this build logger logs to "null" unless
129
		//the user has explicitly set a logfile to use
130
		if (output == System.out) {
131
			fOut= null;
132
		} else {
133
			fOut= output;
134
		}
135
	}
136
	
137
	protected void logMessage(String message, int priority) {
138
		if (priority > getMessageOutputLevel()) {
139
			return;
140
		}
141
		
142
		if (priority == Project.MSG_ERR) {
143
			if (getErrorPrintStream() != null && getErrorPrintStream() != System.err) {
144
				//user has designated to log to a logfile
145
				getErrorPrintStream().println(message);
146
			}
147
		} else {
148
			if (getOutputPrintStream() != null && getOutputPrintStream() != System.out) {
149
				//user has designated to log to a logfile
150
				getOutputPrintStream().println(message);
151
			} 
152
		}
153
	}
154
	
155
	protected String handleException(BuildEvent event) {
156
		Throwable exception = event.getException();
157
		if (exception == null || exception == fHandledException
158
		|| exception instanceof OperationCanceledException
159
		|| exception instanceof AntSecurityException) {
160
			return null;
161
		}
162
		fHandledException= exception;
163
        StringBuffer message= new StringBuffer();
164
        message.append(StringUtils.LINE_SEP);
165
        message.append(RuntimeMessages.NullBuildLogger_1);
166
        message.append(StringUtils.LINE_SEP);
167
        if (Project.MSG_VERBOSE <= fMessageOutputLevel || !(exception instanceof BuildException)) {
168
            message.append(StringUtils.getStackTrace(exception));
169
        } else {
170
            if (exception instanceof BuildException) {
171
                message.append(exception.toString()).append(StringUtils.LINE_SEP);
172
            } else {
173
                message.append(exception.getMessage()).append(StringUtils.LINE_SEP);
174
            }
175
        }
176
        
177
		return message.toString();	
178
	}
179
}
(-)loggers/org/eclipse/ant/internal/launching/runtime/logger/RuntimeMessages.java (+31 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching.runtime.logger;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class RuntimeMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.runtime.logger.RuntimeMessages";//$NON-NLS-1$
16
17
	public static String NullBuildLogger_1;
18
	public static String AntProcessBuildLogger_Total_time;
19
	public static String AntProcessBuildLogger__minutes_2;
20
	public static String AntProcessBuildLogger__minute_3;
21
	public static String AntProcessBuildLogger__seconds_4;
22
	public static String AntProcessBuildLogger__second_5;
23
	public static String AntProcessBuildLogger__milliseconds_6;
24
	
25
	public static String AntProcessDebugBuildLogger_1;
26
27
	static {
28
		// load message values from bundle file
29
		NLS.initializeMessages(BUNDLE_NAME, RuntimeMessages.class);
30
	}
31
}
(-)loggers/org/eclipse/ant/internal/launching/runtime/logger/RuntimeMessages.properties (+20 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
NullBuildLogger_1=BUILD FAILED
13
AntProcessBuildLogger_Total_time=Total time: 
14
AntProcessBuildLogger__minutes_2=\ minutes
15
AntProcessBuildLogger__minute_3=\ minute
16
AntProcessBuildLogger__seconds_4=\ seconds
17
AntProcessBuildLogger__second_5=\ second
18
AntProcessBuildLogger__milliseconds_6=\ milliseconds
19
20
AntProcessDebugBuildLogger_1=Build cancelled.
(-)plugin.properties (-1 / +12 lines)
Lines 10-13 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
pluginName=Ant Launching Support
12
pluginName=Ant Launching Support
13
providerName=Eclipse.org
13
providerName=Eclipse.org
14
15
AntBuild = Ant Build
16
AntLaunchDelegate.name=Eclipse Ant Launcher
17
AntLaunchDelegate.description=The Eclipse Ant Launcher supports running and debugging Ant build files.
18
19
AntBuilder.name=Ant Builder
20
AntBuilderLaunchDelegate.name= Eclipse Ant Builder Launcher
21
AntBuilderLaunchDelegate.description=The Eclipse Ant Builder Launcher supports running Ant build files.
22
23
antBreakpointGroupName= Ant Breakpoints
24
AntLineBreakpoint.name = Ant Line Breakpoint
(-)plugin.xml (+92 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.debug.core.launchConfigurationTypes">
6
      <launchConfigurationType
7
            category="org.eclipse.ui.externaltools"
8
            delegate="org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate"
9
            delegateDescription="%AntLaunchDelegate.description"
10
            delegateName="%AntLaunchDelegate.name"
11
            id="org.eclipse.ant.AntLaunchConfigurationType"
12
            migrationDelegate="org.eclipse.ant.internal.launching.launchConfigurations.AntMigrationDelegate"
13
            modes="run, debug"
14
            name="%AntBuild"
15
            sourceLocatorId="org.eclipse.ant.ui.debug.sourceLookupDirector"
16
            sourcePathComputerId="org.eclipse.ant.ui.debug.sourcePathComputer">
17
      </launchConfigurationType>
18
      <launchConfigurationType
19
            category="org.eclipse.ui.externaltools.builder"
20
            delegate="org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate"
21
            delegateDescription="%AntBuilderLaunchDelegate.description"
22
            delegateName="%AntBuilderLaunchDelegate.name"
23
            id="org.eclipse.ant.AntBuilderLaunchConfigurationType"
24
            modes="run"
25
            name="%AntBuilder.name">
26
      </launchConfigurationType>
27
   </extension>
28
   <extension point="org.eclipse.core.runtime.preferences">
29
		<initializer class="org.eclipse.ant.internal.launching.AntLaunchingPreferenceInitializer"/>
30
	</extension>
31
  <extension
32
         point="org.eclipse.jdt.launching.runtimeClasspathEntries">
33
      <runtimeClasspathEntry
34
            class="org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry"
35
            id="org.eclipse.antui.classpathentry.antHome">
36
      </runtimeClasspathEntry>
37
      <runtimeClasspathEntry
38
            class="org.eclipse.ant.internal.launching.launchConfigurations.ContributedClasspathEntriesEntry"
39
            id="org.eclipse.ant.ui.classpathentry.extraClasspathEntries">
40
      </runtimeClasspathEntry>
41
   </extension>
42
   <extension
43
         point="org.eclipse.jdt.launching.classpathProviders">
44
      <classpathProvider
45
            class="org.eclipse.ant.internal.launching.launchConfigurations.AntClasspathProvider"
46
            id="org.eclipse.ant.ui.AntClasspathProvider">
47
      </classpathProvider>
48
   </extension>
49
   <extension
50
         point="org.eclipse.debug.core.processFactories">
51
      <processFactory
52
            class="org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntProcessFactory"
53
            id="org.eclipse.ant.ui.remoteAntProcessFactory">
54
      </processFactory>
55
   </extension>
56
   <extension point="org.eclipse.core.runtime.preferences">
57
		<initializer class="org.eclipse.ant.internal.launching.AntLaunchingPreferenceInitializer"/>
58
	</extension>
59
   <extension
60
         point="org.eclipse.ant.core.extraClasspathEntries">
61
      <extraClasspathEntry
62
            headless="true"
63
            library="lib/loggers.jar">
64
      </extraClasspathEntry>
65
      <extraClasspathEntry
66
            eclipseRuntime="false"
67
            headless="true"
68
            library="lib/antdebug.jar">
69
      </extraClasspathEntry>
70
      <extraClasspathEntry
71
            eclipseRuntime="false"
72
            headless="true"
73
            library="lib/remote.jar">
74
      </extraClasspathEntry>
75
   </extension>
76
    <extension
77
         point="org.eclipse.debug.core.breakpoints">
78
      <breakpoint
79
            markerType="org.eclipse.ant.ui.antLineBreakpointMarker"
80
            class="org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint"
81
            id="org.eclipse.ant.ui.lineBreakpoint"
82
            name="%antBreakpointGroupName">
83
      </breakpoint>
84
   </extension>
85
   <extension
86
         id="org.eclipse.ant.ui.antLineBreakpointMarker"
87
         name="%AntLineBreakpoint.name"
88
         point="org.eclipse.core.resources.markers">
89
      <super type="org.eclipse.debug.core.lineBreakpointMarker"/>
90
      <persistent value="true"/>
91
   </extension>   
92
</plugin>
(-)remote/META-INF/eclipse.inf (+1 lines)
Added Link Here
1
jarprocessor.exclude.sign=true
(-)remote/org/eclipse/ant/internal/launching/remote/AntSecurityException.java (+23 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
/**
14
 * A security exception that is thrown by the AntSecurityManager if
15
 * an Ant task in some way attempts to halt or exit the Java Virtual Machine.
16
 * 
17
 * @since 2.1
18
 */
19
public class AntSecurityException extends SecurityException {
20
21
	private static final long serialVersionUID = 1L;
22
23
}
(-)remote/org/eclipse/ant/internal/launching/remote/AntSecurityManager.java (+371 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
14
import java.io.FileDescriptor;
15
import java.net.InetAddress;
16
import java.net.SocketPermission;
17
import java.security.Permission;
18
import java.util.PropertyPermission;
19
20
/**
21
 * A security manager that always throws an <code>AntSecurityException</code>
22
 * if the calling thread attempts to cause the Java Virtual Machine to 
23
 * exit/halt or if the restricted thread attempts to set a System property.
24
 * Otherwise this manager just delegates to the pre-existing manager
25
 * passed in the constructor or mimics the default security manager behavior
26
 */
27
public class AntSecurityManager extends SecurityManager {
28
29
	private SecurityManager fSecurityManager= null;
30
	private Thread fRestrictedThread= null;
31
	//ensure that the PropertyPermission class is loaded before we 
32
	//start checking permissions: bug 85908
33
	private static final PropertyPermission fgPropertyPermission= new PropertyPermission("*", "write"); //$NON-NLS-1$ //$NON-NLS-2$
34
	
35
	private boolean fAllowSettingSystemProperties= true;
36
	
37
	public AntSecurityManager(SecurityManager securityManager, Thread restrictedThread, boolean allowSettingProperties) {
38
		fSecurityManager= securityManager;
39
		fRestrictedThread= restrictedThread;
40
		fAllowSettingSystemProperties= allowSettingProperties;
41
	}
42
	
43
	public AntSecurityManager(SecurityManager securityManager, Thread restrictedThread) {
44
		this(securityManager, restrictedThread, true);
45
	}
46
	
47
	/* (non-Javadoc)
48
	 * @see java.lang.SecurityManager#checkExit(int)
49
	 */
50
	public void checkExit(int status) {
51
		//no exit allowed from the restricted thread...System.exit is being called
52
		//by some ant task...disallow the exit
53
		if (Thread.currentThread() == fRestrictedThread) {
54
			throw new AntSecurityException();
55
		}
56
		if (fSecurityManager != null) {
57
			fSecurityManager.checkExit(status);
58
		}
59
	}
60
	/* (non-Javadoc)
61
	 * @see java.lang.SecurityManager#checkAccept(java.lang.String, int)
62
	 */
63
	public void checkAccept(String host, int port) {
64
		if (fSecurityManager != null) {
65
			fSecurityManager.checkAccept(host, port);
66
		}
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see java.lang.SecurityManager#checkAccess(java.lang.Thread)
71
	 */
72
	public void checkAccess(Thread t) {
73
		if (fSecurityManager != null) {
74
			fSecurityManager.checkAccess(t);
75
		}
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup)
80
	 */
81
	public void checkAccess(ThreadGroup g) {
82
		if (fSecurityManager != null) {
83
			fSecurityManager.checkAccess(g);
84
		}
85
	}
86
87
	/* (non-Javadoc)
88
	 * @see java.lang.SecurityManager#checkAwtEventQueueAccess()
89
	 */
90
	public void checkAwtEventQueueAccess() {
91
		if (fSecurityManager != null) {
92
			fSecurityManager.checkAwtEventQueueAccess();
93
		}
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see java.lang.SecurityManager#checkConnect(java.lang.String, int, java.lang.Object)
98
	 */
99
	public void checkConnect(String host, int port, Object context) {
100
		if (fSecurityManager != null) {
101
			fSecurityManager.checkConnect(host, port, context);
102
		}
103
	}
104
105
	/* (non-Javadoc)
106
	 * @see java.lang.SecurityManager#checkConnect(java.lang.String, int)
107
	 */
108
	public void checkConnect(String host, int port) {
109
		if (fSecurityManager != null) {
110
			fSecurityManager.checkConnect(host, port);
111
		}
112
	}
113
114
	/* (non-Javadoc)
115
	 * @see java.lang.SecurityManager#checkCreateClassLoader()
116
	 */
117
	public void checkCreateClassLoader() {
118
		if (fSecurityManager != null) {
119
			fSecurityManager.checkCreateClassLoader();
120
		}
121
	}
122
123
	/* (non-Javadoc)
124
	 * @see java.lang.SecurityManager#checkDelete(java.lang.String)
125
	 */
126
	public void checkDelete(String file) {
127
		if (fSecurityManager != null) {
128
			fSecurityManager.checkDelete(file);
129
		}
130
	}
131
132
	/* (non-Javadoc)
133
	 * @see java.lang.SecurityManager#checkExec(java.lang.String)
134
	 */
135
	public void checkExec(String cmd) {
136
		if (fSecurityManager != null) {
137
			fSecurityManager.checkExec(cmd);
138
		}
139
	}
140
141
	/* (non-Javadoc)
142
	 * @see java.lang.SecurityManager#checkLink(java.lang.String)
143
	 */
144
	public void checkLink(String lib) {
145
		if (fSecurityManager != null) {
146
			fSecurityManager.checkLink(lib);
147
		}
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see java.lang.SecurityManager#checkListen(int)
152
	 */
153
	public void checkListen(int port) {
154
		if (fSecurityManager != null) {
155
			fSecurityManager.checkListen(port);
156
		}
157
	}
158
159
	/* (non-Javadoc)
160
	 * @see java.lang.SecurityManager#checkMemberAccess(java.lang.Class, int)
161
	 */
162
	public void checkMemberAccess(Class clazz, int which) {
163
		if (fSecurityManager != null) {
164
			fSecurityManager.checkMemberAccess(clazz, which);
165
		}
166
	}
167
168
	/**
169
	 * @see java.lang.SecurityManager#checkMulticast(java.net.InetAddress, byte)
170
	 * @deprecated
171
	 */
172
	public void checkMulticast(InetAddress maddr, byte ttl) {
173
		if (fSecurityManager != null) {
174
			String host = maddr.getHostAddress();
175
			if (!host.startsWith("[") && host.indexOf(':') != -1) { //$NON-NLS-1$
176
	   			host = "[" + host + "]"; //$NON-NLS-1$ //$NON-NLS-2$
177
			}
178
	    	checkPermission(new SocketPermission(host, "accept,connect")); //$NON-NLS-1$
179
		}
180
	}
181
182
	/* (non-Javadoc)
183
	 * @see java.lang.SecurityManager#checkMulticast(java.net.InetAddress)
184
	 */
185
	public void checkMulticast(InetAddress maddr) {
186
		if (fSecurityManager != null) {
187
			fSecurityManager.checkMulticast(maddr);
188
		}
189
	}
190
191
	/* (non-Javadoc)
192
	 * @see java.lang.SecurityManager#checkPackageAccess(java.lang.String)
193
	 */
194
	public void checkPackageAccess(String pkg) {
195
		if (fSecurityManager != null) {
196
			fSecurityManager.checkPackageAccess(pkg);
197
		}
198
	}
199
200
	/* (non-Javadoc)
201
	 * @see java.lang.SecurityManager#checkPackageDefinition(java.lang.String)
202
	 */
203
	public void checkPackageDefinition(String pkg) {
204
		if (fSecurityManager != null) {
205
			fSecurityManager.checkPackageDefinition(pkg);
206
		}
207
	}
208
209
	/* (non-Javadoc)
210
	 * @see java.lang.SecurityManager#checkPermission(java.security.Permission, java.lang.Object)
211
	 */
212
	public void checkPermission(Permission perm, Object context) {
213
		if (fSecurityManager != null) {
214
			fSecurityManager.checkPermission(perm, context);
215
		}
216
	}
217
218
	/* (non-Javadoc)
219
	 * @see java.lang.SecurityManager#checkPermission(java.security.Permission)
220
	 */
221
	public void checkPermission(Permission perm) {
222
		if (!fAllowSettingSystemProperties && fgPropertyPermission.implies(perm) && fRestrictedThread == Thread.currentThread()) {
223
			//attempting to write a system property
224
			throw new AntSecurityException();
225
		}
226
		if (fSecurityManager != null) {
227
			fSecurityManager.checkPermission(perm);
228
		}
229
	}
230
231
	/* (non-Javadoc)
232
	 * @see java.lang.SecurityManager#checkPrintJobAccess()
233
	 */
234
	public void checkPrintJobAccess() {
235
		if (fSecurityManager != null) {
236
			fSecurityManager.checkPrintJobAccess();
237
		}
238
	}
239
240
	/* (non-Javadoc)
241
	 * @see java.lang.SecurityManager#checkPropertiesAccess()
242
	 */
243
	public void checkPropertiesAccess() {
244
		if (fSecurityManager != null) {
245
			fSecurityManager.checkPropertiesAccess();
246
		}
247
		super.checkPropertiesAccess();
248
	}
249
250
	/* (non-Javadoc)
251
	 * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
252
	 */
253
	public void checkPropertyAccess(String key) {
254
		if (fSecurityManager != null) {
255
			fSecurityManager.checkPropertyAccess(key);
256
		}
257
	}
258
259
	/* (non-Javadoc)
260
	 * @see java.lang.SecurityManager#checkRead(java.io.FileDescriptor)
261
	 */
262
	public void checkRead(FileDescriptor fd) {
263
		if (fSecurityManager != null) {
264
			fSecurityManager.checkRead(fd);
265
		}
266
	}
267
268
	/* (non-Javadoc)
269
	 * @see java.lang.SecurityManager#checkRead(java.lang.String, java.lang.Object)
270
	 */
271
	public void checkRead(String file, Object context) {
272
		if (fSecurityManager != null) {
273
			fSecurityManager.checkRead(file, context);
274
		}
275
	}
276
277
	/* (non-Javadoc)
278
	 * @see java.lang.SecurityManager#checkRead(java.lang.String)
279
	 */
280
	public void checkRead(String file) {
281
		if (fSecurityManager != null) {
282
			fSecurityManager.checkRead(file);
283
		}
284
	}
285
286
	/* (non-Javadoc)
287
	 * @see java.lang.SecurityManager#checkSecurityAccess(java.lang.String)
288
	 */
289
	public void checkSecurityAccess(String target) {
290
		if (fSecurityManager != null) {
291
			fSecurityManager.checkSecurityAccess(target);
292
		}
293
	}
294
295
	/* (non-Javadoc)
296
	 * @see java.lang.SecurityManager#checkSetFactory()
297
	 */
298
	public void checkSetFactory() {
299
		if (fSecurityManager != null) {
300
			fSecurityManager.checkSetFactory();
301
		}
302
	}
303
304
	/* (non-Javadoc)
305
	 * @see java.lang.SecurityManager#checkSystemClipboardAccess()
306
	 */
307
	public void checkSystemClipboardAccess() {
308
		if (fSecurityManager != null) {
309
			fSecurityManager.checkSystemClipboardAccess();
310
		}
311
	}
312
313
	/* (non-Javadoc)
314
	 * @see java.lang.SecurityManager#checkTopLevelWindow(java.lang.Object)
315
	 */
316
	public boolean checkTopLevelWindow(Object window) {
317
		if (fSecurityManager != null) {
318
			return fSecurityManager.checkTopLevelWindow(window);
319
		}
320
		return super.checkTopLevelWindow(window);
321
	}
322
323
	/* (non-Javadoc)
324
	 * @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
325
	 */
326
	public void checkWrite(FileDescriptor fd) {
327
		if (fSecurityManager != null) {
328
			fSecurityManager.checkWrite(fd);
329
		}
330
	}
331
332
	/* (non-Javadoc)
333
	 * @see java.lang.SecurityManager#checkWrite(java.lang.String)
334
	 */
335
	public void checkWrite(String file) {
336
		if (fSecurityManager != null) {
337
			fSecurityManager.checkWrite(file);
338
		}
339
	}
340
341
	/**
342
	 * @see java.lang.SecurityManager#getInCheck()
343
	 * @deprecated
344
	 */
345
	public boolean getInCheck() {
346
		if (fSecurityManager != null) {
347
			return fSecurityManager.getInCheck();
348
		}
349
		return super.getInCheck();
350
	}
351
352
	/* (non-Javadoc)
353
	 * @see java.lang.SecurityManager#getSecurityContext()
354
	 */
355
	public Object getSecurityContext() {
356
		if (fSecurityManager != null) {
357
			return fSecurityManager.getSecurityContext();
358
		}
359
		return super.getSecurityContext();
360
	}
361
362
	/* (non-Javadoc)
363
	 * @see java.lang.SecurityManager#getThreadGroup()
364
	 */
365
	public ThreadGroup getThreadGroup() {
366
		if (fSecurityManager != null) {
367
			fSecurityManager.getThreadGroup();
368
		}
369
		return super.getThreadGroup();
370
	}
371
}
(-)remote/org/eclipse/ant/internal/launching/remote/DemuxInputStreamSetter.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
14
import org.apache.tools.ant.DemuxInputStream;
15
import org.apache.tools.ant.Project;
16
17
/**
18
 * This class exists so that the Ant integration has backwards compatibility
19
 * with Ant releases previous to 1.6. DemuxInputStream is a new class to Ant 1.6.
20
 */
21
class DemuxInputStreamSetter {
22
23
	protected void remapSystemIn(Project project) {
24
		System.setIn(new DemuxInputStream(project));
25
	}
26
}
(-)remote/org/eclipse/ant/internal/launching/remote/EclipseDefaultExecutor.java (+41 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
import java.util.Arrays;
14
import java.util.Vector;
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Executor;
18
import org.apache.tools.ant.Project;
19
import org.apache.tools.ant.helper.DefaultExecutor;
20
21
public class EclipseDefaultExecutor extends DefaultExecutor {
22
23
    private static final EclipseSingleCheckExecutor SUB_EXECUTOR = new EclipseSingleCheckExecutor();
24
    
25
    /* (non-Javadoc)
26
     * @see org.apache.tools.ant.Executor#executeTargets(org.apache.tools.ant.Project, java.lang.String[])
27
     */
28
    public void executeTargets(Project project, String[] targetNames) throws BuildException {
29
        Vector v= new Vector();
30
        v.addAll(Arrays.asList(targetNames));
31
        project.addReference("eclipse.ant.targetVector", v); //$NON-NLS-1$
32
        super.executeTargets(project, targetNames);
33
    }
34
    
35
    /* (non-Javadoc)
36
     * @see org.apache.tools.ant.Executor#getSubProjectExecutor()
37
     */
38
    public Executor getSubProjectExecutor() {
39
       return SUB_EXECUTOR;
40
    }
41
}
(-)remote/org/eclipse/ant/internal/launching/remote/EclipseSingleCheckExecutor.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
import java.util.Arrays;
14
import java.util.Vector;
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Executor;
18
import org.apache.tools.ant.Project;
19
import org.apache.tools.ant.helper.SingleCheckExecutor;
20
21
public class EclipseSingleCheckExecutor extends SingleCheckExecutor {
22
23
    /* (non-Javadoc)
24
     * @see org.apache.tools.ant.Executor#executeTargets(org.apache.tools.ant.Project, java.lang.String[])
25
     */
26
    public void executeTargets(Project project, String[] targetNames) throws BuildException {
27
        Vector v= new Vector();
28
        v.addAll(Arrays.asList(targetNames));
29
        project.addReference("eclipse.ant.targetVector", v); //$NON-NLS-1$
30
        super.executeTargets(project, targetNames);
31
    }
32
    
33
    /* (non-Javadoc)
34
     * @see org.apache.tools.ant.Executor#getSubProjectExecutor()
35
     */
36
    public Executor getSubProjectExecutor() {
37
        return this;
38
    }
39
}
(-)remote/org/eclipse/ant/internal/launching/remote/ExecutorSetter.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
import org.apache.tools.ant.Executor;
14
import org.apache.tools.ant.Project;
15
16
/**
17
 * This class exists so that the Ant integration has backwards compatibility
18
 * with Ant releases previous to 1.6.3. Executors are a new feature of Ant 1.6.3.
19
 */
20
public class ExecutorSetter {
21
22
    protected void setExecutor(Project project) {
23
        Executor executor= new EclipseDefaultExecutor();
24
        project.setExecutor(executor);
25
    }
26
}
(-)remote/org/eclipse/ant/internal/launching/remote/InputHandlerSetter.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
14
import java.text.MessageFormat; // can't use ICU, used by ant
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Project;
18
import org.apache.tools.ant.input.DefaultInputHandler;
19
import org.apache.tools.ant.input.InputHandler;
20
21
/**
22
 * This class exists so that the Ant integration has backwards compatibility
23
 * with Ant releases previous to 1.5. InputHandlers are a new feature of Ant 1.5.
24
 */
25
class InputHandlerSetter {
26
27
	protected void setInputHandler(Project project, String inputHandlerClassname) {
28
		InputHandler handler = null;
29
		if (inputHandlerClassname == null) {
30
			handler = new DefaultInputHandler();
31
		} else {
32
			try {
33
				handler = (InputHandler)(Class.forName(inputHandlerClassname).newInstance());
34
			} catch (ClassCastException e) {
35
				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5"), new String[]{inputHandlerClassname}); //$NON-NLS-1$
36
				throw new BuildException(msg, e);
37
			} catch (Exception e) {
38
				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6"), new String[]{inputHandlerClassname, e.getClass().getName()}); //$NON-NLS-1$
39
				throw new BuildException(msg, e);
40
			}
41
		}
42
		project.setInputHandler(handler);
43
	}
44
}
(-)remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java (+1231 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * Portions Copyright  2000-2005 The Apache Software Foundation
4
 * All rights reserved. This program and the accompanying materials are made 
5
 * available under the terms of the Apache Software License v2.0 which 
6
 * accompanies this distribution and is available at 
7
 * http://www.apache.org/licenses/LICENSE-2.0.
8
 * 
9
 * Contributors:
10
 *     IBM Corporation - derived implementation
11
 *******************************************************************************/
12
13
package org.eclipse.ant.internal.launching.remote;
14
15
import java.io.File;
16
import java.io.FileInputStream;
17
import java.io.FileNotFoundException;
18
import java.io.FileOutputStream;
19
import java.io.IOException;
20
import java.io.InputStream;
21
import java.io.PrintStream;
22
import java.text.MessageFormat;
23
import java.util.ArrayList;
24
import java.util.Collections;
25
import java.util.Enumeration;
26
import java.util.HashMap;
27
import java.util.Iterator;
28
import java.util.List;
29
import java.util.Map;
30
import java.util.Properties;
31
import java.util.Vector;
32
33
import org.apache.tools.ant.AntTypeDefinition;
34
import org.apache.tools.ant.BuildEvent;
35
import org.apache.tools.ant.BuildException;
36
import org.apache.tools.ant.BuildListener;
37
import org.apache.tools.ant.BuildLogger;
38
import org.apache.tools.ant.ComponentHelper;
39
import org.apache.tools.ant.DefaultLogger;
40
import org.apache.tools.ant.DemuxOutputStream;
41
import org.apache.tools.ant.Diagnostics;
42
import org.apache.tools.ant.Main;
43
import org.apache.tools.ant.Project;
44
import org.apache.tools.ant.ProjectHelper;
45
import org.apache.tools.ant.Target;
46
import org.apache.tools.ant.Task;
47
import org.apache.tools.ant.TaskAdapter;
48
import org.apache.tools.ant.util.FileUtils;
49
import org.eclipse.ant.internal.launching.remote.logger.RemoteAntBuildLogger;
50
51
/**
52
 * Eclipse application entry point into Ant in a separate VM. Derived from the original Ant Main class
53
 * to ensure that the functionality is equivalent when running in the platform.
54
 */
55
public class InternalAntRunner {
56
57
	/**
58
	 *  Message priority for project help messages. 
59
	 */
60
	public static final int MSG_PROJECT_HELP= Project.MSG_DEBUG + 1;
61
	
62
	private List buildListeners;
63
64
	private String buildFileLocation;
65
66
	/** 
67
	 * Targets we want to run.
68
	 */
69
	private Vector targets;
70
71
	private Map userProperties;
72
	
73
	private Project currentProject;
74
	
75
	private BuildLogger buildLogger= null;
76
	
77
	private Map eclipseSpecifiedTasks;
78
	private Map eclipseSpecifiedTypes;
79
	
80
	/**
81
	 * Cache of the Ant version number when it has been loaded
82
	 */
83
	private String antVersionNumber= null;
84
85
	/** Our current message output status. Follows Project.MSG_XXX */
86
	private int messageOutputLevel = Project.MSG_INFO;
87
88
	/** Indicates whether output to the log is to be unadorned. */
89
	private boolean emacsMode = false;
90
91
	/** Indicates we should only parse and display the project help information */
92
	private boolean projectHelp = false;
93
94
	/** Stream that we are using for logging */
95
	private PrintStream out = System.out;
96
97
	/** Stream that we are using for logging error messages */
98
	private PrintStream err = System.err;
99
100
	/**
101
	 * The Ant logger class. There may be only one logger. It will have the
102
	 * right to use the 'out' PrintStream. The class must implement the BuildLogger
103
	 * interface.  An empty String indicates that no logger is to be used.  A <code>null</code>
104
	 * name indicates that the <code>org.apache.tools.ant.DefaultLogger</code> will be used.
105
	 */
106
	private String loggerClassname = null;
107
108
	/** Extra arguments to be parsed as command line arguments. */
109
	private String[] extraArguments = null;
110
	
111
	private boolean scriptExecuted= false;
112
	
113
	private List propertyFiles= new ArrayList();
114
	
115
	/**
116
     * The Ant InputHandler class. There may be only one input handler.
117
     */
118
    private String inputHandlerClassname = null;
119
    
120
    /** 
121
     * Indicates whether to execute all targets that 
122
     * do not depend on failed targets
123
     * @since Ant 1.6.0
124
     */
125
    private boolean keepGoing= false;
126
127
    /** 
128
     * Indicates whether this build is to support interactive input 
129
     * @since Ant 1.6.0
130
     */
131
    private boolean allowInput = true;
132
    
133
    private String fEarlyErrorMessage= null;
134
    
135
    public static void main(String[] args) {
136
    	try {
137
    		new InternalAntRunner().run(getArrayList(args));
138
    	} catch (Throwable t) {
139
    	    t.printStackTrace();
140
    		System.exit(1);
141
    	}
142
		System.exit(0);
143
	}
144
145
	private void addBuildListeners(Project project) {
146
		String className= null;
147
		try {
148
			BuildLogger logger= createLogger();
149
			if (logger != null) {
150
				project.addBuildListener(logger);
151
			}
152
			if (buildListeners != null) {
153
				for (Iterator iterator = buildListeners.iterator(); iterator.hasNext();) {
154
					className = (String) iterator.next();
155
					Class listener = Class.forName(className);
156
					project.addBuildListener((BuildListener) listener.newInstance());
157
				}
158
			}
159
		} catch (ClassCastException e) {
160
			String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_be_a_build_listener_is_not_an_instance_of_org.apache.tools.ant.BuildListener._1"), new String[]{className}); //$NON-NLS-1$
161
			logMessage(null, message, Project.MSG_ERR);
162
			throw new BuildException(message, e);
163
		} catch (BuildException e) {
164
			throw e;
165
		} catch (Exception e) {
166
			throw new BuildException(e);
167
		}
168
	}
169
170
	/**
171
	 * Parses the build file and adds necessary information into
172
	 * the given project.
173
	 * @param project The project to configure
174
	 */
175
	private void parseBuildFile(Project project) {
176
		File buildFile = new File(getBuildFileLocation());
177
		if (!buildFile.exists()) {
178
			throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Buildfile__{0}_does_not_exist_!_1"), //$NON-NLS-1$
179
						 new String[]{buildFile.getAbsolutePath()}));
180
		}
181
		if (!buildFile.isFile()) {
182
			throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Buildfile__{0}_is_not_a_file_1"), //$NON-NLS-1$
183
							new String[]{buildFile.getAbsolutePath()}));
184
		}
185
		
186
        if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
187
            parseBuildFile(project, buildFile);
188
        } else {
189
            ProjectHelper helper = ProjectHelper.getProjectHelper();
190
            project.addReference("ant.projectHelper", helper); //$NON-NLS-1$
191
            helper.parse(project, buildFile);
192
        }
193
    }
194
    
195
    /**
196
     * @deprecated support for Ant older than 1.5
197
     */
198
    private void parseBuildFile(Project project, File buildFile) {
199
        ProjectHelper.configureProject(project, buildFile);   
200
    }
201
202
	private void printArguments(Project project) {
203
		if ((messageOutputLevel != Project.MSG_DEBUG) && (messageOutputLevel != Project.MSG_VERBOSE)) {
204
			return;
205
		}
206
		StringBuffer sb = new StringBuffer();
207
		for (int i = 0; i < extraArguments.length; i++) {
208
			sb.append(extraArguments[i]);
209
			sb.append(' ');
210
		}
211
		project.log(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Arguments__{0}_2"), new String[]{sb.toString().trim()})); //$NON-NLS-1$
212
	}
213
214
215
	/**
216
	 * Logs a message with the client that lists the targets
217
	 * in a project
218
	 * 
219
	 * @param project the project to list targets from
220
	 */
221
	private void printTargets(Project project) {
222
		//notify the logger that project help message are coming
223
		//since there is no buildstarted or targetstarted to 
224
		//to be used to establish the connection
225
		logMessage(project, "", MSG_PROJECT_HELP); //$NON-NLS-1$
226
		// find the target with the longest name
227
		int maxLength = 0;
228
		Enumeration ptargets = project.getTargets().elements();
229
		String targetName;
230
		String targetDescription;
231
		Target currentTarget;
232
		// split the targets in top-level and sub-targets depending
233
		// on the presence of a description
234
		List topNames = new ArrayList();
235
		List topDescriptions = new ArrayList();
236
		List subNames = new ArrayList();
237
238
		while (ptargets.hasMoreElements()) {
239
			currentTarget = (Target) ptargets.nextElement();
240
			targetName = currentTarget.getName();
241
			targetDescription = currentTarget.getDescription();
242
			if (targetDescription == null) {
243
				subNames.add(targetName);
244
			} else {
245
				topNames.add(targetName);
246
				topDescriptions.add(targetDescription);
247
				if (targetName.length() > maxLength) {
248
					maxLength = targetName.length();
249
				}
250
			}
251
		}
252
253
		Collections.sort(subNames);
254
		Collections.sort(topNames);
255
		Collections.sort(topDescriptions);
256
		
257
		String defaultTargetName = project.getDefaultTarget();
258
		if (defaultTargetName != null && !"".equals(defaultTargetName)) { // shouldn't need to check but... //$NON-NLS-1$
259
			List defaultName = new ArrayList(1);
260
			List defaultDesc = null;
261
			defaultName.add(defaultTargetName);
262
263
			int indexOfDefDesc = topNames.indexOf(defaultTargetName);
264
			if (indexOfDefDesc >= 0) {
265
				defaultDesc = new ArrayList(1);
266
				defaultDesc.add(topDescriptions.get(indexOfDefDesc));
267
			}
268
			printTargets(project, defaultName, defaultDesc, RemoteAntMessages.getString("InternalAntRunner.Default_target__3"), maxLength); //$NON-NLS-1$
269
270
		}
271
272
		printTargets(project, topNames, topDescriptions, RemoteAntMessages.getString("InternalAntRunner.Main_targets__4"), maxLength); //$NON-NLS-1$
273
		printTargets(project, subNames, null, RemoteAntMessages.getString("InternalAntRunner.Subtargets__5"), 0); //$NON-NLS-1$
274
	}
275
276
	/**
277
	 * Logs a message with the client that lists the target names and optional descriptions
278
	 * 
279
	 * @param project the enclosing target
280
	 * @param names the targets names
281
	 * @param descriptions the corresponding descriptions
282
	 * @param heading the message heading
283
	 * @param maxlen maximum length that can be allocated for a name
284
	 */
285
	private void printTargets(Project project, List names, List descriptions, String heading, int maxlen) {
286
		// now, start printing the targets and their descriptions
287
		String lSep = System.getProperty("line.separator"); //$NON-NLS-1$
288
		
289
		String spaces = "    "; //$NON-NLS-1$
290
		while (spaces.length() < maxlen) {
291
			spaces += spaces;
292
		}
293
		StringBuffer msg = new StringBuffer();
294
		msg.append(heading + lSep + lSep);
295
		for (int i = 0; i < names.size(); i++) {
296
			msg.append(' ');
297
			msg.append(names.get(i));
298
			if (descriptions != null) {
299
				msg.append(spaces.substring(0, maxlen - ((String) names.get(i)).length() + 2));
300
				msg.append(descriptions.get(i));
301
			}
302
			msg.append(lSep);
303
		}
304
		logMessage(project, msg.toString(), Project.MSG_INFO);
305
	}
306
307
	/*
308
	 * Note that the list passed to this method must support
309
	 * List#remove(Object)
310
	 */
311
	private void run(List argList) {
312
		setCurrentProject(new Project());
313
         if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$
314
               new ExecutorSetter().setExecutor(getCurrentProject());
315
            }
316
		Throwable error = null;
317
		PrintStream originalErr = System.err;
318
		PrintStream originalOut = System.out;
319
		InputStream originalIn= System.in;
320
		
321
		SecurityManager originalSM= System.getSecurityManager();
322
		scriptExecuted= true;
323
		try {
324
			if (argList != null && (argList.remove("-projecthelp") || argList.remove("-p"))) { //$NON-NLS-1$ //$NON-NLS-2$
325
				projectHelp = true;
326
			}
327
			getCurrentProject().init();
328
			if (argList != null) {
329
				scriptExecuted= preprocessCommandLine(argList);
330
			
331
				if (!scriptExecuted) {
332
					return;
333
				}
334
			}
335
			
336
            boolean exceptionState= processProperties(argList);
337
            
338
			addBuildListeners(getCurrentProject());
339
            
340
			addInputHandler(getCurrentProject());
341
			
342
			remapSystemIn();
343
			System.setOut(new PrintStream(new DemuxOutputStream(getCurrentProject(), false)));
344
			System.setErr(new PrintStream(new DemuxOutputStream(getCurrentProject(), true)));
345
			
346
			if (!projectHelp) {
347
				fireBuildStarted(getCurrentProject());
348
			}
349
            
350
            if (fEarlyErrorMessage != null) {
351
                //an error occurred processing the properties
352
                //build started has fired and we have
353
                //listeners/loggers to report the error
354
                logMessage(getCurrentProject(), fEarlyErrorMessage, Project.MSG_ERR);
355
                if (exceptionState) {
356
                    throw new BuildException(fEarlyErrorMessage);
357
                }
358
            }
359
            
360
            //properties can only be set after buildStarted as some listeners/loggers
361
            //depend on this (e.g. XMLLogger)
362
            setProperties(getCurrentProject());
363
			
364
			if (argList != null && !argList.isEmpty()) {
365
				try {
366
					scriptExecuted= processCommandLine(argList);
367
				} catch (BuildException e) {
368
					scriptExecuted= false;
369
					throw e;
370
				}
371
			}
372
			if (!scriptExecuted) {
373
				return;
374
			}
375
			
376
            //needs to occur after processCommandLine(List)
377
			if (allowInput && (inputHandlerClassname != null && inputHandlerClassname.length() > 0)) {
378
				if (isVersionCompatible("1.6")) { //$NON-NLS-1$
379
					getCurrentProject().setDefaultInputStream(originalIn);
380
				}
381
			} else {
382
				//set the system property that any input handler
383
				//can check to see if handling input is allowed
384
				System.setProperty("eclipse.ant.noInput", "true");  //$NON-NLS-1$//$NON-NLS-2$
385
				if (isVersionCompatible("1.5") && (inputHandlerClassname == null || inputHandlerClassname.length() == 0)) { //$NON-NLS-1$
386
					InputHandlerSetter setter= new InputHandlerSetter();
387
					setter.setInputHandler(getCurrentProject(), "org.eclipse.ant.internal.ui.antsupport.inputhandler.FailInputHandler"); //$NON-NLS-1$
388
				}
389
			}
390
			
391
			getCurrentProject().log(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Build_file__{0}_1"), new String[]{getBuildFileLocation()})); //$NON-NLS-1$
392
			
393
			setTasks();
394
			setTypes();
395
			
396
			if (isVersionCompatible("1.6")) { //$NON-NLS-1$
397
				getCurrentProject().setKeepGoingMode(keepGoing);
398
			}
399
			
400
			parseBuildFile(getCurrentProject());
401
			
402
			if (projectHelp) {
403
				printHelp(getCurrentProject());
404
				scriptExecuted= false;
405
				return;
406
			}
407
			
408
			if (extraArguments != null) {
409
				printArguments(getCurrentProject());
410
			}
411
			
412
			System.setSecurityManager(new AntSecurityManager(originalSM, Thread.currentThread()));
413
			
414
			if (targets == null) {
415
                targets= new Vector(1);
416
            }
417
            if (targets.isEmpty() && getCurrentProject().getDefaultTarget() != null) {
418
                targets.add(getCurrentProject().getDefaultTarget());
419
            }
420
			if (!isVersionCompatible("1.6.3")) {  //$NON-NLS-1$
421
	            getCurrentProject().addReference("eclipse.ant.targetVector", targets); //$NON-NLS-1$
422
			}
423
			getCurrentProject().executeTargets(targets);
424
		} catch (AntSecurityException e) {
425
			//expected
426
		} catch (Throwable e) {
427
			error = e;
428
		} finally {
429
			System.setErr(originalErr);
430
			System.setOut(originalOut);
431
			System.setIn(originalIn);
432
			if (System.getSecurityManager() instanceof AntSecurityManager) {
433
				System.setSecurityManager(originalSM);
434
			}
435
			
436
			if (!projectHelp) {				
437
				fireBuildFinished(getCurrentProject(), error);
438
			}
439
						
440
			//close any user specified build log
441
			if (err != originalErr) {
442
				err.close();
443
			}
444
			if (out != originalOut) {
445
				out.close();
446
			}
447
		}
448
	}
449
	
450
	private void setTasks() {
451
		if (eclipseSpecifiedTasks != null) {
452
			Iterator itr= eclipseSpecifiedTasks.keySet().iterator();
453
			String taskName;
454
			String taskClassName;
455
			while (itr.hasNext()) {
456
				taskName= (String) itr.next();
457
				taskClassName= (String) eclipseSpecifiedTasks.get(taskName);
458
				
459
				if (isVersionCompatible("1.6")) { //$NON-NLS-1$
460
					AntTypeDefinition def= new AntTypeDefinition();
461
					def.setName(taskName);
462
		            def.setClassName(taskClassName);
463
		            def.setClassLoader(this.getClass().getClassLoader());
464
		            def.setAdaptToClass(Task.class);
465
		            def.setAdapterClass(TaskAdapter.class);
466
		            ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def);
467
				} else {
468
					try {
469
						Class taskClass = Class.forName(taskClassName);
470
						getCurrentProject().addTaskDefinition(taskName, taskClass);
471
					} catch (ClassNotFoundException e) {
472
						String message= MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.161"), new String[]{taskClassName, taskName}); //$NON-NLS-1$
473
						getCurrentProject().log(message, Project.MSG_WARN);
474
					}	
475
				}
476
			}
477
		}
478
	}
479
480
	private void setTypes() {
481
		if (eclipseSpecifiedTypes != null) {
482
			Iterator itr= eclipseSpecifiedTypes.keySet().iterator();
483
			String typeName;
484
			String typeClassName;
485
			while (itr.hasNext()) {
486
				typeName = (String) itr.next();
487
				typeClassName= (String) eclipseSpecifiedTypes.get(typeName);
488
				if (isVersionCompatible("1.6")) { //$NON-NLS-1$
489
					AntTypeDefinition def = new AntTypeDefinition();
490
	                def.setName(typeName);
491
	                def.setClassName(typeClassName);
492
	                def.setClassLoader(this.getClass().getClassLoader());
493
	                ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def);
494
				} else {
495
					try {
496
						Class typeClass = Class.forName(typeClassName);
497
						getCurrentProject().addDataTypeDefinition(typeName, typeClass);
498
					} catch (ClassNotFoundException e) {
499
						String message= MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.162"), new String[]{typeClassName, typeName}); //$NON-NLS-1$
500
						getCurrentProject().log(message, Project.MSG_WARN);
501
					}	
502
				}
503
			}
504
		}
505
	}
506
507
	private void remapSystemIn() {
508
		if (!isVersionCompatible("1.6")) { //$NON-NLS-1$
509
			return;
510
		}
511
		DemuxInputStreamSetter setter= new DemuxInputStreamSetter();
512
		setter.remapSystemIn(getCurrentProject());
513
	}
514
	
515
	/**
516
	 * Creates and returns the default build logger for logging build events to the ant log.
517
	 * 
518
	 * @return the default build logger for logging build events to the ant log
519
	 * 			can return <code>null</code> if no logging is to occur
520
	 */
521
	private BuildLogger createLogger() {
522
		if (loggerClassname == null) {
523
			buildLogger= new DefaultLogger();
524
		} else if (!"".equals(loggerClassname)) { //$NON-NLS-1$
525
			try {
526
				buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
527
			} catch (ClassCastException e) {
528
				String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2"), new String[]{loggerClassname}); //$NON-NLS-1$
529
				logMessage(null, message, Project.MSG_ERR);
530
				throw new BuildException(message, e);
531
			} catch (Exception e) {
532
				String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_logger__{0}_6"), new String[]{loggerClassname}); //$NON-NLS-1$
533
				logMessage(null, message, Project.MSG_ERR);
534
				throw new BuildException(message, e);
535
			}
536
		} 
537
		
538
		if (buildLogger != null) {
539
			buildLogger.setMessageOutputLevel(messageOutputLevel);
540
			buildLogger.setOutputPrintStream(out);
541
			buildLogger.setErrorPrintStream(err);
542
			buildLogger.setEmacsMode(emacsMode);
543
            if (buildLogger instanceof RemoteAntBuildLogger) {
544
                ((RemoteAntBuildLogger) buildLogger).configure(userProperties);
545
            }
546
		}
547
548
		return buildLogger;
549
    }
550
    
551
    /**
552
     * Project.fireBuildStarted is protected in Ant earlier than 1.5.*.
553
     * Provides backwards compatibility with old Ant installs.
554
     */
555
    private void fireBuildStarted(Project project) {
556
        if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
557
            BuildEvent event = new BuildEvent(project);
558
            for (Iterator iterator = project.getBuildListeners().iterator(); iterator.hasNext();) {
559
                BuildListener listener = (BuildListener) iterator.next();
560
                listener.buildStarted(event);
561
            }
562
        } else {
563
            project.fireBuildStarted();
564
        }
565
    }
566
567
	private void fireBuildFinished(Project project, Throwable error) {
568
		if (error == null && scriptExecuted) {
569
			logMessage(project, RemoteAntMessages.getString("InternalAntRunner.BUILD_SUCCESSFUL_1"), messageOutputLevel); //$NON-NLS-1$
570
		}
571
        if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
572
            BuildEvent event = new BuildEvent(project);
573
            event.setException(error);
574
            Iterator iter = project.getBuildListeners().iterator();
575
            while (iter.hasNext()) {
576
                BuildListener listener = (BuildListener) iter.next();
577
                listener.buildFinished(event);
578
            }   
579
        } else {
580
            project.fireBuildFinished(error);
581
        }
582
	}
583
584
	private void logMessage(Project project, String message, int priority) {
585
		if (project != null) {
586
			project.log(message, priority);	
587
		} else {
588
			if (buildListeners != null) {
589
				project = new Project();
590
				BuildEvent event = new BuildEvent(project);
591
				event.setMessage(message, priority);
592
				//notify the build listeners that are not registered as
593
				//no project existed
594
				for (Iterator iterator = buildListeners.iterator(); iterator.hasNext();) {
595
					try {
596
						BuildListener listener = (BuildListener) iterator.next();
597
						listener.messageLogged(event);
598
					} catch (ClassCastException e) {
599
						//ignore we could be trying to log that a build listener is the
600
						//wrong type of class
601
					}
602
				}
603
			}
604
		}
605
	}
606
607
	/**
608
	 * Sets the buildFileLocation.
609
	 * 
610
	 * @param buildFileLocation the file system location of the build file
611
	 */
612
	private void setBuildFileLocation(String buildFileLocation) {
613
		this.buildFileLocation = buildFileLocation;
614
		if (getCurrentProject() != null) {
615
			getCurrentProject().setUserProperty("ant.file", buildFileLocation); //$NON-NLS-1$
616
		}
617
	}
618
619
	private String getBuildFileLocation() {
620
		if (buildFileLocation == null) {
621
			buildFileLocation = new File("build.xml").getAbsolutePath(); //$NON-NLS-1$
622
		}
623
		return buildFileLocation;
624
	}
625
626
	/**
627
	 * Sets the message output level. Use -1 for none.
628
	 * @param level The message output level
629
	 */
630
	private void setMessageOutputLevel(int level) {
631
		messageOutputLevel = level;
632
		if (buildLogger != null) {
633
			buildLogger.setMessageOutputLevel(level);
634
		}
635
	}
636
	
637
	/*
638
	 * Returns a String representation of the Ant version number as specified
639
	 * in the version.txt file.
640
	 */
641
	private String getAntVersionNumber() throws BuildException {
642
		if (antVersionNumber == null) {
643
			try {
644
				Properties props = new Properties();
645
				InputStream in = Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); //$NON-NLS-1$
646
				props.load(in);
647
				in.close();
648
				String versionNumber= props.getProperty("VERSION");  //$NON-NLS-1$
649
				antVersionNumber= versionNumber;
650
			} catch (IOException ioe) {
651
				throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._{0}_9"), new String[]{ioe.getMessage()})); //$NON-NLS-1$
652
			} catch (NullPointerException npe) {
653
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._10")); //$NON-NLS-1$
654
			}
655
		}
656
		return antVersionNumber;
657
	}
658
	
659
	/*
660
	 * Returns whether the given version is compatible with the
661
	 * current Ant version. A version is compatible if it is less
662
	 * than or equal to the current version. 
663
	 */
664
	private boolean isVersionCompatible(String comparison) {
665
		String version= getAntVersionNumber();
666
		return version.compareTo(comparison) >= 0;
667
	}
668
	
669
	private boolean preprocessCommandLine(List commands) {
670
		
671
		String arg = getArgument(commands, "-listener"); //$NON-NLS-1$
672
		while (arg != null) {
673
			if (arg.length() == 0) {
674
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_classname_when_using_the_-listener_argument_1")); //$NON-NLS-1$
675
			} 
676
			if (buildListeners == null) {
677
				buildListeners= new ArrayList(1);
678
			}
679
			buildListeners.add(arg);
680
			arg = getArgument(commands, "-listener"); //$NON-NLS-1$
681
		}
682
683
		arg = getArgument(commands, "-logger"); //$NON-NLS-1$
684
		if (arg != null) {
685
			//allow empty string to mean no logger
686
			loggerClassname = arg;
687
		}
688
		arg = getArgument(commands, "-logger"); //$NON-NLS-1$
689
		if (arg != null) {
690
			throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Only_one_logger_class_may_be_specified_1")); //$NON-NLS-1$
691
		}
692
		
693
		arg = getArgument(commands, "-inputhandler"); //$NON-NLS-1$
694
		if (arg != null) {
695
			if (arg.length() == 0) {
696
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_classname_when_using_the_-inputhandler_argument_1")); //$NON-NLS-1$
697
			} 
698
			inputHandlerClassname = arg;
699
		}
700
		arg = getArgument(commands, "-inputhandler"); //$NON-NLS-1$
701
		if (arg != null) {
702
			throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Only_one_input_handler_class_may_be_specified._2")); //$NON-NLS-1$
703
		}
704
		return true;
705
	}
706
	
707
	/*
708
	 * Looks for interesting command line arguments. 
709
	 * Returns whether it is OK to run the script.
710
	 */
711
	private boolean processCommandLine(List commands) {
712
		
713
		if (commands.remove("-help") || commands.remove("-h")) { //$NON-NLS-1$ //$NON-NLS-2$
714
			printUsage();
715
			return false;
716
		}
717
		
718
		if (commands.remove("-version")) { //$NON-NLS-1$
719
			printVersion();
720
			return false;
721
		}
722
		
723
		if (commands.remove("-verbose") || commands.remove("-v")) { //$NON-NLS-1$ //$NON-NLS-2$
724
			printVersion();
725
			setMessageOutputLevel(Project.MSG_VERBOSE);
726
		}
727
		
728
		if (commands.remove("-debug") || commands.remove("-d")) { //$NON-NLS-1$ //$NON-NLS-2$
729
			printVersion();
730
			setMessageOutputLevel(Project.MSG_DEBUG);
731
		}
732
		
733
		if (commands.remove("-quiet") || commands.remove("-q")) { //$NON-NLS-1$ //$NON-NLS-2$
734
			setMessageOutputLevel(Project.MSG_WARN);
735
		}
736
737
		if (commands.remove("-emacs") || commands.remove("-e")) { //$NON-NLS-1$ //$NON-NLS-2$
738
			emacsMode = true;
739
			if (buildLogger != null) {
740
				buildLogger.setEmacsMode(true);
741
			}
742
		}
743
		
744
		if (commands.remove("-diagnostics")) { //$NON-NLS-1$
745
			if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
746
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.The_diagnositics_options_is_an_Ant_1.5.*_feature._Please_update_your_Ant_classpath_to_include_an_Ant_version_greater_than_this._4")); //$NON-NLS-1$
747
			}
748
			try {
749
				Diagnostics.doReport(System.out);
750
			} catch (NullPointerException e) {
751
				logMessage(getCurrentProject(), RemoteAntMessages.getString("InternalAntRunner.ANT_HOME_must_be_set_to_use_Ant_diagnostics_2"), Project.MSG_ERR); //$NON-NLS-1$
752
			}
753
			return false;
754
		}
755
		
756
		String arg = getArgument(commands, "-logfile"); //$NON-NLS-1$
757
		if (arg == null) {
758
			arg = getArgument(commands, "-l"); //$NON-NLS-1$
759
		}
760
		if (arg != null) {
761
			if (arg.length() == 0) {
762
				String message= RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_log_file_when_using_the_-log_argument_3"); //$NON-NLS-1$
763
				logMessage(currentProject, message, Project.MSG_ERR); 
764
				throw new BuildException(message);
765
			} 
766
			try {
767
				createLogFile(arg);
768
			} catch (IOException e) {
769
				// just log message and ignore exception
770
				logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_write_to_the_specified_log_file__{0}._Make_sure_the_path_exists_and_you_have_write_permissions._2"), new String[]{arg}), Project.MSG_ERR); //$NON-NLS-1$
771
				return false;
772
			}
773
		
774
		}
775
		
776
		arg = getArgument(commands, "-buildfile"); //$NON-NLS-1$
777
		if (arg == null) {
778
			arg = getArgument(commands, "-file"); //$NON-NLS-1$
779
			if (arg == null) {
780
				arg = getArgument(commands, "-f"); //$NON-NLS-1$
781
			}
782
		}
783
		
784
		if (arg != null) {
785
			if (arg.length() == 0) {
786
				String message= RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_buildfile_when_using_the_-buildfile_argument_4"); //$NON-NLS-1$
787
				logMessage(currentProject, message, Project.MSG_ERR); 
788
				throw new BuildException(message);
789
			} 
790
			setBuildFileLocation(arg);
791
		}
792
		
793
		if (isVersionCompatible("1.6")) { //$NON-NLS-1$
794
			if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$
795
				keepGoing= true;
796
			}
797
			if (commands.remove("-noinput")) { //$NON-NLS-1$
798
				allowInput= false;
799
			}
800
			arg= getArgument(commands, "-lib"); //$NON-NLS-1$
801
			if (arg != null) {
802
				logMessage(currentProject, RemoteAntMessages.getString("InternalAntRunner.157"), Project.MSG_ERR); //$NON-NLS-1$
803
				return false;
804
			}
805
		}
806
		
807
		arg= getArgument(commands, "-find"); //$NON-NLS-1$
808
		if (arg == null) {
809
			arg= getArgument(commands, "-s"); //$NON-NLS-1$
810
		}
811
		if (arg != null) {
812
			logMessage(currentProject, RemoteAntMessages.getString("InternalAntRunner.-find_not_supported"), Project.MSG_ERR); //$NON-NLS-1$
813
			return false;
814
		}
815
		
816
		processTasksAndTypes(commands);
817
		
818
		if (!commands.isEmpty()) {
819
			processUnrecognizedCommands(commands);
820
		}
821
822
		if (!commands.isEmpty()) {
823
			processTargets(commands);
824
		}
825
		
826
		return true;
827
	}
828
	
829
	private void processTasksAndTypes(List commands) {
830
		String arg = getArgument(commands, "-eclipseTask"); //$NON-NLS-1$
831
		while (arg != null) {
832
			if (eclipseSpecifiedTasks == null) {
833
				eclipseSpecifiedTasks= new HashMap();
834
			}
835
			int index= arg.indexOf(',');
836
			if (index != -1) {
837
				String name= arg.substring(0, index);
838
				String className= arg.substring(index + 1);
839
				eclipseSpecifiedTasks.put(name, className);
840
			}
841
			arg = getArgument(commands, "-eclipseTask"); //$NON-NLS-1$
842
		}
843
		
844
		arg = getArgument(commands, "-eclipseType"); //$NON-NLS-1$
845
		while (arg != null) {
846
			if (eclipseSpecifiedTypes == null) {
847
				eclipseSpecifiedTypes= new HashMap();
848
			}
849
			int index= arg.indexOf(',');
850
			if (index != -1) {	
851
				String name= arg.substring(0, index);
852
				String className= arg.substring(index + 1);
853
				eclipseSpecifiedTypes.put(name, className);
854
			}
855
			arg = getArgument(commands, "-eclipseType"); //$NON-NLS-1$
856
		}
857
	}
858
859
	/*
860
	 * Checks for unrecognized arguments on the command line.
861
	 * Since there is no syntactic way to distingush between
862
	 * ant -foo target1 target2
863
	 * ant -foo fooarg target
864
	 * we remove everything up to the last argument that
865
	 * begins with a '-'.  In the latter case, above, that
866
	 * means that there will be an extra target, 'fooarg',
867
	 * left lying around.
868
	 */
869
	private void processUnrecognizedCommands(List commands) {
870
		int p = -1;
871
872
		// find the last arg that begins with '-'
873
		for (int i = commands.size() - 1; i >= 0; i--) {
874
			if (((String) commands.get(0)).startsWith("-")) { //$NON-NLS-1$
875
				p = i;
876
				break;
877
			}
878
		}
879
		if (p < 0) { return; }
880
881
		// remove everything preceding that last '-arg'
882
		String s = ""; //$NON-NLS-1$
883
		for (int i = 0; i <= p; i++) {
884
			s += " " + ((String) commands.get(0)); //$NON-NLS-1$
885
			commands.remove(0);
886
		}
887
		
888
		// warn of ignored commands
889
		String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unknown_argument__{0}_2"), new Object[]{ s.substring(1) }); //$NON-NLS-1$
890
		logMessage(currentProject, message, Project.MSG_WARN); 
891
	}
892
	
893
894
	/*
895
	 * Checks for targets specified at the command line.
896
	 */
897
	private void processTargets(List commands) {
898
		if (targets == null) {
899
			targets = new Vector(commands.size());
900
		}
901
		for (Iterator iter = commands.iterator(); iter.hasNext();) {
902
			targets.add(iter.next());
903
		}
904
	}
905
906
	/*
907
	 * Creates the log file with the name specified by the user.
908
	 * If the fileName is not absolute, the file will be created in the
909
	 * working directory if specified or in the same directory as the location
910
	 * of the build file.
911
	 */
912
	private void createLogFile(String fileName) throws FileNotFoundException, IOException {
913
		File logFile = getFileRelativeToBaseDir(fileName);
914
		
915
		//this stream is closed in the finally block of run(list)
916
		out = new PrintStream(new FileOutputStream(logFile));
917
		err = out;
918
		logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Using_{0}_file_as_build_log._1"), new String[]{logFile.getCanonicalPath()}), Project.MSG_INFO); //$NON-NLS-1$
919
		if (buildLogger != null) {
920
			buildLogger.setErrorPrintStream(err);
921
			buildLogger.setOutputPrintStream(out);
922
		}
923
	}
924
925
	private File getFileRelativeToBaseDir(String fileName) {
926
		File parentFile= null;
927
		
928
		String base= getCurrentProject().getUserProperty("basedir"); //$NON-NLS-1$
929
		if (base != null) {
930
			parentFile= new File(base);
931
		} else {
932
			//relative to the build file location
933
			parentFile= new File(getBuildFileLocation()).getParentFile();
934
		}
935
		
936
		//remain backwards compatible for older Ant usage
937
		return FileUtils.newFileUtils().resolveFile(parentFile, fileName);
938
	}
939
940
	/*
941
	 * Processes cmd line properties and adds the user properties
942
	 * Any user properties that have been explicitly set are set as well.
943
	 * Ensures that -D properties take precedence.
944
	 */
945
	private boolean processProperties(List commands) {
946
        boolean exceptionToBeThrown= false;
947
		//MULTIPLE property files are allowed
948
		String arg= getArgument(commands, "-propertyfile"); //$NON-NLS-1$
949
		while (arg != null) {
950
			if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
951
				fEarlyErrorMessage= RemoteAntMessages.getString("InternalAntRunner.Specifying_property_files_is_a_Ant_1.5.*_feature._Please_update_your_Ant_classpath._6"); //$NON-NLS-1$
952
				break;
953
			}
954
			if (arg.length() == 0) {
955
                fEarlyErrorMessage= RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_property_filename_when_using_the_-propertyfile_argument_3"); //$NON-NLS-1$
956
                exceptionToBeThrown= true;
957
                break;
958
			} 
959
			
960
			propertyFiles.add(arg);
961
			arg= getArgument(commands, "-propertyfile"); //$NON-NLS-1$
962
		}
963
        
964
        if (propertyFiles != null && !propertyFiles.isEmpty()) {
965
            loadPropertyFiles();
966
        }
967
        
968
        if (commands != null) {
969
            processMinusDProperties(commands);
970
        }
971
        return exceptionToBeThrown;
972
	}
973
974
	private void processMinusDProperties(List commands) {
975
		String[] args = (String[]) commands.toArray(new String[commands.size()]);
976
		for (int i = 0; i < args.length; i++) {
977
			String arg = args[i];
978
			if (arg.startsWith("-D")) { //$NON-NLS-1$
979
				String name = arg.substring(2, arg.length());
980
				String value = null;
981
				int posEq = name.indexOf("="); //$NON-NLS-1$
982
				if (posEq == 0) {
983
					value= name.substring(1);
984
					name= ""; //$NON-NLS-1$
985
				} else if (posEq > 0 && posEq != name.length() - 1) {
986
					value = name.substring(posEq + 1).trim();
987
					name = name.substring(0, posEq);
988
				}
989
				
990
				if (value == null) {
991
					//the user has specified something like "-Debug"
992
					continue;
993
				}
994
				if (userProperties == null) {
995
					userProperties= new HashMap();
996
				}
997
				userProperties.put(name, value);
998
				commands.remove(args[i]);
999
			}
1000
		}
1001
	}
1002
	
1003
	private void setProperties(Project project) {
1004
		setBuiltInProperties(project);
1005
		if (userProperties != null) {
1006
			for (Iterator iterator = userProperties.entrySet().iterator(); iterator.hasNext();) {
1007
				Map.Entry entry = (Map.Entry) iterator.next();
1008
				project.setUserProperty((String) entry.getKey(), (String) entry.getValue());
1009
			}
1010
		} 
1011
	}
1012
1013
	private void setBuiltInProperties(Project project) {
1014
		project.setUserProperty("ant.file", getBuildFileLocation()); //$NON-NLS-1$
1015
		project.setUserProperty("ant.version", Main.getAntVersion()); //$NON-NLS-1$
1016
	}
1017
1018
	/*
1019
	 * Print the project description, if any
1020
	 */
1021
	private void printHelp(Project project) {
1022
		if (project.getDescription() != null) {
1023
			logMessage(project, project.getDescription(), Project.MSG_INFO);
1024
		}
1025
		printTargets(project);
1026
	}
1027
1028
	/*
1029
	 * Logs a message with the client indicating the version of <b>Ant</b> that this class
1030
	 * fronts.
1031
	 */
1032
	private void printVersion() {
1033
		logMessage(getCurrentProject(), Main.getAntVersion(), Project.MSG_INFO);
1034
	}
1035
1036
	/*
1037
	 * Logs a message with the client outlining the usage of <b>Ant</b>.
1038
	 */
1039
	private void printUsage() {
1040
		String lSep = System.getProperty("line.separator"); //$NON-NLS-1$
1041
		StringBuffer msg = new StringBuffer();
1042
		msg.append("ant ["); //$NON-NLS-1$
1043
		msg.append(RemoteAntMessages.getString("InternalAntRunner.options_13")); //$NON-NLS-1$
1044
		msg.append("] ["); //$NON-NLS-1$
1045
		msg.append(RemoteAntMessages.getString("InternalAntRunner.target_15")); //$NON-NLS-1$
1046
		msg.append(" ["); //$NON-NLS-1$
1047
		msg.append(RemoteAntMessages.getString("InternalAntRunner.target_15")); //$NON-NLS-1$
1048
		msg.append("2 ["); //$NON-NLS-1$
1049
		msg.append(RemoteAntMessages.getString("InternalAntRunner.target_15")); //$NON-NLS-1$
1050
		msg.append("3] ...]]"); //$NON-NLS-1$
1051
		msg.append(lSep);
1052
		msg.append(RemoteAntMessages.getString("InternalAntRunner.Options___21")); //$NON-NLS-1$
1053
		msg.append(lSep);
1054
		msg.append("\t-help, -h\t\t\t\t"); //$NON-NLS-1$
1055
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_this_message_23")); //$NON-NLS-1$
1056
		msg.append(lSep);
1057
		msg.append("\t-projecthelp, -p\t\t"); //$NON-NLS-1$
1058
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_project_help_information_25")); //$NON-NLS-1$
1059
		msg.append(lSep);
1060
		msg.append("\t-version\t\t\t\t"); //$NON-NLS-1$
1061
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_the_version_information_and_exit_27")); //$NON-NLS-1$
1062
		msg.append(lSep); 
1063
		msg.append("\t-diagnostics\t\t\t"); //$NON-NLS-1$
1064
		msg.append(RemoteAntMessages.getString("InternalAntRunner.12")); //$NON-NLS-1$
1065
		msg.append(lSep);
1066
		msg.append(RemoteAntMessages.getString("InternalAntRunner.13")); //$NON-NLS-1$
1067
		msg.append(lSep);
1068
		msg.append("\t-quiet, -q\t\t\t"); //$NON-NLS-1$
1069
		msg.append(RemoteAntMessages.getString("InternalAntRunner.be_extra_quiet_29")); //$NON-NLS-1$
1070
		msg.append(lSep);
1071
		msg.append("\t-verbose, -v\t\t\t"); //$NON-NLS-1$
1072
		msg.append(RemoteAntMessages.getString("InternalAntRunner.be_extra_verbose_31")); //$NON-NLS-1$
1073
		msg.append(lSep);
1074
		msg.append("\t-debug, -d\t\t\t"); //$NON-NLS-1$
1075
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_debugging_information_33")); //$NON-NLS-1$
1076
		msg.append(lSep);
1077
		msg.append("\t-emacs, -e\t\t\t"); //$NON-NLS-1$
1078
		msg.append(RemoteAntMessages.getString("InternalAntRunner.produce_logging_information_without_adornments_35")); //$NON-NLS-1$
1079
		msg.append(lSep);
1080
		msg.append("\t-logfile\t<file>\t\t"); //$NON-NLS-1$
1081
		msg.append(RemoteAntMessages.getString("InternalAntRunner.use_given_file_for_log_37")); //$NON-NLS-1$
1082
		msg.append(lSep);
1083
		msg.append("\t\t-l\t<file>"); //$NON-NLS-1$
1084
		msg.append(RemoteAntMessages.getString("InternalAntRunner.1")); //$NON-NLS-1$
1085
		msg.append(lSep);  
1086
		msg.append("\t-logger <classname>\t\t"); //$NON-NLS-1$
1087
		msg.append(RemoteAntMessages.getString("InternalAntRunner.the_class_which_is_to_perform_logging_39")); //$NON-NLS-1$
1088
		msg.append(lSep);  
1089
		msg.append("\t-listener <classname>\t"); //$NON-NLS-1$
1090
		msg.append(RemoteAntMessages.getString("InternalAntRunner.add_an_instance_of_class_as_a_project_listener_41")); //$NON-NLS-1$
1091
		msg.append(lSep);
1092
		msg.append("\t-noinput\t"); //$NON-NLS-1$
1093
		msg.append(RemoteAntMessages.getString("InternalAntRunner.158")); //$NON-NLS-1$
1094
		msg.append(lSep); 
1095
		msg.append("\t-buildfile\t<file>\t"); //$NON-NLS-1$
1096
		msg.append(RemoteAntMessages.getString("InternalAntRunner.use_given_buildfile_43")); //$NON-NLS-1$
1097
		msg.append(lSep); 
1098
		msg.append("\t\t-file\t<file>"); //$NON-NLS-1$
1099
		msg.append(RemoteAntMessages.getString("InternalAntRunner.1")); //$NON-NLS-1$
1100
		msg.append(lSep);
1101
		msg.append("\t\t-f\t\t<file>"); //$NON-NLS-1$
1102
		msg.append(RemoteAntMessages.getString("InternalAntRunner.1")); //$NON-NLS-1$
1103
		msg.append(lSep);
1104
		msg.append("\t-D<property>=<value>\t"); //$NON-NLS-1$
1105
		msg.append(RemoteAntMessages.getString("InternalAntRunner.use_value_for_given_property_45")); //$NON-NLS-1$
1106
		msg.append(lSep);
1107
		msg.append("\t-keep-going, -k"); //$NON-NLS-1$
1108
		msg.append(RemoteAntMessages.getString("InternalAntRunner.159")); //$NON-NLS-1$
1109
		msg.append(lSep);
1110
		msg.append(RemoteAntMessages.getString("InternalAntRunner.160")); //$NON-NLS-1$
1111
		msg.append(lSep); 
1112
		msg.append("\t-propertyfile <name>\t"); //$NON-NLS-1$
1113
		msg.append(RemoteAntMessages.getString("InternalAntRunner.19")); //$NON-NLS-1$
1114
		msg.append(lSep);
1115
		msg.append(RemoteAntMessages.getString("InternalAntRunner.20")); //$NON-NLS-1$
1116
		msg.append(lSep);
1117
		msg.append("\t-inputhandler <class>\t"); //$NON-NLS-1$
1118
		msg.append(RemoteAntMessages.getString("InternalAntRunner.22")); //$NON-NLS-1$
1119
		msg.append(lSep);
1120
1121
		logMessage(getCurrentProject(), msg.toString(), Project.MSG_INFO);
1122
	}
1123
1124
	/*
1125
	 * From a command line list, return the argument for the given parameter.
1126
	 * The parameter and its argument are removed from the list.
1127
	 * 
1128
	 * @return <code>null</code> if the parameter is not found 
1129
	 * 			or an empty String if no arguments are found
1130
	 */
1131
	private String getArgument(List commands, String param) {
1132
		if (commands == null) {
1133
			return null;
1134
		}
1135
		int index = commands.indexOf(param);
1136
		if (index == -1) {
1137
			return null;
1138
		}
1139
		commands.remove(index);
1140
		if (index == commands.size()) {// if this is the last command
1141
			return ""; //$NON-NLS-1$
1142
		}
1143
		
1144
		String command = (String) commands.get(index);
1145
		if (command.startsWith("-")) { //new parameter //$NON-NLS-1$
1146
			return ""; //$NON-NLS-1$
1147
		}
1148
		
1149
		commands.remove(index);
1150
		return command;
1151
	}
1152
1153
	/*
1154
	 * Helper method to ensure an array is converted into an ArrayList.
1155
	 */
1156
	private static ArrayList getArrayList(String[] args) {
1157
		if (args == null) {
1158
			return null;
1159
		}
1160
		// We could be using Arrays.asList() here, but it does not specify
1161
		// what kind of list it will return. We need a list that
1162
		// implements the method List.remove(Object) and ArrayList does.
1163
		ArrayList result = new ArrayList(args.length);
1164
		for (int i = 0; i < args.length; i++) {
1165
			result.add(args[i]);
1166
		}
1167
		return result;
1168
	}
1169
1170
	private Project getCurrentProject() {
1171
		return currentProject;
1172
	}
1173
1174
	private void setCurrentProject(Project currentProject) {
1175
		this.currentProject = currentProject;
1176
	}
1177
	
1178
	/**
1179
	 * Load all properties from the files 
1180
	 * specified by -propertyfile.
1181
	 */
1182
	private void loadPropertyFiles() {
1183
		Iterator itr= propertyFiles.iterator();
1184
        while (itr.hasNext()) {
1185
            String filename= (String) itr.next();
1186
           	File file= getFileRelativeToBaseDir(filename);
1187
            Properties props = new Properties();
1188
            FileInputStream fis = null;
1189
            try {
1190
                fis = new FileInputStream(file);
1191
                props.load(fis);
1192
            } catch (IOException e) {
1193
            	fEarlyErrorMessage= MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_property_file_{0}__{1}_4"), new String[]{filename, e.getMessage()}); //$NON-NLS-1$
1194
            } finally {
1195
                if (fis != null) {
1196
                    try {
1197
                        fis.close();
1198
                    } catch (IOException e){
1199
                    }
1200
                }
1201
            }
1202
1203
            if (userProperties == null) {
1204
            	userProperties= new HashMap();
1205
            }
1206
            Enumeration propertyNames = props.propertyNames();
1207
            while (propertyNames.hasMoreElements()) {
1208
                String name = (String) propertyNames.nextElement();
1209
                //most specific to global
1210
                //do not overwrite specific with a global property
1211
                if (userProperties.get(name) == null) {
1212
            		userProperties.put(name, props.getProperty(name));
1213
                }
1214
            }
1215
        }
1216
	}
1217
	
1218
	/*
1219
     * Creates the InputHandler and adds it to the project.
1220
     *
1221
     * @exception BuildException if a specified InputHandler
1222
     *                           implementation could not be loaded.
1223
     */
1224
    private void addInputHandler(Project project) {
1225
    	if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
1226
			return;
1227
		}
1228
		InputHandlerSetter setter= new InputHandlerSetter();
1229
		setter.setInputHandler(project, inputHandlerClassname);
1230
    }
1231
}
(-)remote/org/eclipse/ant/internal/launching/remote/RemoteAntMessages.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote;
12
13
14
import java.util.MissingResourceException;
15
import java.util.ResourceBundle;
16
17
public class RemoteAntMessages {
18
19
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.remote.RemoteAntMessages"; //$NON-NLS-1$
20
21
	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
22
23
	private RemoteAntMessages() {
24
	}
25
26
	public static String getString(String key) {
27
		try {
28
			return RESOURCE_BUNDLE.getString(key);
29
		} catch (MissingResourceException e) {
30
			return '!' + key + '!';
31
		}
32
	}
33
}
(-)remote/org/eclipse/ant/internal/launching/remote/RemoteAntMessages.properties (+76 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
InternalAntRunner.Build_file__{0}_1=Buildfile: {0}
13
InternalAntRunner.Arguments__{0}_2=Arguments: {0}
14
InternalAntRunner.Default_target__3=Default target:
15
InternalAntRunner.Main_targets__4=Main targets:
16
InternalAntRunner.Subtargets__5=Subtargets:
17
InternalAntRunner.Unable_to_instantiate_logger__{0}_6=Unable to instantiate logger: {0}
18
InternalAntRunner.Could_not_load_the_version_information._{0}_9=Could not load the version information. {0}
19
InternalAntRunner.Could_not_load_the_version_information._10=Could not load the version information.
20
InternalAntRunner.options_13=options
21
InternalAntRunner.target_15=target
22
InternalAntRunner.Options___21=Options: 
23
InternalAntRunner.print_this_message_23=print this message
24
InternalAntRunner.print_project_help_information_25=print project help information
25
InternalAntRunner.print_the_version_information_and_exit_27=print the version information and exit
26
InternalAntRunner.be_extra_quiet_29=be extra quiet
27
InternalAntRunner.be_extra_verbose_31=be extra verbose
28
InternalAntRunner.print_debugging_information_33=print debugging information
29
InternalAntRunner.produce_logging_information_without_adornments_35=produce logging information without adornments
30
InternalAntRunner.use_given_file_for_log_37=use given file for log
31
InternalAntRunner.the_class_which_is_to_perform_logging_39=the class which is to perform logging
32
InternalAntRunner.add_an_instance_of_class_as_a_project_listener_41=add an instance of class as a project listener
33
InternalAntRunner.use_given_buildfile_43=use given buildfile
34
InternalAntRunner.use_value_for_given_property_45=use value for given property
35
InternalAntRunner.Using_{0}_file_as_build_log._1=Using {0} file as build log.
36
InternalAntRunner.Could_not_write_to_the_specified_log_file__{0}._Make_sure_the_path_exists_and_you_have_write_permissions._2=Cannot write on the specified log file: {0}. Make sure the path exists and you have write permissions.
37
InternalAntRunner.BUILD_SUCCESSFUL_1=BUILD SUCCESSFUL
38
InternalAntRunner.Unknown_argument__{0}_2=Unknown argument: {0}
39
InternalAntRunner.Buildfile__{0}_does_not_exist_!_1=Buildfile: {0} does not exist
40
InternalAntRunner.{0}_which_was_specified_to_be_a_build_listener_is_not_an_instance_of_org.apache.tools.ant.BuildListener._1={0} which was specified to be a build listener is not an instance of org.apache.tools.ant.BuildListener.
41
InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2={0} which was specified to perform logging is not an instance of org.apache.tools.ant.BuildLogger.
42
InternalAntRunner.You_must_specify_a_classname_when_using_the_-listener_argument_1=You must specify a classname when using the -listener argument
43
InternalAntRunner.You_must_specify_a_log_file_when_using_the_-log_argument_3=You must specify a log file when using the -log argument
44
InternalAntRunner.You_must_specify_a_buildfile_when_using_the_-buildfile_argument_4=You must specify a buildfile when using the -buildfile argument
45
InternalAntRunner.12=print information that might be helpful to
46
InternalAntRunner.13=\t\t\t\t\t\t\tdiagnose or report problems.
47
InternalAntRunner.19=load all properties from file with -D
48
InternalAntRunner.20=\t\t\t\t\t\t\tproperties taking precedence
49
InternalAntRunner.22=the class which will handle input requests
50
InternalAntRunner.1=\t\t\t\t\'
51
InternalAntRunner.Only_one_logger_class_may_be_specified_1=Only one logger class may be specified
52
InternalAntRunner.You_must_specify_a_classname_when_using_the_-inputhandler_argument_1=You must specify a classname when using the -inputhandler argument
53
InternalAntRunner.Only_one_input_handler_class_may_be_specified._2=Only one input handler class may be specified.
54
InternalAntRunner.You_must_specify_a_property_filename_when_using_the_-propertyfile_argument_3=You must specify a property filename when using the -propertyfile argument
55
InternalAntRunner.Could_not_load_property_file_{0}__{1}_4=Could not load property file {0}: {1}
56
InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5=The specified input handler class {0} does not implement the org.apache.tools.ant.input.InputHandler interface
57
InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6=Unable to instantiate specified input handler class {0} : {1}
58
InternalAntRunner.The_diagnositics_options_is_an_Ant_1.5.*_feature._Please_update_your_Ant_classpath_to_include_an_Ant_version_greater_than_this._4=The diagnostics options is an Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this.
59
InternalAntRunner.Specifying_property_files_is_a_Ant_1.5.*_feature._Please_update_your_Ant_classpath._6=Specifying property files is a Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this.
60
InternalAntRunner.ANT_HOME_must_be_set_to_use_Ant_diagnostics_2=ANT_HOME must be set to use Ant diagnostics
61
InternalAntRunner.Buildfile__{0}_is_not_a_file_1=Buildfile: {0} is not a file
62
InternalAntRunner.-find_not_supported=-find not supported.\nCan be emulated using Run As > Ant Build located\nin the Run > External Tools menu
63
InternalAntRunner.157=-lib not supported\nConfigure the Ant runtime classpath using either the\nglobal Ant runtime classpath or the Ant runtime classpath\n for this particular build
64
InternalAntRunner.158=\t\t\tdo not allow interactive input
65
InternalAntRunner.159=\t\texecute all targets that do not depend
66
InternalAntRunner.160=\t\t\t\t\t\ton failed target(s)
67
InternalAntRunner.161=Class {0} not found for task {1}
68
InternalAntRunner.162=Class {0} not found for type {1}
69
70
RemoteAntBuildLogger.1=BUILD FAILED
71
RemoteAntBuildLogger.Total_time=Total time: 
72
RemoteAntBuildLogger._minutes_2=\ minutes
73
RemoteAntBuildLogger._minute_3=\ minute
74
RemoteAntBuildLogger._seconds_4=\ seconds
75
RemoteAntBuildLogger._second_5=\ second
76
RemoteAntBuildLogger._milliseconds_6=\ milliseconds
(-)remote/org/eclipse/ant/internal/launching/remote/inputhandler/FailInputHandler.java (+29 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.remote.inputhandler;
13
14
import java.io.IOException;
15
import java.io.InputStream;
16
17
import org.apache.tools.ant.input.DefaultInputHandler;
18
19
public class FailInputHandler extends DefaultInputHandler {
20
	
21
	protected InputStream getInputStream() {
22
		//ensure any attempts to read input fail
23
		return new InputStream(){
24
			public int read() throws IOException {
25
				throw new IOException();
26
			}
27
		};
28
	}
29
}
(-)remote/org/eclipse/ant/internal/launching/remote/logger/MessageIds.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote.logger;
12
13
14
public class MessageIds {
15
16
	public final static String PROCESS_ID=   "processID"; //$NON-NLS-1$
17
	public final static String BUILD_CANCELLED= "cancelled"; //$NON-NLS-1$
18
    //constants need to start greater than the Project.MSG_* constants
19
	public final static String TASK= "6"; //$NON-NLS-1$
20
	public final static String TARGET= "7"; //$NON-NLS-1$
21
}
(-)remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBreakpoint.java (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote.logger;
12
13
import java.io.File;
14
15
import org.eclipse.ant.internal.launching.debug.model.DebugMessageIds;
16
17
public class RemoteAntBreakpoint {
18
	
19
    private File fFile;
20
	private int fLineNumber;
21
	private String fFileName;
22
	
23
	public RemoteAntBreakpoint(String breakpointRepresentation) {
24
		String[] data= breakpointRepresentation.split(DebugMessageIds.MESSAGE_DELIMITER);
25
		String fileName= data[1];
26
		String lineNumber= data[2];
27
		fFileName= fileName;
28
		fFile= new File(fileName);
29
		fLineNumber= Integer.parseInt(lineNumber);
30
	}
31
32
	public boolean isAt(String fileName, int lineNumber) {
33
		return fLineNumber == lineNumber && fileName != null && fFile.equals(new File(fileName));
34
	}
35
	
36
	public String toMarshallString() {
37
		StringBuffer buffer= new StringBuffer(DebugMessageIds.BREAKPOINT);
38
		buffer.append(DebugMessageIds.MESSAGE_DELIMITER);
39
		buffer.append(fFileName);
40
		buffer.append(DebugMessageIds.MESSAGE_DELIMITER);
41
		buffer.append(fLineNumber);
42
		return buffer.toString();
43
	}
44
	
45
	/* (non-Javadoc)
46
	 * @see java.lang.Object#equals(java.lang.Object)
47
	 */
48
	public boolean equals(Object obj) {
49
		if (!(obj instanceof RemoteAntBreakpoint)) {
50
			return false;
51
		}
52
		RemoteAntBreakpoint other= (RemoteAntBreakpoint) obj;
53
		return other.getLineNumber() == fLineNumber && other.getFile().equals(fFile);
54
	}
55
	
56
	/* (non-Javadoc)
57
	 * @see java.lang.Object#hashCode()
58
	 */
59
	public int hashCode() {
60
		return fFileName.hashCode() + fLineNumber;
61
	}
62
	
63
	public int getLineNumber() {
64
		return fLineNumber;
65
	}
66
67
	public String getFileName() {
68
		return fFileName;
69
	}
70
	
71
	public File getFile() {
72
	    return fFile;
73
	}
74
}
(-)remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntBuildLogger.java (+396 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote.logger;
12
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.PrintStream;
17
import java.io.PrintWriter;
18
import java.io.StringReader;
19
import java.net.Socket;
20
import java.util.ArrayList;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
25
import org.apache.tools.ant.BuildEvent;
26
import org.apache.tools.ant.BuildException;
27
import org.apache.tools.ant.DefaultLogger;
28
import org.apache.tools.ant.Location;
29
import org.apache.tools.ant.Project;
30
import org.apache.tools.ant.Target;
31
import org.apache.tools.ant.util.StringUtils;
32
import org.eclipse.ant.internal.launching.debug.AntDebugState;
33
import org.eclipse.ant.internal.launching.remote.AntSecurityException;
34
import org.eclipse.ant.internal.launching.remote.InternalAntRunner;
35
import org.eclipse.ant.internal.launching.remote.RemoteAntMessages;
36
37
/**
38
 * Parts adapted from org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
39
 * A build logger that reports via a socket connection.
40
 * See MessageIds for more information about the protocol.
41
 */
42
public class RemoteAntBuildLogger extends DefaultLogger {
43
44
    /** Time of the start of the build */
45
    private long fStartTime = System.currentTimeMillis();
46
47
    /**
48
     * The client socket.
49
     */
50
    private Socket fEventSocket;
51
    /**
52
     * Print writer for sending messages
53
     */
54
    private PrintWriter fWriter;
55
    /**
56
     * Host to connect to, default is the localhost
57
     */
58
    protected String fHost= ""; //$NON-NLS-1$
59
    /**
60
     * Port to connect to.
61
     */
62
    private int fEventPort= -1;
63
    
64
    private String fProcessId= null;
65
    
66
    /**
67
     * Is the debug mode enabled?
68
     */
69
    protected boolean fDebugMode= false;    
70
    
71
    protected boolean fSentProcessId= false;
72
    
73
    private List fEventQueue;
74
    
75
    private String fLastFileName= null;
76
    private String fLastTaskName= null;
77
    
78
    /* (non-Javadoc)
79
     * @see org.apache.tools.ant.DefaultLogger#printMessage(java.lang.String, java.io.PrintStream, int)
80
     */
81
    protected void printMessage(String message, PrintStream stream, int priority) {
82
        marshalMessage(priority, message);
83
    }
84
    
85
    /**
86
     * Connect to the remote Ant build listener.
87
     */
88
    protected void connect() {
89
        if (fDebugMode) {
90
            System.out.println("RemoteAntBuildLogger: trying to connect" + fHost + ":" + fEventPort); //$NON-NLS-1$ //$NON-NLS-2$
91
        }
92
        
93
        for (int i= 1; i < 5; i++) {
94
            try{
95
                fEventSocket= new Socket(fHost, fEventPort);
96
                fWriter= new PrintWriter(fEventSocket.getOutputStream(), true);
97
                return;
98
            } catch(IOException e){
99
            }
100
            try {
101
                Thread.sleep(500);
102
            } catch(InterruptedException e) {
103
            }
104
        }
105
        shutDown();
106
    }
107
108
    /**
109
     * Shutdown the connection to the remote build listener.
110
     */
111
    protected void shutDown() {
112
        if (fEventQueue != null) {
113
            fEventQueue.clear();
114
        }
115
        if (fWriter != null) {
116
            fWriter.close();
117
            fWriter= null;
118
        }
119
        
120
        try {
121
            if (fEventSocket != null) {
122
                fEventSocket.close();
123
                fEventSocket= null;
124
            }
125
        } catch(IOException e) {
126
        }
127
    }
128
129
    private void sendMessage(String msg) {
130
        if (fWriter == null) {
131
            return;
132
        }
133
        
134
        fWriter.println(msg);
135
    }
136
    
137
    /* (non-Javadoc)
138
     * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
139
     */
140
    public void buildFinished(BuildEvent event) {
141
        if (!fSentProcessId) {
142
            establishConnection();
143
        }
144
        handleException(event);
145
        printMessage( getTimeString(System.currentTimeMillis() - fStartTime), out, Project.MSG_INFO); 
146
        shutDown();
147
    }
148
    
149
    protected void handleException(BuildEvent event) {
150
        Throwable exception = event.getException();
151
        if (exception == null || exception instanceof AntSecurityException) {
152
            return;
153
        }
154
        
155
         StringBuffer message= new StringBuffer();
156
         message.append(StringUtils.LINE_SEP);
157
         message.append(RemoteAntMessages.getString("RemoteAntBuildLogger.1")); //$NON-NLS-1$
158
         message.append(StringUtils.LINE_SEP);
159
         if (Project.MSG_VERBOSE <= this.msgOutputLevel || !(exception instanceof BuildException)) {
160
             message.append(StringUtils.getStackTrace(exception));
161
         } else {
162
             if (exception instanceof BuildException) {
163
                 message.append(exception.toString()).append(StringUtils.LINE_SEP);
164
             } else {
165
                 message.append(exception.getMessage()).append(StringUtils.LINE_SEP);
166
             }
167
         }
168
        message.append(StringUtils.LINE_SEP);
169
        printMessage(message.toString(), out, Project.MSG_ERR); 
170
    }
171
    
172
    private String getTimeString(long milliseconds) {
173
        long seconds = milliseconds / 1000;
174
        long minutes = seconds / 60;
175
        seconds= seconds % 60;
176
177
        StringBuffer result= new StringBuffer(RemoteAntMessages.getString("RemoteAntBuildLogger.Total_time")); //$NON-NLS-1$
178
        if (minutes > 0) {
179
            result.append(minutes);
180
            if (minutes > 1) {
181
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._minutes_2")); //$NON-NLS-1$
182
            } else {
183
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._minute_3")); //$NON-NLS-1$
184
            }
185
        }
186
        if (seconds > 0) {
187
            if (minutes > 0) {
188
                result.append(' ');
189
            }
190
            result.append(seconds);
191
    
192
            if (seconds > 1) {
193
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._seconds_4")); //$NON-NLS-1$
194
            } else {
195
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._second_5")); //$NON-NLS-1$
196
            } 
197
        }
198
        if (seconds == 0 && minutes == 0) {
199
            result.append(milliseconds);
200
            result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._milliseconds_6"));      //$NON-NLS-1$
201
        }
202
        return result.toString();
203
    }
204
            
205
206
    /* (non-Javadoc)
207
     * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
208
     */
209
    public void targetStarted(BuildEvent event) {
210
        if (!fSentProcessId) {
211
            establishConnection();
212
        }
213
214
        if (Project.MSG_INFO <= msgOutputLevel) {
215
            marshalTargetMessage(event);
216
        }
217
    }
218
219
    protected void establishConnection() {
220
        if (fEventPort != -1) {
221
            connect();
222
        } else {
223
            shutDown();
224
            return;
225
        }
226
        
227
        fSentProcessId= true;
228
        StringBuffer message= new StringBuffer(MessageIds.PROCESS_ID);
229
        message.append(fProcessId);
230
        sendMessage(message.toString());
231
        if (fEventQueue != null) {
232
            for (Iterator iter = fEventQueue.iterator(); iter.hasNext();) {
233
                processEvent((BuildEvent)iter.next());
234
            }
235
            fEventQueue= null;
236
        }
237
    }
238
239
    /* (non-Javadoc)
240
     * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
241
     */
242
    public void messageLogged(BuildEvent event) {
243
        if (event.getPriority() > msgOutputLevel && event.getPriority() != InternalAntRunner.MSG_PROJECT_HELP) {
244
            return;
245
        }
246
        
247
        if (!fSentProcessId) {
248
            if (event.getPriority() == InternalAntRunner.MSG_PROJECT_HELP) {
249
                if (Project.MSG_INFO > msgOutputLevel) {
250
                    return;
251
                }
252
                //no buildstarted or project started for project help option
253
                establishConnection();
254
                return;
255
            }
256
            if (fEventQueue == null){
257
                fEventQueue= new ArrayList(10);
258
            }
259
            fEventQueue.add(event);
260
            return;
261
        }
262
        
263
        processEvent(event);
264
    }
265
266
    private void processEvent(BuildEvent event) {
267
        if (event.getTask() != null & !emacsMode) {
268
            try {
269
                marshalTaskMessage(event);
270
            } catch (IOException e) {
271
            }
272
        } else {
273
            marshalMessage(event);
274
        }
275
    }
276
    
277
    private void marshalMessage(BuildEvent event) {
278
        String eventMessage= event.getMessage();
279
        if (eventMessage.length() == 0) {
280
            return;
281
        }
282
        marshalMessage(event.getPriority(), eventMessage);
283
    }
284
285
    protected void marshalMessage(int priority, String message) {
286
        try {
287
            BufferedReader r = new BufferedReader(new StringReader(message));
288
            String line = r.readLine();
289
            StringBuffer messageLine;
290
            while (line != null) {
291
                messageLine= new StringBuffer();
292
                if (priority != -1) {
293
                    messageLine.append(priority);
294
                    messageLine.append(',');
295
                }
296
                messageLine.append(line);
297
                sendMessage(messageLine.toString());
298
                line = r.readLine();
299
            }
300
        } catch (IOException e) {
301
        }
302
    }
303
304
    private void marshalTaskMessage(BuildEvent event) throws IOException {
305
        String eventMessage= event.getMessage();
306
        if (eventMessage.length() == 0) {
307
            return;
308
        }
309
        BufferedReader r = new BufferedReader(new StringReader(eventMessage));
310
        String line = r.readLine();
311
        StringBuffer message;
312
        String taskName= event.getTask().getTaskName();
313
        if (taskName != null && taskName.equals(fLastTaskName)) {
314
            taskName= ""; //$NON-NLS-1$
315
        } else {
316
            fLastTaskName= taskName;
317
        }
318
        Location location= event.getTask().getLocation();
319
        String fileName= null;
320
        int lineNumber= -1;
321
        try {
322
            fileName= location.getFileName();
323
            lineNumber= location.getLineNumber();
324
        } catch (NoSuchMethodError e) {
325
            //older Ant
326
            fileName= location.toString();
327
        }
328
        if (location.equals(Location.UNKNOWN_LOCATION)) {
329
            fileName= location.toString();
330
            lineNumber= -1;
331
        }
332
        int priority= event.getPriority();
333
        while (line != null) {
334
            message= new StringBuffer(MessageIds.TASK);
335
            message.append(priority);
336
            message.append(',');
337
            message.append(taskName);
338
            message.append(',');
339
            message.append(line.length());
340
            message.append(',');
341
            message.append(line);
342
            message.append(',');
343
            if (!fileName.equals(fLastFileName)) {
344
            	message.append(fileName.length());
345
            	message.append(',');
346
                message.append(fileName);
347
            } 
348
            message.append(',');
349
            message.append(lineNumber);
350
            sendMessage(message.toString());
351
            fLastFileName= fileName;
352
            line= r.readLine();
353
        }
354
    }
355
    
356
    private void marshalTargetMessage(BuildEvent event) {
357
        Target target= event.getTarget();
358
        Location location= AntDebugState.getLocation(target);
359
        
360
        StringBuffer message= new StringBuffer();
361
        message.append(MessageIds.TARGET);
362
        message.append(',');
363
        message.append(target.getName());
364
        message.append(':');
365
        message.append(',');
366
        if (location != null && location != Location.UNKNOWN_LOCATION) {
367
            //if a target has a valid location then we are on an Ant that is 
368
            //new enough to have the accessor methods on Location
369
        	String fileName= location.getFileName();
370
        	message.append(fileName.length());
371
        	message.append(',');
372
            message.append(fileName);
373
            message.append(',');
374
            message.append(location.getLineNumber());
375
        }
376
        sendMessage(message.toString());
377
    }
378
379
    /* (non-Javadoc)
380
     * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
381
     */
382
    public void buildStarted(BuildEvent event) {
383
        establishConnection();
384
        super.buildStarted(event);
385
    }
386
    
387
    public void configure(Map userProperties) {
388
        String portProperty= (String) userProperties.remove("eclipse.connect.port"); //$NON-NLS-1$
389
        
390
        if (portProperty != null) {
391
            fEventPort= Integer.parseInt(portProperty);
392
        }
393
        
394
        fProcessId= (String) userProperties.remove("org.eclipse.ant.core.ANT_PROCESS_ID"); //$NON-NLS-1$
395
    } 
396
}
(-)remote/org/eclipse/ant/internal/launching/remote/logger/RemoteAntDebugBuildLogger.java (+353 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.remote.logger;
12
13
import java.io.BufferedReader;
14
import java.io.IOException;
15
import java.io.InputStreamReader;
16
import java.io.PrintWriter;
17
import java.net.ServerSocket;
18
import java.net.Socket;
19
import java.net.SocketTimeoutException;
20
import java.util.ArrayList;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
25
import org.apache.tools.ant.BuildEvent;
26
import org.apache.tools.ant.Location;
27
import org.apache.tools.ant.Task;
28
import org.eclipse.ant.internal.launching.debug.AntDebugState;
29
import org.eclipse.ant.internal.launching.debug.IDebugBuildLogger;
30
import org.eclipse.ant.internal.launching.debug.model.DebugMessageIds;
31
32
/**
33
 * Parts adapted from org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
34
 * A build logger that reports via a socket connection.
35
 * See DebugMessageIds and MessageIds for more information about the protocol.
36
 */
37
public class RemoteAntDebugBuildLogger extends RemoteAntBuildLogger implements IDebugBuildLogger {
38
	
39
	private ServerSocket fServerSocket;
40
	private static final int fgServerSocketTimeout= 5000;
41
	private Socket fRequestSocket;
42
	
43
	private PrintWriter fRequestWriter;
44
	
45
	private BufferedReader fRequestReader;
46
	
47
    private boolean fBuildStartedSuspend= true;
48
	
49
	private Task fStepOverTaskInterrupted;
50
	
51
	private List fBreakpoints= null;
52
	
53
	/**
54
	 * Request port to connect to.
55
	 * Used for debug connections
56
	 */
57
	private int fRequestPort= -1;
58
	private AntDebugState fDebugState;
59
60
	/**
61
	 * Reader thread that processes requests from the debug client.
62
	 */
63
	private class ReaderThread extends Thread {
64
		public ReaderThread() {
65
			super("ReaderThread"); //$NON-NLS-1$
66
			setDaemon(true);
67
		}
68
69
		public void run(){
70
			try { 
71
				String message= null; 
72
				while (fRequestReader != null) { 
73
					if ((message= fRequestReader.readLine()) != null) {
74
						
75
						if (message.startsWith(DebugMessageIds.STEP_INTO)){
76
							synchronized(RemoteAntDebugBuildLogger.this) {
77
								fDebugState.setStepIntoSuspend(true);
78
								fDebugState.setStepIntoTask(fDebugState.getCurrentTask());
79
								RemoteAntDebugBuildLogger.this.notifyAll();
80
							}
81
						} if (message.startsWith(DebugMessageIds.STEP_OVER)){
82
							synchronized(RemoteAntDebugBuildLogger.this) {
83
								fDebugState.stepOver();
84
							}
85
						} else if (message.startsWith(DebugMessageIds.SUSPEND)) {
86
							synchronized(RemoteAntDebugBuildLogger.this) {
87
								fDebugState.setStepIntoTask(null);
88
								fDebugState.setStepOverTask(null);
89
								fStepOverTaskInterrupted= null;
90
								fDebugState.setClientSuspend(true);
91
							}
92
						} else if (message.startsWith(DebugMessageIds.RESUME)) {
93
							synchronized(RemoteAntDebugBuildLogger.this) {
94
								fDebugState.setStepIntoTask(null);
95
								fDebugState.setStepOverTask(null);
96
								fStepOverTaskInterrupted= null;
97
								RemoteAntDebugBuildLogger.this.notifyAll();
98
							}
99
						} else if (message.startsWith(DebugMessageIds.TERMINATE)) {
100
						    sendRequestResponse(DebugMessageIds.TERMINATED);
101
							shutDown();
102
						} else if (message.startsWith(DebugMessageIds.STACK)) {
103
							marshallStack();
104
						} else if (message.startsWith(DebugMessageIds.ADD_BREAKPOINT)) {
105
							addBreakpoint(message);
106
						} else if (message.startsWith(DebugMessageIds.REMOVE_BREAKPOINT)) {
107
							removeBreakpoint(message);
108
						}  else if (message.startsWith(DebugMessageIds.PROPERTIES)) {
109
							marshallProperties();
110
						}
111
					}
112
				} 
113
			} catch (Exception e) {
114
				RemoteAntDebugBuildLogger.this.shutDown();
115
			}
116
		}
117
	}
118
	
119
	private void requestConnect() {
120
		if (fDebugMode) {
121
			System.out.println("RemoteAntDebugBuildLogger: trying to connect" + fHost + ":" + fRequestPort); //$NON-NLS-1$ //$NON-NLS-2$
122
		}
123
		
124
		try{
125
			fServerSocket.setSoTimeout(fgServerSocketTimeout);
126
			fRequestSocket= fServerSocket.accept();
127
			fRequestWriter= new PrintWriter(fRequestSocket.getOutputStream(), true);
128
			fRequestReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
129
			
130
			ReaderThread readerThread= new ReaderThread();
131
			readerThread.setDaemon(true);
132
			readerThread.start();
133
			return;
134
		} catch(SocketTimeoutException e){
135
		} catch(IOException e) {
136
		}
137
		shutDown();
138
	}
139
	
140
	/* (non-Javadoc)
141
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger#shutDown()
142
	 */
143
	protected void shutDown() {
144
		if (fRequestWriter != null) {
145
			fRequestWriter.close();
146
			fRequestWriter= null;
147
		}
148
		
149
		if (fRequestReader != null) {
150
			try {
151
				fRequestReader.close();
152
			} catch (IOException e) {
153
			}
154
			fRequestReader= null;
155
		}
156
		
157
		if (fRequestSocket != null) {
158
			try {
159
				fRequestSocket.close();	
160
			} catch(IOException e) {
161
			}
162
		}
163
		fRequestSocket= null;
164
		
165
		super.shutDown();
166
	}
167
	
168
	/* (non-Javadoc)
169
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
170
	 */
171
	public synchronized void buildStarted(BuildEvent event) {
172
		fDebugState= new AntDebugState(this);
173
		super.buildStarted(event);
174
		marshalMessage(-1, DebugMessageIds.BUILD_STARTED);
175
		if (fRequestPort != -1) {
176
			try {
177
				fServerSocket= new ServerSocket(fRequestPort);
178
			} catch (IOException ioe) {
179
				shutDown();
180
			}
181
			requestConnect();
182
		} else {
183
			shutDown();
184
		}
185
        fDebugState.buildStarted();
186
		fDebugState.setShouldSuspend(true);
187
		waitIfSuspended();
188
	}
189
190
	/* (non-Javadoc)
191
	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
192
	 */
193
	public void taskStarted(BuildEvent event) {
194
        super.taskStarted(event);
195
		fDebugState.taskStarted(event);
196
	}
197
	
198
	/* (non-Javadoc)
199
	 * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
200
	 */
201
	public synchronized void taskFinished(BuildEvent event) {
202
		super.taskFinished(event);
203
		fDebugState.taskFinished();
204
	}
205
	
206
	/* (non-Javadoc)
207
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.util.IDebugBuildLogger#waitIfSuspended()
208
	 */
209
	public synchronized void waitIfSuspended() {
210
		String detail= null;
211
		boolean shouldSuspend= true;
212
		RemoteAntBreakpoint breakpoint= breakpointAtLineNumber(fDebugState.getBreakpointLocation());
213
		if (breakpoint != null) {
214
			detail= breakpoint.toMarshallString();
215
			fDebugState.setShouldSuspend(false);
216
			if (fDebugState.getStepOverTask() != null) {
217
				fStepOverTaskInterrupted= fDebugState.getStepOverTask();
218
				fDebugState.setStepOverTask(null);
219
			}
220
		} else if (fDebugState.getCurrentTask() != null) {
221
	        if (fDebugState.isStepIntoSuspend()) {
222
	            detail= DebugMessageIds.STEP;
223
				fDebugState.setStepIntoSuspend(false);
224
	        } else if ((fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fDebugState.getStepOverTask()) || fDebugState.shouldSuspend()) {
225
	        	//suspend as a step over has finished
226
	        	detail= DebugMessageIds.STEP;
227
				fDebugState.setStepOverTask(null);
228
				fDebugState.setShouldSuspend(false);
229
	        } else if (fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fDebugState.getStepIntoTask()) {
230
	        	//suspend as a task that was stepped into has finally completed
231
	        	 detail= DebugMessageIds.STEP;
232
	        	 fDebugState.setStepIntoTask(null);
233
	        } else if (fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fStepOverTaskInterrupted) {
234
	        	//suspend as a task that was stepped over but hit a breakpoint has finally completed
235
	        	 detail= DebugMessageIds.STEP;
236
	        	 fStepOverTaskInterrupted= null;
237
	        } else if (fDebugState.isClientSuspend()) {
238
	            detail= DebugMessageIds.CLIENT_REQUEST;
239
				fDebugState.setClientSuspend(false);
240
	        } else {
241
	            shouldSuspend= false;
242
	        }
243
	    } else if (fDebugState.shouldSuspend() && fBuildStartedSuspend) {
244
            fBuildStartedSuspend= false;
245
			fDebugState.setShouldSuspend(false);
246
	    } else {
247
			shouldSuspend= false;
248
	    }
249
		
250
		if (shouldSuspend) {
251
			if (detail != null) {
252
				StringBuffer message= new StringBuffer(DebugMessageIds.SUSPENDED);
253
				message.append(detail);
254
				sendRequestResponse(message.toString());
255
			}
256
			 try {
257
				 wait();
258
                 shouldSuspend= false;
259
			 } catch (InterruptedException e) {
260
			 }
261
		}
262
	}
263
264
	private RemoteAntBreakpoint breakpointAtLineNumber(Location location) {
265
		if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
266
			return null;
267
		}
268
		String fileName= fDebugState.getFileName(location);
269
		int lineNumber= fDebugState.getLineNumber(location);
270
		for (int i = 0; i < fBreakpoints.size(); i++) {
271
			RemoteAntBreakpoint breakpoint = (RemoteAntBreakpoint) fBreakpoints.get(i);
272
			if (breakpoint.isAt(fileName, lineNumber)) {
273
				return breakpoint;
274
			}
275
		}
276
		return null;
277
	}
278
279
	private void sendRequestResponse(String message) {
280
		if (fRequestWriter == null) {
281
			return;
282
		}
283
		
284
		fRequestWriter.println(message);
285
	}
286
	
287
	protected void marshallStack() {
288
	    StringBuffer stackRepresentation= new StringBuffer();
289
	    fDebugState.marshalStack(stackRepresentation);
290
	    sendRequestResponse(stackRepresentation.toString());
291
	}
292
	
293
	protected void marshallProperties() {
294
	    StringBuffer propertiesRepresentation= new StringBuffer();
295
		fDebugState.marshallProperties(propertiesRepresentation, true);
296
	    sendRequestResponse(propertiesRepresentation.toString());
297
	}
298
	
299
	protected void addBreakpoint(String breakpointRepresentation) {
300
		if (fBreakpoints == null) {
301
			fBreakpoints= new ArrayList();
302
		}
303
		RemoteAntBreakpoint newBreakpoint= new RemoteAntBreakpoint(breakpointRepresentation);
304
		if (!fBreakpoints.contains(newBreakpoint)) {
305
			fBreakpoints.add(newBreakpoint);	
306
		}
307
	}
308
	
309
	protected void removeBreakpoint(String breakpointRepresentation) {
310
		if (fBreakpoints == null) {
311
			return;
312
		} 
313
		RemoteAntBreakpoint equivalentBreakpoint= new RemoteAntBreakpoint(breakpointRepresentation);
314
		for (Iterator iter = fBreakpoints.iterator(); iter.hasNext(); ) {
315
			RemoteAntBreakpoint breakpoint = (RemoteAntBreakpoint) iter.next();
316
			if (breakpoint.equals(equivalentBreakpoint)) {
317
				iter.remove();
318
				return;
319
			}
320
		}
321
	}
322
323
	/* (non-Javadoc)
324
	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
325
	 */
326
	public void targetStarted(BuildEvent event) {
327
		fDebugState.targetStarted(event);
328
		if (!fSentProcessId) {
329
			establishConnection();
330
		}
331
		waitIfSuspended();
332
		super.targetStarted(event);
333
	}
334
    
335
    /* (non-Javadoc)
336
     * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
337
     */
338
    public void targetFinished(BuildEvent event) {
339
        super.targetFinished(event);
340
		fDebugState.setTargetExecuting(null);
341
    }   
342
    
343
    /* (non-Javadoc)
344
     * @see org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger#configure(java.util.Map)
345
     */
346
    public void configure(Map userProperties) {
347
       super.configure(userProperties);
348
       String requestPortProperty= (String) userProperties.remove("eclipse.connect.request_port"); //$NON-NLS-1$
349
        if (requestPortProperty != null) {
350
            fRequestPort= Integer.parseInt(requestPortProperty);
351
        }
352
    }
353
}
(-)src/org/eclipse/ant/internal/launching/AntCoreModelMessages.java (+25 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class AntCoreModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.launchConfigurations.AntCoreModelMessages";//$NON-NLS-1$
16
	
17
	public static String AntUtil_6;
18
	public static String AntUtil_7;
19
	public static String AntUtil_2;
20
21
	static {
22
		// load message values from bundle file
23
		NLS.initializeMessages(BUNDLE_NAME, AntCoreModelMessages.class);
24
	}
25
}
(-)src/org/eclipse/ant/internal/launching/AntCoreModelMessages.properties (+14 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
AntUtil_6=Invalid property file entry: {0}
13
AntUtil_7=Unable to generate Ant classpath
14
AntUtil_2=Error reading launch configuration
(-)src/org/eclipse/ant/internal/launching/AntLaunch.java (+57 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.Launch;
18
import org.eclipse.debug.core.model.ISourceLocator;
19
20
/**
21
 * Stores link descriptors for Launch for further use of TaskLinkManager
22
 */
23
public class AntLaunch extends Launch {
24
	List linkDescriptors;
25
26
	public AntLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
27
		super(launchConfiguration, mode, locator);
28
		linkDescriptors = new ArrayList();
29
	}
30
31
	public void addLinkDescriptor(String line, String fileName, int lineNumber, int offset, int length) {
32
		if (fileName!= null && fileName.trim().length() > 0) {
33
			synchronized (linkDescriptors) {
34
				linkDescriptors.add(new LinkDescriptor(line, fileName, lineNumber, offset, length));
35
			}
36
		}
37
	}
38
39
	public void removeLinkDescriptor(LinkDescriptor ld) {
40
		synchronized (linkDescriptors) {
41
			linkDescriptors.remove(ld);
42
		}
43
	}
44
45
	public List getLinkDescriptors() {
46
		synchronized (linkDescriptors) {
47
			return new ArrayList(linkDescriptors);
48
		}
49
	}
50
51
	public void clearLinkDescriptors() {
52
		synchronized (linkDescriptors) {
53
			linkDescriptors.clear();
54
		}
55
	}
56
57
}
(-)src/org/eclipse/ant/internal/launching/AntLaunching.java (+106 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
11
package org.eclipse.ant.internal.launching;
12
12
13
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
14
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.Plugin;
15
import org.eclipse.core.runtime.Plugin;
16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
14
import org.osgi.framework.BundleContext;
18
import org.osgi.framework.BundleContext;
15
19
16
/**
20
/**
Lines 20-25 Link Here
20
24
21
	// The plug-in ID
25
	// The plug-in ID
22
	public static final String PLUGIN_ID = "org.eclipse.ant.launching"; //$NON-NLS-1$
26
	public static final String PLUGIN_ID = "org.eclipse.ant.launching"; //$NON-NLS-1$
27
	
28
	private static final String EMPTY_STRING= ""; //$NON-NLS-1$
29
	
30
	/**
31
	 * Boolean attribute indicating if an input handler should be supplied for
32
	 * the build Default value is <code>true</code>.
33
	 */
34
	public static final String SET_INPUTHANDLER = "org.eclipse.ant.ui.SET_INPUTHANDLER"; //$NON-NLS-1$
35
36
	/**
37
	 * int preference identifier constant which specifies the length of time to
38
	 * wait to connect with the socket that communicates with the separate JRE
39
	 * to capture the output
40
	 */
41
	public static final String ANT_COMMUNICATION_TIMEOUT = "timeout"; //$NON-NLS-1$
42
43
	/**
44
	 * Size of left-hand column for right-justified task name. Used for Ant
45
	 * Build logging.
46
	 * 
47
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger
48
	 * @see org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener
49
	 */
50
	public static final int LEFT_COLUMN_SIZE = 15;
51
	
52
	/**
53
	 * String attribute indicating the custom runtime classpath to use for an
54
	 * Ant build. Default value is <code>null</code> which indicates that the
55
	 * global classpath is to be used. Format is a comma separated listing of
56
	 * URLs.
57
	 * 
58
	 * @deprecated no longer supported: use
59
	 *             {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER}
60
	 * @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH
61
	 */
62
	public static final String ATTR_ANT_CUSTOM_CLASSPATH = IExternalToolConstants.UI_PLUGIN_ID
63
			+ ".ATTR_ANT_CUSTOM_CLASSPATH"; //$NON-NLS-1$
64
	/**
65
	 * String attribute indicating the custom Ant home to use for an Ant build.
66
	 * Default value is <code>null</code> which indicates that no Ant home is to
67
	 * be set
68
	 * 
69
	 * @deprecated no longer supported: use
70
	 *             {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER}
71
	 * @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH
72
	 */
73
	public static final String ATTR_ANT_HOME = IExternalToolConstants.UI_PLUGIN_ID
74
			+ ".ATTR_ANT_HOME"; //$NON-NLS-1$
75
	
76
	
77
	/**
78
	 * Status code indicating an unexpected internal error.
79
	 * @since 2.1
80
	 */
81
	public static final int INTERNAL_ERROR = 120;	
23
82
24
	// The shared instance
83
	// The shared instance
25
	private static AntLaunching plugin;
84
	private static AntLaunching plugin;
Lines 56-60 Link Here
56
	public static AntLaunching getDefault() {
115
	public static AntLaunching getDefault() {
57
		return plugin;
116
		return plugin;
58
	}
117
	}
118
	
119
	public static String getUniqueIdentifier() {
120
		return PLUGIN_ID;
121
	}
122
	
123
	/**
124
	 * Logs the specified throwable with this plug-in's log.
125
	 * 
126
	 * @param t throwable to log 
127
	 */
128
	public static void log(Throwable t) {
129
		IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, "Error logged from Ant UI: ", t); //$NON-NLS-1$
130
		log(status);
131
	}
132
	
133
	/**
134
	 * Logs the specified status with this plug-in's log.
135
	 * 
136
	 * @param status status 
137
	 */
138
	public static void log(IStatus status) {
139
		getDefault().getLog().log(status);
140
	}
141
	
142
	/**
143
	 * Writes the message to the plug-in's log
144
	 * 
145
	 * @param message the text to write to the log
146
	 */
147
	public static void log(String message, Throwable exception) {
148
		IStatus status = newErrorStatus(message, exception);
149
		log(status);
150
	}
151
	
152
	/**
153
	 * Returns a new <code>IStatus</code> for this plug-in
154
	 */
155
	public static IStatus newErrorStatus(String message, Throwable exception) {
156
		if (message == null) {
157
			message= EMPTY_STRING; 
158
		}		
159
		return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception);
160
	}
161
	
162
	public static AntLaunching getPlugin() {
163
		return plugin;
164
	}
59
165
60
}
166
}
(-)src/org/eclipse/ant/internal/launching/AntLaunchingPreferenceInitializer.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
12
13
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
14
import org.eclipse.core.runtime.preferences.DefaultScope;
15
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
16
17
public class AntLaunchingPreferenceInitializer extends
18
		AbstractPreferenceInitializer {
19
20
	public AntLaunchingPreferenceInitializer() {
21
		super();
22
	}
23
24
	/*
25
	 * (non-Javadoc)
26
	 * 
27
	 * @seeorg.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
28
	 * initializeDefaultPreferences()
29
	 */
30
	public void initializeDefaultPreferences() {
31
32
		IEclipsePreferences node = new DefaultScope()
33
				.getNode("org.eclipse.ant.launching"); //$NON-NLS-1$
34
		node.put(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
35
				"20000"); //$NON-NLS-1$
36
	}
37
}
(-)src/org/eclipse/ant/internal/launching/AntLaunchingUtil.java (+524 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
12
13
import java.io.File;
14
import java.io.IOException;
15
import java.net.MalformedURLException;
16
import java.net.URL;
17
import java.util.ArrayList;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.StringTokenizer;
21
22
import org.apache.tools.ant.BuildException;
23
import org.apache.tools.ant.util.FileUtils;
24
import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
25
import org.eclipse.ant.internal.launching.launchConfigurations.AntProcess;
26
import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntRuntimeProcess;
27
import org.eclipse.ant.launching.IAntLaunchConstants;
28
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
29
import org.eclipse.core.externaltools.internal.model.ExternalToolBuilder;
30
import org.eclipse.core.resources.IFile;
31
import org.eclipse.core.resources.IWorkspaceRoot;
32
import org.eclipse.core.resources.ResourcesPlugin;
33
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.IPath;
35
import org.eclipse.core.runtime.IStatus;
36
import org.eclipse.core.runtime.Path;
37
import org.eclipse.core.runtime.Status;
38
import org.eclipse.core.variables.VariablesPlugin;
39
import org.eclipse.debug.core.ILaunch;
40
import org.eclipse.debug.core.ILaunchConfiguration;
41
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
42
import org.eclipse.debug.core.model.IProcess;
43
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
44
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
45
import org.eclipse.jdt.launching.IRuntimeClasspathEntry2;
46
import org.eclipse.jdt.launching.JavaRuntime;
47
48
import com.ibm.icu.text.MessageFormat;
49
50
/**
51
 * General utility class dealing with Ant build files
52
 */
53
public final class AntLaunchingUtil {
54
	public static final String ATTRIBUTE_SEPARATOR = ","; //$NON-NLS-1$;
55
	public static final char ANT_CLASSPATH_DELIMITER = '*';
56
	public static final String ANT_HOME_CLASSPATH_PLACEHOLDER = "G"; //$NON-NLS-1$
57
	public static final String ANT_GLOBAL_USER_CLASSPATH_PLACEHOLDER = "UG"; //$NON-NLS-1$
58
	
59
	/**
60
	 * No instances allowed
61
	 */
62
	private AntLaunchingUtil() {
63
		super();
64
	}
65
66
	/**
67
	 * Returns a single-string of the strings for storage.
68
	 * 
69
	 * @param strings
70
	 *            the array of strings
71
	 * @return a single-string representation of the strings or
72
	 *         <code>null</code> if the array is empty.
73
	 */
74
	public static String combineStrings(String[] strings) {
75
		if (strings.length == 0)
76
			return null;
77
78
		if (strings.length == 1)
79
			return strings[0];
80
81
		StringBuffer buf = new StringBuffer();
82
		for (int i = 0; i < strings.length - 1; i++) {
83
			buf.append(strings[i]);
84
			buf.append(ATTRIBUTE_SEPARATOR);
85
		}
86
		buf.append(strings[strings.length - 1]);
87
		return buf.toString();
88
	}
89
90
	/**
91
	 * Returns an array of targets to be run, or <code>null</code> if none are
92
	 * specified (indicating the default target or implicit target should be
93
	 * run).
94
	 * 
95
	 * @param configuration
96
	 *            launch configuration
97
	 * @return array of target names, or <code>null</code>
98
	 * @throws CoreException
99
	 *             if unable to access the associated attribute
100
	 */
101
	public static String[] getTargetNames(ILaunchConfiguration configuration)
102
			throws CoreException {
103
		String attribute = null;
104
		if (IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE
105
				.equals(configuration.getType().getIdentifier())) {
106
			attribute = getTargetNamesForAntBuilder(configuration);
107
		}
108
		if (attribute == null) {
109
			attribute = configuration.getAttribute(
110
					IAntLaunchConstants.ATTR_ANT_TARGETS,
111
					(String) null);
112
			if (attribute == null) {
113
				return null;
114
			}
115
		}
116
117
		return AntLaunchingUtil.parseRunTargets(attribute);
118
	}
119
120
	private static String getTargetNamesForAntBuilder(
121
			ILaunchConfiguration configuration) throws CoreException {
122
		String buildType = ExternalToolBuilder.getBuildType();
123
		String targets = null;
124
		if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(buildType)) {
125
			targets = configuration.getAttribute(
126
					IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS,
127
					(String) null);
128
		} else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(buildType)) {
129
			targets = configuration.getAttribute(
130
					IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS,
131
					(String) null);
132
		} else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(buildType)) {
133
			targets = configuration
134
					.getAttribute(
135
							IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS,
136
							(String) null);
137
		} else if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL
138
				.equals(buildType)) {
139
			targets = configuration.getAttribute(
140
					IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS,
141
					(String) null);
142
		}
143
144
		return targets;
145
	}
146
147
	/**
148
	 * Returns a map of properties to be defined for the build, or
149
	 * <code>null</code> if none are specified (indicating no additional
150
	 * properties specified for the build).
151
	 * 
152
	 * @param configuration
153
	 *            launch configuration
154
	 * @return map of properties (name --> value), or <code>null</code>
155
	 * @throws CoreException
156
	 *             if unable to access the associated attribute
157
	 */
158
	public static Map getProperties(ILaunchConfiguration configuration)
159
			throws CoreException {
160
		Map map = configuration.getAttribute(
161
				IAntLaunchConstants.ATTR_ANT_PROPERTIES,
162
				(Map) null);
163
		return map;
164
	}
165
166
	/**
167
	 * Returns a String specifying the Ant home to use for the build.
168
	 * 
169
	 * @param configuration
170
	 *            launch configuration
171
	 * @return String specifying Ant home to use or <code>null</code>
172
	 * @throws CoreException
173
	 *             if unable to access the associated attribute
174
	 */
175
	public static String getAntHome(ILaunchConfiguration configuration)
176
			throws CoreException {
177
		IRuntimeClasspathEntry[] entries = JavaRuntime
178
				.computeUnresolvedRuntimeClasspath(configuration);
179
		for (int i = 0; i < entries.length; i++) {
180
			IRuntimeClasspathEntry entry = entries[i];
181
			if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
182
				IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
183
				if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) {
184
					return ((AntHomeClasspathEntry) entry2).getAntHome();
185
				}
186
			}
187
		}
188
		return null;
189
	}
190
191
	/**
192
	 * Returns an array of property files to be used for the build, or
193
	 * <code>null</code> if none are specified (indicating no additional
194
	 * property files specified for the build).
195
	 * 
196
	 * @param configuration
197
	 *            launch configuration
198
	 * @return array of property file names, or <code>null</code>
199
	 * @throws CoreException
200
	 *             if unable to access the associated attribute
201
	 */
202
	public static String[] getPropertyFiles(ILaunchConfiguration configuration)
203
			throws CoreException {
204
		String attribute = configuration.getAttribute(
205
				IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES,
206
				(String) null);
207
		if (attribute == null) {
208
			return null;
209
		}
210
		String[] propertyFiles = AntLaunchingUtil.parseString(attribute, ","); //$NON-NLS-1$
211
		for (int i = 0; i < propertyFiles.length; i++) {
212
			String propertyFile = propertyFiles[i];
213
			propertyFile = expandVariableString(propertyFile,
214
					AntCoreModelMessages.AntUtil_6);
215
			propertyFiles[i] = propertyFile;
216
		}
217
		return propertyFiles;
218
	}
219
220
	/**
221
	 * Returns the list of URLs that define the custom classpath for the Ant
222
	 * build, or <code>null</code> if the global classpath is to be used.
223
	 * 
224
	 * @param config
225
	 *            launch configuration
226
	 * @return a list of <code>URL</code>
227
	 * 
228
	 * @throws CoreException
229
	 *             if file does not exist, IO problems, or invalid format.
230
	 */
231
	public static URL[] getCustomClasspath(ILaunchConfiguration config)
232
			throws CoreException {
233
		boolean useDefault = config.getAttribute(
234
				IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
235
		if (useDefault) {
236
			return null;
237
		}
238
		IRuntimeClasspathEntry[] unresolved = JavaRuntime
239
				.computeUnresolvedRuntimeClasspath(config);
240
		// don't consider bootpath entries
241
		List userEntries = new ArrayList(unresolved.length);
242
		for (int i = 0; i < unresolved.length; i++) {
243
			IRuntimeClasspathEntry entry = unresolved[i];
244
			if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
245
				userEntries.add(entry);
246
			}
247
		}
248
		IRuntimeClasspathEntry[] entries = JavaRuntime
249
				.resolveRuntimeClasspath(
250
						(IRuntimeClasspathEntry[]) userEntries
251
								.toArray(new IRuntimeClasspathEntry[userEntries
252
										.size()]), config);
253
		URL[] urls = new URL[entries.length];
254
		for (int i = 0; i < entries.length; i++) {
255
			IRuntimeClasspathEntry entry = entries[i];
256
			try {
257
				urls[i] = new URL("file:" + entry.getLocation()); //$NON-NLS-1$
258
			} catch (MalformedURLException e) {
259
				throw new CoreException(new Status(IStatus.ERROR, AntLaunching
260
						.getUniqueIdentifier(), AntLaunching.INTERNAL_ERROR,
261
						AntCoreModelMessages.AntUtil_7, e));
262
			}
263
		}
264
		return urls;
265
	}
266
267
	private static String expandVariableString(String variableString,
268
			String invalidMessage) throws CoreException {
269
		String expandedString = VariablesPlugin.getDefault()
270
				.getStringVariableManager().performStringSubstitution(
271
						variableString);
272
		if (expandedString == null || expandedString.length() == 0) {
273
			String msg = MessageFormat.format(invalidMessage,
274
					new String[] { variableString });
275
			throw new CoreException(new Status(IStatus.ERROR,
276
					AntLaunching.PLUGIN_ID, 0, msg, null));
277
		}
278
279
		return expandedString;
280
	}
281
282
	/**
283
	 * Returns the list of target names to run
284
	 * 
285
	 * @param extraAttibuteValue
286
	 *            the external tool's extra attribute value for the run targets
287
	 *            key.
288
	 * @return a list of target names
289
	 */
290
	public static String[] parseRunTargets(String extraAttibuteValue) {
291
		return parseString(extraAttibuteValue, ATTRIBUTE_SEPARATOR);
292
	}
293
294
	/**
295
	 * Returns the list of Strings that were delimiter separated.
296
	 * 
297
	 * @param delimString
298
	 *            the String to be tokenized based on the delimiter
299
	 * @return a list of Strings
300
	 */
301
	public static String[] parseString(String delimString, String delim) {
302
		if (delimString == null) {
303
			return new String[0];
304
		}
305
306
		// Need to handle case where separator character is
307
		// actually part of the target name!
308
		StringTokenizer tokenizer = new StringTokenizer(delimString, delim);
309
		String[] results = new String[tokenizer.countTokens()];
310
		for (int i = 0; i < results.length; i++) {
311
			results[i] = tokenizer.nextToken();
312
		}
313
314
		return results;
315
	}
316
317
	/**
318
	 * Returns an IFile with the given fully qualified path (relative to the
319
	 * workspace root). The returned IFile may or may not exist.
320
	 */
321
	public static IFile getFile(String fullPath) {
322
		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
323
		return root.getFile(new Path(fullPath));
324
	}
325
326
	/**
327
	 * Returns the workspace file associated with the given path in the local
328
	 * file system, or <code>null</code> if none. If the path happens to be a
329
	 * relative path, then the path is interpreted as relative to the specified
330
	 * parent file.
331
	 * 
332
	 * Attempts to handle linked files; the first found linked file with the
333
	 * correct path is returned.
334
	 * 
335
	 * @param path
336
	 * @param buildFileParent
337
	 * @return file or <code>null</code>
338
	 * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath)
339
	 */
340
	public static IFile getFileForLocation(String path, File buildFileParent) {
341
		if (path == null) {
342
			return null;
343
		}
344
		IPath filePath = new Path(path);
345
		IFile file = null;
346
		IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
347
				.findFilesForLocation(filePath);
348
		if (files.length > 0) {
349
			file = files[0];
350
		}
351
		if (file == null) {
352
			// relative path
353
			File relativeFile = null;
354
			try {
355
				// this call is ok if buildFileParent is null
356
				relativeFile = FileUtils.getFileUtils().resolveFile(
357
						buildFileParent, path);
358
				filePath = new Path(relativeFile.getAbsolutePath());
359
				files = ResourcesPlugin.getWorkspace().getRoot()
360
						.findFilesForLocation(filePath);
361
				if (files.length > 0) {
362
					file = files[0];
363
				} else {
364
					return null;
365
				}
366
			} catch (BuildException be) {
367
				return null;
368
			}
369
		}
370
371
		if (file.exists()) {
372
			return file;
373
		}
374
		File ioFile = file.getLocation().toFile();
375
		if (ioFile.exists()) {// needs to handle case insensitivity on WINOS
376
			try {
377
				files = ResourcesPlugin.getWorkspace().getRoot()
378
						.findFilesForLocation(
379
								new Path(ioFile.getCanonicalPath()));
380
				if (files.length > 0) {
381
					return files[0];
382
				}
383
			} catch (IOException e) {
384
			}
385
		}
386
387
		return null;
388
	}
389
390
	/**
391
	 * Migrates the classpath in the given configuration from the old format to
392
	 * the new format. The old format is not preserved. Instead, the default
393
	 * classpath will be used. However, ANT_HOME settings are preserved.
394
	 * 
395
	 * @param configuration
396
	 *            a configuration to migrate
397
	 * @throws CoreException
398
	 *             if unable to migrate
399
	 * @since 3.0
400
	 */
401
	public static void migrateToNewClasspathFormat(
402
			ILaunchConfiguration configuration) throws CoreException {
403
		String oldClasspath = configuration.getAttribute(
404
				AntLaunching.ATTR_ANT_CUSTOM_CLASSPATH,
405
				(String) null);
406
		String oldAntHome = configuration.getAttribute(
407
				AntLaunching.ATTR_ANT_HOME, (String) null);
408
		String provider = configuration.getAttribute(
409
				IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
410
				(String) null);
411
		if (oldClasspath != null || oldAntHome != null || provider == null) {
412
			ILaunchConfigurationWorkingCopy workingCopy = null;
413
			if (configuration.isWorkingCopy()) {
414
				workingCopy = (ILaunchConfigurationWorkingCopy) configuration;
415
			} else {
416
				workingCopy = configuration.getWorkingCopy();
417
			}
418
			workingCopy
419
					.setAttribute(
420
							AntLaunching.ATTR_ANT_CUSTOM_CLASSPATH,
421
							(String) null);
422
			workingCopy
423
					.setAttribute(
424
							AntLaunching.ATTR_ANT_HOME,
425
							(String) null);
426
			workingCopy.setAttribute(
427
					IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
428
					"org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
429
			workingCopy.setAttribute(
430
					IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
431
					true);
432
			if (oldAntHome != null) {
433
				IRuntimeClasspathEntry[] entries = JavaRuntime
434
						.computeUnresolvedRuntimeClasspath(workingCopy);
435
				List mementos = new ArrayList(entries.length);
436
				for (int i = 0; i < entries.length; i++) {
437
					IRuntimeClasspathEntry entry = entries[i];
438
					if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
439
						IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
440
						if (entry2.getTypeId().equals(
441
								AntHomeClasspathEntry.TYPE_ID)) {
442
							AntHomeClasspathEntry homeEntry = new AntHomeClasspathEntry(
443
									oldAntHome);
444
							mementos.add(homeEntry.getMemento());
445
							continue;
446
						}
447
					}
448
					mementos.add(entry.getMemento());
449
				}
450
				workingCopy
451
						.setAttribute(
452
								IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH,
453
								false);
454
				workingCopy.setAttribute(
455
						IJavaLaunchConfigurationConstants.ATTR_CLASSPATH,
456
						mementos);
457
			}
458
			workingCopy.doSave();
459
		}
460
	}
461
462
	public static boolean isSeparateJREAntBuild(
463
			ILaunchConfiguration configuration) {
464
		boolean separateJRE = true;
465
		try {
466
			// always null for same JRE
467
			separateJRE = configuration.getAttribute(
468
					IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
469
					(String) null) != null;
470
		} catch (CoreException e) {
471
			AntLaunching.log(AntCoreModelMessages.AntUtil_2, e);
472
		}
473
474
		return separateJRE;
475
	}
476
477
	public static void linkBuildFailedMessage(String message, IProcess process) {
478
		String fileName = null;
479
		String lineNumber = ""; //$NON-NLS-1$
480
		int fileStart = 0;
481
		int index = message.indexOf("xml"); //$NON-NLS-1$
482
		if (index > 0) {
483
			int numberStart = index + 4;
484
			int numberEnd = message.indexOf(':', numberStart);
485
			int fileEnd = index + 3;
486
			if (numberStart > 0 && fileEnd > 0) {
487
				fileName = message.substring(fileStart, fileEnd).trim();
488
				if (numberEnd > 0) {
489
					lineNumber = message.substring(numberStart, numberEnd)
490
							.trim();
491
				}
492
			}
493
		}
494
495
		if (fileName != null) {
496
			int num = -1;
497
			try {
498
				num = Integer.parseInt(lineNumber);
499
			} catch (NumberFormatException e) {
500
			}
501
			IFile[] files = ResourcesPlugin.getWorkspace().getRoot()
502
					.findFilesForLocation(new Path(fileName));
503
			IFile file = null;
504
			if (files.length > 0) {
505
				file = files[0];
506
			}
507
			if (file != null && file.exists()) {
508
				if (process != null) {
509
					ILaunch launch = null;
510
					if (process instanceof RemoteAntRuntimeProcess) {
511
						launch = ((RemoteAntRuntimeProcess) process)
512
								.getLaunch();
513
					} else if (process instanceof AntProcess) {
514
						launch = ((AntProcess) process).getLaunch();
515
					}
516
					if (launch != null) {
517
						((AntLaunch) launch).addLinkDescriptor(message,
518
								fileName, num, 0, message.length());
519
					}
520
				}
521
			}
522
		}
523
	}
524
}
(-)src/org/eclipse/ant/internal/launching/IAntLaunchingPreferenceConstants.java (+23 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
12
13
/**
14
 * Constants used to identify user preferences.
15
 */
16
public interface IAntLaunchingPreferenceConstants {
17
18
	 /**
19
     * int preference identifier constant which specifies the length of time to wait
20
     * to connect with the socket that communicates with the separate JRE to capture the output
21
     */
22
    public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$
23
}
(-)src/org/eclipse/ant/internal/launching/LinkDescriptor.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching;
12
13
/**
14
 * Stores detailed data of Link. Used to create linked messages.
15
 */
16
public class LinkDescriptor {
17
	String line;
18
	String fileName;
19
	int lineNumber;
20
	int offset;
21
	int length;
22
23
	public LinkDescriptor(String line, String fileName, int lineNumber,
24
			int offset, int length) {
25
		super();
26
		this.line = line;
27
		this.fileName = fileName;
28
		this.lineNumber = lineNumber;
29
		this.offset = offset;
30
		this.length = length;
31
	}
32
33
	public String getLine() {
34
		return line;
35
	}
36
37
	public void setLine(String line) {
38
		this.line = line;
39
	}
40
41
	public String getFileName() {
42
		return fileName;
43
	}
44
45
	public void setFileName(String fileName) {
46
		this.fileName = fileName;
47
	}
48
49
	public int getLineNumber() {
50
		return lineNumber;
51
	}
52
53
	public void setLineNumber(int lineNumber) {
54
		this.lineNumber = lineNumber;
55
	}
56
57
	public int getOffset() {
58
		return offset;
59
	}
60
61
	public void setOffset(int offset) {
62
		this.offset = offset;
63
	}
64
65
	public int getLength() {
66
		return length;
67
	}
68
69
	public void setLength(int length) {
70
		this.length = length;
71
	}
72
73
}
(-)src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.java (+23 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching.debug;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class AntDebugMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.debug.AntDebugMessages";//$NON-NLS-1$
16
    
17
	public static String AntSourceContainer_0;
18
19
	static {
20
		// load message values from bundle file
21
		NLS.initializeMessages(BUNDLE_NAME, AntDebugMessages.class);
22
	}
23
}
(-)src/org/eclipse/ant/internal/launching/debug/AntDebugMessages.properties (+12 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2005, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
AntSourceContainer_0=Ant Source Container
(-)src/org/eclipse/ant/internal/launching/debug/AntSourceContainer.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.debug;
13
14
import java.io.File;
15
import java.io.IOException;
16
import java.util.ArrayList;
17
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
25
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
26
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
27
28
public class AntSourceContainer extends AbstractSourceContainer {
29
30
	private IWorkspaceRoot fRoot;
31
32
	public AntSourceContainer() {
33
		fRoot = ResourcesPlugin.getWorkspace().getRoot();
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
38
	 */
39
	public Object[] findSourceElements(String path) throws CoreException {
40
		ArrayList sources = new ArrayList();
41
		File osFile = new File(path);
42
		if (osFile.exists()) {
43
			try {
44
				IPath canonicalPath = new Path(osFile.getCanonicalPath());
45
				IFile[] files = fRoot.findFilesForLocation(canonicalPath);
46
				if (files.length > 0) {
47
					for (int i = 0; i < files.length; i++) {
48
						sources.add(files[i]);
49
					}
50
				} else {
51
					sources.add(new LocalFileStorage(osFile));
52
				}
53
			} catch (IOException e) {
54
			}
55
		}
56
		return sources.toArray();
57
	}
58
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
61
	 */
62
	public String getName() {
63
		return AntDebugMessages.AntSourceContainer_0;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
68
     * Not persisted via the launch configuration
69
	 */
70
	public ISourceContainerType getType() {
71
		return null;
72
	}
73
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourceLookupDirector.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
15
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
16
17
/**
18
 * Ant source lookup director. For Ant source lookup there is one source
19
 * lookup participant. 
20
 */
21
public class AntSourceLookupDirector extends AbstractSourceLookupDirector {
22
	
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
25
	 */
26
	public void initializeParticipants() {
27
		addParticipants(new ISourceLookupParticipant[]{new AntSourceLookupParticipant()});
28
	}
29
30
    /* (non-Javadoc)
31
     * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
32
     */
33
    public String getMemento() throws CoreException {
34
        return null;
35
    }
36
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourceLookupParticipant.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
16
17
/**
18
 * The Ant source lookup participant knows how to translate a 
19
 * Ant stack frame into a source file name 
20
 */
21
public class AntSourceLookupParticipant extends AbstractSourceLookupParticipant {
22
	
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
25
	 */
26
	public String getSourceName(Object object) throws CoreException {
27
		if (object instanceof AntStackFrame) {
28
			return ((AntStackFrame)object).getFilePath();
29
		}
30
        if (object instanceof String) {
31
            // assume it's a file name
32
            return (String)object;
33
        }
34
		return null;
35
	}
36
}
(-)src/org/eclipse/ant/internal/launching/debug/AntSourcePathComputerDelegate.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
17
import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
18
19
/**
20
 * Computes the default source lookup path for an Ant launch configuration.
21
 * The default source lookup is a container that knows how to map the 
22
 * fully qualified file system paths to either the <code>IFile</code> within the workspace or
23
 * a <code>LocalFileStorage</code> for buildfiles not in the workspace.
24
 */
25
public class AntSourcePathComputerDelegate implements ISourcePathComputerDelegate {
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
29
	 */
30
	public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
31
		return new ISourceContainer[] {new AntSourceContainer()};
32
	}
33
}
(-)src/org/eclipse/ant/internal/launching/debug/IAntDebugConstants.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.debug;
13
14
public interface IAntDebugConstants {
15
	
16
	/**
17
	 * Unique identifier for the Ant debug model (value 
18
	 * <code>org.eclipse.ant.ui.debug</code>).
19
	 */
20
	public static final String ID_ANT_DEBUG_MODEL = "org.eclipse.ant.ui.debug"; //$NON-NLS-1$
21
	
22
	/**
23
	 * Unique identifier for the Ant line breakpoint markers 
24
	 * (value <code>org.eclipse.ant.ui.antLineBreakpointMarker</code>).
25
	 */
26
	public static final String ID_ANT_LINE_BREAKPOINT_MARKER= "org.eclipse.ant.ui.antLineBreakpointMarker"; //$NON-NLS-1$
27
    
28
    /**
29
     * Unique identifier for the Ant run to line breakpoints 
30
     * (value <code>org.eclipse.ant.ui.runToLineBreakpoint</code>).
31
     */
32
    public static final String ANT_RUN_TO_LINE= "org.eclipse.ant.ui.runToLineBreakpoint"; //$NON-NLS-1$
33
}
(-)src/org/eclipse/ant/internal/launching/debug/IAntDebugController.java (+66 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug;
12
13
import org.eclipse.debug.core.model.IBreakpoint;
14
15
public interface IAntDebugController {
16
	
17
    /**
18
     * Resume the Ant build
19
     */
20
	public void resume();
21
    
22
    /**
23
     * Suspend the Ant build
24
     */
25
	public void suspend();
26
    
27
     /**
28
     * Step into the current Ant task
29
     */
30
	public void stepInto();
31
    
32
     /**
33
     * Step over the current Ant task
34
     */
35
	public void stepOver();
36
    
37
    /**
38
     * The provided breakpoint has been added or removed depending on the <code>added</code> parameter.
39
     * Updates the controller for this change.
40
     * 
41
     * @param breakpoint the breakpoint that has been added or removed
42
     * @param added whether or not the breakpoint has been added 
43
     */
44
	public void handleBreakpoint(IBreakpoint breakpoint, boolean added);
45
    
46
     /**
47
     * Retrieve the properties of the Ant build.
48
     * May occur asynchronously depending on implementation.
49
     */
50
	public void getProperties();
51
    
52
    /**
53
     * Retrieve the stack frames of the Ant build.
54
     * May occur asynchronously depending on implementation.
55
     */
56
	public void getStackFrames();
57
58
	/**
59
	 * Some strings are escaped when marshalled for socket communication.
60
	 * The Ant debug controller will properly unescape these Strings if required.
61
	 * 
62
	 * @param value The buffer of the string to unescape
63
	 * @return The unescaped string
64
	 */
65
	public StringBuffer unescapeString(StringBuffer value);
66
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntDebugElement.java (+55 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
14
import org.eclipse.ant.internal.launching.AntLaunching;
15
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.debug.core.DebugException;
19
import org.eclipse.debug.core.model.DebugElement;
20
21
/**
22
 * Common function of Ant debug model elements
23
 */
24
public abstract class AntDebugElement extends DebugElement {
25
	
26
	/**
27
	 * Constructs a new debug element contained in the given
28
	 * debug target.
29
	 * 
30
	 * @param target debug target
31
	 */
32
	public AntDebugElement(AntDebugTarget target) {
33
		super(target);
34
	}
35
	
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
38
	 */
39
	public String getModelIdentifier() {
40
		return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
41
	}
42
    
43
	/**
44
     * Throws a debug exception with the given message, error code, and underlying
45
     * exception.
46
     */
47
    protected void throwDebugException(String message) throws DebugException {
48
        throw new DebugException(new Status(IStatus.ERROR, AntLaunching.getUniqueIdentifier(),
49
            DebugException.TARGET_REQUEST_FAILED, message, null));
50
    }
51
    
52
    protected AntDebugTarget getAntDebugTarget() {
53
        return (AntDebugTarget)super.getDebugTarget();
54
    }
55
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntDebugTarget.java (+463 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
16
17
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
18
import org.eclipse.ant.internal.launching.debug.IAntDebugController;
19
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
20
import org.eclipse.core.resources.IMarkerDelta;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.variables.VariablesPlugin;
23
import org.eclipse.debug.core.DebugEvent;
24
import org.eclipse.debug.core.DebugException;
25
import org.eclipse.debug.core.DebugPlugin;
26
import org.eclipse.debug.core.IBreakpointManager;
27
import org.eclipse.debug.core.IBreakpointManagerListener;
28
import org.eclipse.debug.core.IDebugEventSetListener;
29
import org.eclipse.debug.core.ILaunch;
30
import org.eclipse.debug.core.model.IBreakpoint;
31
import org.eclipse.debug.core.model.IDebugTarget;
32
import org.eclipse.debug.core.model.ILineBreakpoint;
33
import org.eclipse.debug.core.model.IMemoryBlock;
34
import org.eclipse.debug.core.model.IProcess;
35
import org.eclipse.debug.core.model.IThread;
36
37
/**
38
 * Ant Debug Target
39
 */
40
public class AntDebugTarget extends AntDebugElement implements IDebugTarget, IDebugEventSetListener, IBreakpointManagerListener {
41
	
42
	// associated system process (Ant Build)
43
	private IProcess fProcess;
44
	
45
	// containing launch object
46
	private ILaunch fLaunch;
47
	
48
	// Build file name
49
	private String fName;
50
51
	// suspend state
52
	private boolean fSuspended= false;
53
	
54
	// terminated state
55
	private boolean fTerminated= false;
56
	
57
	// threads
58
	private AntThread fThread;
59
	private IThread[] fThreads;
60
	
61
	private IAntDebugController fController;
62
    
63
    private List fRunToLineBreakpoints;
64
65
	/**
66
	 * Constructs a new debug target in the given launch for the 
67
	 * associated Ant build process.
68
	 * 
69
	 * @param launch containing launch
70
	 * @param process Ant build process
71
	 * @param controller the controller to communicate to the Ant build
72
	 */
73
	public AntDebugTarget(ILaunch launch, IProcess process, IAntDebugController controller) {
74
		super(null);
75
		fLaunch = launch;
76
		fProcess = process;
77
		
78
		fController= controller;
79
		
80
		fThread = new AntThread(this);
81
		fThreads = new IThread[] {fThread};
82
        
83
        DebugPlugin.getDefault().getBreakpointManager().addBreakpointManagerListener(this);
84
		DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
85
        DebugPlugin.getDefault().addDebugEventListener(this);
86
	}
87
	
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
90
	 */
91
	public IProcess getProcess() {
92
		return fProcess;
93
	}
94
	
95
	/* (non-Javadoc)
96
	 * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
97
	 */
98
	public IThread[] getThreads() {
99
		return fThreads;
100
	}
101
	
102
	/* (non-Javadoc)
103
	 * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
104
	 */
105
	public boolean hasThreads() throws DebugException {
106
		return !fTerminated && fThreads.length > 0;
107
	}
108
	
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.debug.core.model.IDebugTarget#getName()
111
	 */
112
	public String getName() throws DebugException {
113
		if (fName == null) {
114
			try {
115
				fName= getLaunch().getLaunchConfiguration().getAttribute(IExternalToolConstants.ATTR_LOCATION, DebugModelMessages.AntDebugTarget_0);
116
				fName= VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fName);
117
			} catch (CoreException e) {
118
				fName = DebugModelMessages.AntDebugTarget_0;
119
			}
120
		}
121
		return fName;
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
126
	 */
127
	public boolean supportsBreakpoint(IBreakpoint breakpoint) {
128
		if (breakpoint.getModelIdentifier().equals(IAntDebugConstants.ID_ANT_DEBUG_MODEL)) {
129
		    //need to consider all breakpoints as no way to tell which set
130
		    //of buildfiles will be executed (ant task)
131
		    return true;
132
		}
133
		return false;
134
	}
135
	
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
138
	 */
139
	public IDebugTarget getDebugTarget() {
140
		return this;
141
	}
142
	
143
	/* (non-Javadoc)
144
	 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
145
	 */
146
	public ILaunch getLaunch() {
147
		return fLaunch;
148
	}
149
	
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
152
	 */
153
	public boolean canTerminate() {
154
		return !fTerminated;
155
	}
156
	
157
	/* (non-Javadoc)
158
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
159
	 */
160
	public boolean isTerminated() {
161
		return fTerminated;
162
	}
163
	
164
	/* (non-Javadoc)
165
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
166
	 */
167
	public void terminate() throws DebugException {
168
	    terminated();
169
	}
170
	
171
	/* (non-Javadoc)
172
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
173
	 */
174
	public boolean canResume() {
175
		return !isTerminated() && isSuspended();
176
	}
177
	
178
	/* (non-Javadoc)
179
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
180
	 */
181
	public boolean canSuspend() {
182
		return !isTerminated() && !isSuspended();
183
	}
184
	
185
	/* (non-Javadoc)
186
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
187
	 */
188
	public boolean isSuspended() {
189
		return fSuspended;
190
	}
191
	
192
	/* (non-Javadoc)
193
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
194
	 */
195
	public void resume() throws DebugException {
196
	    fSuspended= false;
197
	    fController.resume();
198
	}
199
	
200
	/**
201
	 * Notification the target has suspended for the given reason
202
	 * 
203
	 * @param detail reason for the suspend
204
	 */
205
	public void suspended(int detail) {
206
		fSuspended = true;
207
		fThread.setStepping(false);
208
		fThread.fireSuspendEvent(detail);
209
	}	
210
	
211
	/* (non-Javadoc)
212
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
213
	 */
214
	public void suspend() throws DebugException {
215
		fController.suspend();
216
	}
217
	
218
	/* (non-Javadoc)
219
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
220
	 */
221
	public void breakpointAdded(IBreakpoint breakpoint) {
222
		fController.handleBreakpoint(breakpoint, true);
223
        if (breakpoint instanceof AntLineBreakpoint) {
224
            if (((AntLineBreakpoint) breakpoint).isRunToLine()) {
225
                if (fRunToLineBreakpoints == null) {
226
                    fRunToLineBreakpoints= new ArrayList();
227
                }
228
                fRunToLineBreakpoints.add(breakpoint);
229
            }
230
        }
231
	}
232
233
    /* (non-Javadoc)
234
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
235
	 */
236
	public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
237
		fController.handleBreakpoint(breakpoint, false);
238
        if (fRunToLineBreakpoints != null) {
239
            if (fRunToLineBreakpoints.remove(breakpoint) && fRunToLineBreakpoints.isEmpty()) {
240
                fRunToLineBreakpoints= null;
241
            }
242
        }
243
	}
244
	
245
	/* (non-Javadoc)
246
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
247
	 */
248
	public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
249
		if (supportsBreakpoint(breakpoint)) {
250
			try {
251
				if (breakpoint.isEnabled() && DebugPlugin.getDefault().getBreakpointManager().isEnabled()) {
252
					breakpointAdded(breakpoint);
253
				} else {
254
					breakpointRemoved(breakpoint, null);
255
				}
256
			} catch (CoreException e) {
257
			}
258
		}
259
	}
260
	
261
	/* (non-Javadoc)
262
	 * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
263
	 */
264
	public boolean canDisconnect() {
265
		return false;
266
	}
267
	
268
	/* (non-Javadoc)
269
	 * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
270
	 */
271
	public void disconnect() throws DebugException {
272
	}
273
	
274
	/* (non-Javadoc)
275
	 * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
276
	 */
277
	public boolean isDisconnected() {
278
		return false;
279
	}
280
	
281
	/* (non-Javadoc)
282
	 * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
283
	 */
284
	public boolean supportsStorageRetrieval() {
285
		return false;
286
	}
287
	
288
	/* (non-Javadoc)
289
	 * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
290
	 */
291
	public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException {
292
		return null;
293
	}
294
295
	/**
296
	 * Notification we have connected to the Ant build logger and it has started.
297
	 * Resume the build.
298
	 */
299
	public void buildStarted() {
300
		fireCreationEvent();
301
		installDeferredBreakpoints();
302
		try {
303
			resume();
304
		} catch (DebugException e) {
305
		}
306
	}
307
	
308
	/**
309
	 * Install breakpoints that are already registered with the breakpoint
310
	 * manager if the breakpoint manager is enabled and the breakpoint is enabled.
311
	 */
312
	private void installDeferredBreakpoints() {
313
		IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager();
314
		if (!manager.isEnabled()) {
315
			return;
316
		}
317
		IBreakpoint[] breakpoints = manager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
318
		for (int i = 0; i < breakpoints.length; i++) {
319
            IBreakpoint breakpoint= breakpoints[i];
320
            try {
321
                if (breakpoint.isEnabled()) {
322
                    breakpointAdded(breakpoints[i]);
323
                }
324
            } catch (CoreException e) {
325
            }
326
		}
327
	}
328
	
329
	/**
330
	 * Called when this debug target terminates.
331
	 */
332
	public void terminated() {
333
		fThreads= new IThread[0];
334
		fTerminated = true;
335
		fSuspended = false;
336
		if (DebugPlugin.getDefault() != null) {
337
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
338
			DebugPlugin.getDefault().removeDebugEventListener(this);
339
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointManagerListener(this);
340
		}
341
		if (!getProcess().isTerminated()) {
342
		    try {
343
                fProcess.terminate();
344
                resume();
345
		    } catch (DebugException e) {       
346
		    }
347
		}
348
		if (DebugPlugin.getDefault() != null) {
349
			fireTerminateEvent();
350
		}
351
	}
352
	
353
	/**
354
	 * Single step the Ant build.
355
	 * 
356
	 * @throws DebugException if the request fails
357
	 */
358
	public void stepOver() {
359
	    fSuspended= false;
360
		fController.stepOver();
361
	}
362
	
363
	/**
364
	 * Step-into the Ant build.
365
	 * 
366
	 * @throws DebugException if the request fails
367
	 */
368
	public void stepInto() {
369
	    fSuspended= false;
370
	    fController.stepInto();
371
	}
372
	
373
	/**
374
	 * Notification a breakpoint was encountered. Determine
375
	 * which breakpoint was hit and fire a suspend event.
376
	 * 
377
	 * @param event debug event
378
	 */
379
	public void breakpointHit(String event) {
380
		// determine which breakpoint was hit, and set the thread's breakpoint
381
		String[] datum= event.split(DebugMessageIds.MESSAGE_DELIMITER);
382
		String fileName= datum[1];
383
		int lineNumber = Integer.parseInt(datum[2]);
384
		IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
385
        boolean found= false;
386
		for (int i = 0; i < breakpoints.length; i++) {
387
           ILineBreakpoint lineBreakpoint = (ILineBreakpoint)breakpoints[i];
388
           if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) {
389
               found= true;
390
               break;
391
           }
392
		}
393
        if (!found && fRunToLineBreakpoints != null) {
394
            Iterator iter= fRunToLineBreakpoints.iterator();
395
            while (iter.hasNext()) {
396
                ILineBreakpoint lineBreakpoint = (ILineBreakpoint) iter.next();
397
                if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) {
398
                    break;
399
                }
400
            }
401
        }
402
		suspended(DebugEvent.BREAKPOINT);
403
	}	
404
    
405
    private boolean setThreadBreakpoint(ILineBreakpoint lineBreakpoint, int lineNumber, String fileName) {
406
        try {
407
            if (lineBreakpoint.getLineNumber() == lineNumber && 
408
                    fileName.equals(lineBreakpoint.getMarker().getResource().getLocation().toOSString())) {
409
                fThread.setBreakpoints(new IBreakpoint[]{lineBreakpoint});
410
                return true;
411
            }
412
        } catch (CoreException e) {
413
        }
414
        return false;
415
    }
416
	
417
    public void breakpointHit (IBreakpoint breakpoint) {
418
        fThread.setBreakpoints(new IBreakpoint[]{breakpoint});
419
        suspended(DebugEvent.BREAKPOINT);
420
    }
421
    
422
	public void getStackFrames() {
423
		fController.getStackFrames();
424
	}
425
	
426
	public void getProperties() {
427
		fController.getProperties();
428
	}
429
430
    /* (non-Javadoc)
431
     * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
432
     */
433
    public void handleDebugEvents(DebugEvent[] events) {
434
        for (int i = 0; i < events.length; i++) {
435
            DebugEvent event = events[i];
436
            if (event.getKind() == DebugEvent.TERMINATE && event.getSource().equals(fProcess)) {
437
                terminated();
438
            }
439
        }
440
    }
441
    
442
    /**
443
     * When the breakpoint manager disables, remove all registered breakpoints
444
     * requests from the VM. When it enables, reinstall them.
445
     *
446
     * @see org.eclipse.debug.core.IBreakpointManagerListener#breakpointManagerEnablementChanged(boolean)
447
     */
448
    public void breakpointManagerEnablementChanged(boolean enabled) {
449
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
450
        for (int i = 0; i < breakpoints.length; i++) {
451
            IBreakpoint breakpoint = breakpoints[i];
452
            if (enabled) {
453
                breakpointAdded(breakpoint);
454
            } else {
455
                breakpointRemoved(breakpoint, null);
456
            }
457
        }
458
    }
459
460
	public IAntDebugController getAntDebugController() {
461
		return fController;
462
	}   
463
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntLineBreakpoint.java (+112 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import com.ibm.icu.text.MessageFormat;
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
18
import org.eclipse.core.resources.IMarker;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IWorkspaceRunnable;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugPlugin;
25
import org.eclipse.debug.core.model.IBreakpoint;
26
import org.eclipse.debug.core.model.LineBreakpoint;
27
28
/**
29
 * Ant line breakpoint
30
 */
31
public class AntLineBreakpoint extends LineBreakpoint {
32
	
33
	/**
34
	 * Default constructor is required for the breakpoint manager
35
	 * to re-create persisted breakpoints. After instantiating a breakpoint,
36
	 * the <code>setMarker(...)</code> method is called to restore
37
	 * this breakpoint's attributes.
38
	 */
39
	public AntLineBreakpoint() {
40
	}
41
	
42
	/**
43
	 * Constructs a line breakpoint on the given resource at the given
44
	 * line number. The line number is 1-based (i.e. the first line of a
45
	 * file is line number 1).
46
	 * 
47
	 * @param resource file on which to set the breakpoint
48
	 * @param lineNumber 1-based line number of the breakpoint
49
	 * @throws CoreException if unable to create the breakpoint
50
	 */
51
	public AntLineBreakpoint(IResource resource, int lineNumber) throws CoreException {
52
	    this(resource, lineNumber, new HashMap(), true);
53
	}
54
	
55
	/**
56
	 * Constructs a line breakpoint on the given resource at the given
57
	 * line number. The line number is 1-based (i.e. the first line of a
58
	 * file is line number 1).
59
	 * 
60
	 * @param resource file on which to set the breakpoint
61
	 * @param lineNumber 1-based line number of the breakpoint
62
	 * @param attributes the marker attributes to set
63
	 * @param register whether to add this breakpoint to the breakpoint manager
64
	 * @throws CoreException if unable to create the breakpoint
65
	 */
66
	public AntLineBreakpoint(final IResource resource, final int lineNumber, final Map attributes, final boolean register) throws CoreException {
67
	    IWorkspaceRunnable wr= new IWorkspaceRunnable() {
68
			public void run(IProgressMonitor monitor) throws CoreException {
69
			    IMarker marker = resource.createMarker(IAntDebugConstants.ID_ANT_LINE_BREAKPOINT_MARKER);
70
			    setMarker(marker);
71
			    attributes.put(IBreakpoint.ENABLED, Boolean.TRUE);
72
			    attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
73
			    attributes.put(IBreakpoint.ID, IAntDebugConstants.ID_ANT_DEBUG_MODEL);
74
                attributes.put(IMarker.MESSAGE, MessageFormat.format(DebugModelMessages.AntLineBreakpoint_0, new String[] {Integer.toString(lineNumber)}));
75
			    ensureMarker().setAttributes(attributes);
76
                
77
                register(register);
78
			}
79
	    };
80
	    run(getMarkerRule(resource), wr);
81
	}
82
	
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
85
	 */
86
	public String getModelIdentifier() {
87
		return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
88
	}
89
90
    /**
91
     * @return whether this breakpoint is a run to line breakpoint
92
     */
93
    public boolean isRunToLine() {
94
        try {
95
            return ensureMarker().getAttribute(IAntDebugConstants.ANT_RUN_TO_LINE, false);
96
        } catch (DebugException e) {
97
           return false;
98
        }
99
    }
100
    
101
    /**
102
     * Add this breakpoint to the breakpoint manager,
103
     * or sets it as unregistered.
104
     */
105
    private void register(boolean register) throws CoreException {
106
        if (register) {
107
            DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
108
        } else {
109
            setRegistered(false);
110
        }
111
    }
112
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntProperties.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
public class AntProperties extends AntDebugElement implements IVariable {
18
	
19
	private IValue fValue;
20
	private String fName;
21
    private boolean fValid= true;
22
23
	public AntProperties(AntDebugTarget target, String name) {
24
		super(target);
25
		fName= name;
26
	}
27
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.debug.core.model.IVariable#getValue()
30
	 */
31
	public synchronized IValue getValue() throws DebugException {
32
        int attempts= 0;
33
        while (!fValid && !getDebugTarget().isTerminated()) {
34
            try {
35
                wait(50);
36
            } catch (InterruptedException e) {
37
            }
38
            if (attempts == 20 && !fValid && !getDebugTarget().isTerminated()) {
39
                throwDebugException(DebugModelMessages.AntProperties_1);
40
            }
41
            attempts++;
42
        }
43
 		return fValue;
44
	}
45
    
46
    public IValue getLastValue() {
47
        return fValue;
48
    }
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.debug.core.model.IVariable#getName()
52
	 */
53
	public String getName() {
54
		return fName;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
59
	 */
60
	public String getReferenceTypeName() {
61
		return ""; //$NON-NLS-1$
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
66
	 */
67
	public boolean hasValueChanged() {
68
		return false;
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
73
	 */
74
	public void setValue(String expression) {
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
79
	 */
80
	public void setValue(IValue value) {
81
		fValue= value;
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
86
	 */
87
	public boolean supportsValueModification() {
88
		return false;
89
	}
90
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
93
	 */
94
	public boolean verifyValue(String expression) {
95
		return false;
96
	}
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
100
	 */
101
	public boolean verifyValue(IValue value) {
102
		return false;
103
	}
104
105
    public synchronized void setValid(boolean valid) {
106
        fValid= valid;        
107
        notifyAll();
108
    }
109
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntPropertiesValue.java (+71 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Brock Janiczak (brockj@tpg.com.au) - bug 154907
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.launching.debug.model;
13
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.List;
17
import org.eclipse.debug.core.model.IValue;
18
import org.eclipse.debug.core.model.IVariable;
19
20
public class AntPropertiesValue extends AntDebugElement implements IValue {
21
	
22
	private List fProperties= new ArrayList();
23
	
24
	public AntPropertiesValue(AntDebugTarget target) {
25
		super(target);
26
	}
27
	
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
30
	 */
31
	public String getReferenceTypeName() {
32
		return ""; //$NON-NLS-1$
33
	}
34
	
35
	/* (non-Javadoc)
36
	 * @see org.eclipse.debug.core.model.IValue#getValueString()
37
	 */
38
	public String getValueString() {
39
		return ""; //$NON-NLS-1$
40
	}
41
	
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.debug.core.model.IValue#isAllocated()
44
	 */
45
	public boolean isAllocated() {
46
		return true;
47
	}
48
	
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.debug.core.model.IValue#getVariables()
51
	 */
52
	public IVariable[] getVariables() {
53
		Collections.sort(fProperties);
54
		return (IVariable[])fProperties.toArray(new IVariable[fProperties.size()]);
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.model.IValue#hasVariables()
59
	 */
60
	public boolean hasVariables() {
61
		return true;
62
	}
63
	
64
	protected void addProperties(List properties) {
65
		fProperties.addAll(properties);
66
	}
67
68
	public List getProperties() {
69
		return fProperties;
70
	}
71
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntProperty.java (+121 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Brock Janiczak (brockj@tpg.com.au) - bug 154907
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.launching.debug.model;
13
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
/**
18
 * A property in an Ant build.
19
 */
20
public class AntProperty extends AntDebugElement implements IVariable, Comparable {
21
22
	private String fName;
23
	private AntValue fValue;
24
    private String fLabel;
25
	
26
	/**
27
	 * Constructs a variable associated with the debug target
28
	 * with the given name and value.
29
	 * 
30
	 * @param target the debug target
31
	 * @param name property name
32
	 * @param value property value
33
	 */
34
	public AntProperty(AntDebugTarget target, String name, String value) {
35
		super(target);
36
		fName = name;
37
		fValue= new AntValue(target, value);
38
	}
39
	
40
	/*
41
	 * @see org.eclipse.debug.core.model.IVariable#getValue()
42
	 */
43
	public IValue getValue() {
44
		return fValue;
45
	}
46
	
47
	/*
48
	 * @see org.eclipse.debug.core.model.IVariable#getName()
49
	 */
50
	public String getName() {
51
		return fName;
52
	}
53
	
54
	/*
55
	 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
56
	 */
57
	public String getReferenceTypeName() {
58
		return ""; //$NON-NLS-1$
59
	}
60
	
61
	/*
62
	 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
63
	 */
64
	public boolean hasValueChanged() {
65
		return false;
66
	}
67
	
68
	/*
69
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
70
	 */
71
	public void setValue(String expression) {
72
	}
73
	
74
	/*
75
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
76
	 */
77
	public void setValue(IValue value) {
78
	}
79
	
80
	/*
81
	 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
82
	 */
83
	public boolean supportsValueModification() {
84
		return false;
85
	}
86
	
87
	/*
88
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
89
	 */
90
	public boolean verifyValue(String expression) {
91
		return false;
92
	}
93
	
94
	/*
95
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
96
	 */
97
	public boolean verifyValue(IValue value) {
98
		return false;
99
	}
100
101
    /**
102
     * @return the text used to render this property
103
     */
104
    public String getText() {
105
        if (fLabel == null) {
106
            StringBuffer buffer= new StringBuffer(getName());
107
            buffer.append("= "); //$NON-NLS-1$
108
            buffer.append(fValue.getValueString());          
109
            fLabel=  buffer.toString();
110
        } 
111
        return fLabel;
112
    }
113
    
114
    /*
115
     * @see java.lang.Comparable#compareTo(java.lang.Object)
116
     */
117
    public int compareTo(Object other) {
118
    	AntProperty otherProperty = (AntProperty) other;
119
    	return fName.compareToIgnoreCase(otherProperty.getName());
120
    }
121
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntStackFrame.java (+314 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.debug.core.DebugException;
17
import org.eclipse.debug.core.model.IRegisterGroup;
18
import org.eclipse.debug.core.model.IStackFrame;
19
import org.eclipse.debug.core.model.IThread;
20
import org.eclipse.debug.core.model.IVariable;
21
22
/**
23
 * Ant stack frame.
24
 */
25
public class AntStackFrame extends AntDebugElement implements IStackFrame {
26
	
27
	private AntThread fThread;
28
	private String fName;
29
	private int fLineNumber;
30
	private String fFilePath;
31
	private int fId;
32
    private String fFullPath;
33
	
34
	/**
35
	 * Constructs a stack frame in the given thread with the given id.
36
	 * 
37
	 * @param antThread
38
	 * @param id stack frame id (0 is the top of the stack)
39
	 */
40
	public AntStackFrame(AntThread antThread, int id, String name, String fullPath, int lineNumber) {
41
		super((AntDebugTarget) antThread.getDebugTarget());
42
		fId = id;
43
		fThread = antThread;
44
		fLineNumber= lineNumber;
45
		fName= name;
46
		setFilePath(fullPath);
47
	}
48
	
49
	public void setId(int id) {
50
		fId= id;
51
	}
52
	
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.debug.core.model.IStackFrame#getThread()
55
	 */
56
	public IThread getThread() {
57
		return fThread;
58
	}
59
	
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
62
	 */
63
	public IVariable[] getVariables() throws DebugException {
64
	   return fThread.getVariables();
65
	}
66
67
    /* (non-Javadoc)
68
	 * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
69
	 */
70
	public boolean hasVariables() {
71
		return isSuspended();
72
	}
73
	
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
76
	 */
77
	public int getLineNumber() {
78
		return fLineNumber;
79
	}
80
	
81
	public void setLineNumber(int lineNumber) {
82
		fLineNumber= lineNumber;
83
	}
84
	
85
	public void setFilePath(String fullPath) {
86
        fFullPath= fullPath;
87
        IFile file= AntLaunchingUtil.getFileForLocation(fullPath, null);
88
        if (file != null) {
89
            fFilePath= file.getProjectRelativePath().toString();
90
        } else {
91
            fFilePath= new Path(fullPath).lastSegment();
92
        }
93
	}
94
	
95
	public String getFilePath() {
96
		return fFullPath;
97
	}
98
	
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
101
	 */
102
	public int getCharStart() {
103
		return -1;
104
	}
105
	
106
	/* (non-Javadoc)
107
	 * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
108
	 */
109
	public int getCharEnd() {
110
		return -1;
111
	}
112
	
113
	/* (non-Javadoc)
114
	 * @see org.eclipse.debug.core.model.IStackFrame#getName()
115
	 */
116
	public String getName() {
117
		return fName;
118
	}
119
	
120
	public void setName(String name) {
121
		fName= name;
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
126
	 */
127
	public IRegisterGroup[] getRegisterGroups() {
128
		return null;
129
	}
130
	
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
133
	 */
134
	public boolean hasRegisterGroups() {
135
		return false;
136
	}
137
	
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.debug.core.model.IStep#canStepInto()
140
	 */
141
	public boolean canStepInto() {
142
		return getThread().canStepInto();
143
	}
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.debug.core.model.IStep#canStepOver()
147
	 */
148
	public boolean canStepOver() {
149
		return getThread().canStepOver();
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
154
	 */
155
	public boolean canStepReturn() {
156
		return getThread().canStepReturn();
157
	}
158
	
159
	/* (non-Javadoc)
160
	 * @see org.eclipse.debug.core.model.IStep#isStepping()
161
	 */
162
	public boolean isStepping() {
163
		return getThread().isStepping();
164
	}
165
	
166
	/* (non-Javadoc)
167
	 * @see org.eclipse.debug.core.model.IStep#stepInto()
168
	 */
169
	public void stepInto() throws DebugException {
170
		getThread().stepInto();
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.debug.core.model.IStep#stepOver()
175
	 */
176
	public void stepOver() throws DebugException {
177
		getThread().stepOver();
178
	}
179
	
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.debug.core.model.IStep#stepReturn()
182
	 */
183
	public void stepReturn() throws DebugException {
184
		getThread().stepReturn();
185
	}
186
	
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
189
	 */
190
	public boolean canResume() {
191
		return getThread().canResume();
192
	}
193
	
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
196
	 */
197
	public boolean canSuspend() {
198
		return getThread().canSuspend();
199
	}
200
	
201
	/* (non-Javadoc)
202
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
203
	 */
204
	public boolean isSuspended() {
205
		return getThread().isSuspended();
206
	}
207
	
208
	/* (non-Javadoc)
209
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
210
	 */
211
	public void resume() throws DebugException {
212
		getThread().resume();
213
	}
214
	
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
217
	 */
218
	public void suspend() throws DebugException {
219
		getThread().suspend();
220
	}
221
	
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
224
	 */
225
	public boolean canTerminate() {
226
		return getThread().canTerminate();
227
	}
228
	
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
231
	 */
232
	public boolean isTerminated() {
233
		return getThread().isTerminated();
234
	}
235
	
236
	/* (non-Javadoc)
237
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
238
	 */
239
	public void terminate() throws DebugException {
240
		getThread().terminate();
241
	}
242
	
243
	/**
244
	 * Returns the name of the buildfile this stack frame is associated
245
	 * with.
246
	 * 
247
	 * @return the name of the buildfile this stack frame is associated
248
	 * with
249
	 */
250
	public String getSourceName() {
251
		return fFilePath;
252
	}
253
	
254
	/* (non-Javadoc)
255
	 * @see java.lang.Object#equals(java.lang.Object)
256
	 */
257
	public boolean equals(Object obj) {
258
		if (obj instanceof AntStackFrame) {
259
			AntStackFrame sf = (AntStackFrame)obj;
260
			if (getSourceName() != null) {
261
				return getSourceName().equals(sf.getSourceName()) &&
262
					sf.getLineNumber() == getLineNumber() &&
263
					sf.fId == fId;
264
			} 
265
			return sf.fId == fId;
266
		}
267
		return false;
268
	}
269
	
270
	/* (non-Javadoc)
271
	 * @see java.lang.Object#hashCode()
272
	 */
273
	public int hashCode() {
274
	    if (getSourceName() == null) {
275
	        return fId;
276
	    }
277
	    return getSourceName().hashCode() + fId;
278
	}
279
	
280
	/**
281
	 * Returns this stack frame's unique identifier within its thread
282
	 * 
283
	 * @return this stack frame's unique identifier within its thread
284
	 */
285
	protected int getIdentifier() {
286
		return fId;
287
	}
288
    
289
    /**
290
     * Returns the system, user or runtime property
291
     * name, or <code>null</code> if unable to resolve a property with the name.
292
     *
293
     * @param propertyName the name of the variable to search for
294
     * @return a property, or <code>null</code> if none
295
     */
296
    public AntProperty findProperty(String propertyName) {
297
        try {
298
            IVariable[] groups= getVariables();
299
            for (int i = 0; i < groups.length; i++) {
300
                AntProperties propertiesGrouping = (AntProperties) groups[i];
301
                AntPropertiesValue value= (AntPropertiesValue) propertiesGrouping.getValue();
302
                IVariable[] properties= value.getVariables();
303
                for (int j = 0; j < properties.length; j++) {
304
                    AntProperty property = (AntProperty) properties[j];
305
                    if (property.getName().equals(propertyName)) {
306
                        return property;
307
                    }
308
                }
309
            }
310
        } catch (DebugException e) {
311
        }
312
        return null;
313
    } 
314
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntThread.java (+479 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.debug.core.DebugEvent;
17
import org.eclipse.debug.core.DebugException;
18
import org.eclipse.debug.core.model.IBreakpoint;
19
import org.eclipse.debug.core.model.IStackFrame;
20
import org.eclipse.debug.core.model.IThread;
21
import org.eclipse.debug.core.model.IVariable;
22
23
/**
24
 * An Ant build thread.
25
 */
26
public class AntThread extends AntDebugElement implements IThread {
27
	
28
	/**
29
	 * Breakpoints this thread is suspended at or <code>null</code>
30
	 * if none.
31
	 */
32
	private IBreakpoint[] fBreakpoints;
33
	
34
	/**
35
	 * The stackframes associated with this thread
36
	 */
37
	private List fFrames= new ArrayList(1);
38
	
39
	/**
40
	 * The stackframes to be reused on suspension
41
	 */
42
	private List fOldFrames;
43
	
44
	/**
45
	 * Whether this thread is stepping
46
	 */
47
	private boolean fStepping = false;
48
	
49
	private boolean fRefreshProperties= true;
50
	
51
	/**
52
	 * The user properties associated with this thread
53
	 */
54
	private AntProperties fUserProperties;
55
	
56
	/**
57
	 * The system properties associated with this thread
58
	 */
59
	private AntProperties fSystemProperties;
60
	
61
	/**
62
	 * The properties set during the build associated with this thread
63
	 */
64
	private AntProperties fRuntimeProperties;
65
    
66
    private Object fPropertiesLock= new Object();
67
	
68
	/**
69
	 * Constructs a new thread for the given target
70
	 * 
71
	 * @param target the Ant Build
72
	 */
73
	public AntThread(AntDebugTarget target) {
74
		super(target);
75
	}
76
	
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.model.IThread#getStackFrames()
79
	 */
80
	public synchronized IStackFrame[] getStackFrames() throws DebugException {
81
		if (isSuspended()) {
82
			if (fFrames.size() == 0) {
83
				getStackFrames0();
84
			}
85
		} 
86
		
87
		return (IStackFrame[]) fFrames.toArray(new IStackFrame[fFrames.size()]);
88
	}
89
	
90
	/**
91
	 * Retrieves the current stack frames in the thread
92
	 * possibly waiting until the frames are populated
93
     * 
94
	 */
95
	private void getStackFrames0() throws DebugException {
96
        synchronized (fFrames) {
97
    		getAntDebugTarget().getStackFrames();
98
            if (fFrames.size() > 0) {
99
                //frames set..no need to wait
100
                return;
101
            }
102
            int attempts= 0;
103
    		try {
104
                while (fFrames.size() == 0 && !isTerminated()) {
105
                    fFrames.wait(50);
106
                    if (attempts == 20 && fFrames.size() == 0 && !isTerminated()) {
107
                        throwDebugException(DebugModelMessages.AntThread_3);
108
                    }
109
                    attempts++;
110
                }
111
    		} catch (InterruptedException e) {
112
    		}
113
        }
114
	}
115
	
116
	/* (non-Javadoc)
117
	 * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
118
	 */
119
	public boolean hasStackFrames() throws DebugException {
120
		return isSuspended();
121
	}
122
	
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.debug.core.model.IThread#getPriority()
125
	 */
126
	public int getPriority() throws DebugException {
127
		return 0;
128
	}
129
	
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
132
	 */
133
	public synchronized IStackFrame getTopStackFrame() throws DebugException {
134
		if (isSuspended()) {
135
			if (fFrames.size() == 0) {
136
				getStackFrames0();
137
			}
138
			if (fFrames.size() > 0) {
139
				return (IStackFrame)fFrames.get(0);
140
			}
141
		} 
142
		return null;
143
	}
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.debug.core.model.IThread#getName()
147
	 */
148
	public String getName() {
149
		return "Thread [Ant Build]"; //$NON-NLS-1$
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
154
	 */
155
	public IBreakpoint[] getBreakpoints() {
156
		if (fBreakpoints == null) {
157
			return new IBreakpoint[0];
158
		}
159
		return fBreakpoints;
160
	}
161
	
162
	/**
163
	 * Sets the breakpoints this thread is suspended at, or <code>null</code>
164
	 * if none.
165
	 * 
166
	 * @param breakpoints the breakpoints this thread is suspended at, or <code>null</code>
167
	 * if none
168
	 */
169
	protected void setBreakpoints(IBreakpoint[] breakpoints) {
170
		fBreakpoints = breakpoints;
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
175
	 */
176
	public boolean canResume() {
177
		return isSuspended();
178
	}
179
	
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
182
	 */
183
	public boolean canSuspend() {
184
		return !isSuspended();
185
	}
186
	
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
189
	 */
190
	public boolean isSuspended() {
191
		return getDebugTarget().isSuspended();
192
	}
193
	
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
196
	 */
197
	public synchronized void resume() throws DebugException {
198
		aboutToResume(DebugEvent.CLIENT_REQUEST, false);
199
		getDebugTarget().resume();
200
	}
201
	
202
	/* (non-Javadoc)
203
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
204
	 */
205
	public synchronized void suspend() throws DebugException {
206
		getDebugTarget().suspend();
207
	}
208
	
209
	/* (non-Javadoc)
210
	 * @see org.eclipse.debug.core.model.IStep#canStepInto()
211
	 */
212
	public boolean canStepInto() {
213
	    return isSuspended();
214
	}
215
	
216
	/* (non-Javadoc)
217
	 * @see org.eclipse.debug.core.model.IStep#canStepOver()
218
	 */
219
	public boolean canStepOver() {
220
		return isSuspended();
221
	}
222
	
223
	/* (non-Javadoc)
224
	 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
225
	 */
226
	public boolean canStepReturn() {
227
		return false;
228
	}
229
	
230
	/* (non-Javadoc)
231
	 * @see org.eclipse.debug.core.model.IStep#isStepping()
232
	 */
233
	public boolean isStepping() {
234
		return fStepping;
235
	}
236
	
237
	/* (non-Javadoc)
238
	 * @see org.eclipse.debug.core.model.IStep#stepInto()
239
	 */
240
	public synchronized void stepInto() throws DebugException {
241
	    aboutToResume(DebugEvent.STEP_INTO, true);
242
		((AntDebugTarget)getDebugTarget()).stepInto();
243
	}
244
	
245
	private void aboutToResume(int detail, boolean stepping) {
246
	    fRefreshProperties= true;
247
	    fOldFrames= new ArrayList(fFrames);
248
        fFrames.clear();
249
        setPropertiesValid(false);
250
	    setStepping(stepping);
251
	    setBreakpoints(null);
252
		fireResumeEvent(detail);
253
    }
254
255
    private void setPropertiesValid(boolean valid) {
256
        if (fUserProperties != null) {
257
            fUserProperties.setValid(valid);
258
            fSystemProperties.setValid(valid);
259
            fRuntimeProperties.setValid(valid);
260
        }
261
    }
262
263
    /* (non-Javadoc)
264
	 * @see org.eclipse.debug.core.model.IStep#stepOver()
265
	 */
266
	public synchronized void stepOver() throws DebugException {
267
	    aboutToResume(DebugEvent.STEP_OVER, true);
268
		((AntDebugTarget)getDebugTarget()).stepOver();
269
	}
270
	
271
	/* (non-Javadoc)
272
	 * @see org.eclipse.debug.core.model.IStep#stepReturn()
273
	 */
274
	public synchronized void stepReturn() throws DebugException {
275
	}
276
	
277
	/* (non-Javadoc)
278
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
279
	 */
280
	public boolean canTerminate() {
281
		return !isTerminated();
282
	}
283
	
284
	/* (non-Javadoc)
285
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
286
	 */
287
	public boolean isTerminated() {
288
		return getDebugTarget().isTerminated();
289
	}
290
	
291
	/* (non-Javadoc)
292
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
293
	 */
294
	public void terminate() throws DebugException {
295
		fFrames.clear();
296
		getDebugTarget().terminate();
297
	}
298
	
299
	/**
300
	 * Sets whether this thread is stepping
301
	 * 
302
	 * @param stepping whether stepping
303
	 */
304
	protected void setStepping(boolean stepping) {
305
		fStepping = stepping;
306
	}
307
308
    public void buildStack(String data) { 
309
        synchronized (fFrames) {
310
            String[] strings= data.split(DebugMessageIds.MESSAGE_DELIMITER);
311
            //0 STACK message
312
            //1 targetName
313
            //2 taskName
314
            //3 filePath
315
            //4 lineNumber
316
            //5 ...
317
            if (fOldFrames != null && (strings.length - 1)/ 4 != fOldFrames.size()) {
318
                fOldFrames= null; //stack size changed..do not preserve
319
            }
320
            StringBuffer name;
321
            String filePath;
322
            int lineNumber;
323
            int stackFrameId= 0;
324
            String taskName;
325
            for (int i = 1; i < strings.length; i++) {
326
                if (strings[i].length() > 0) {
327
                    name= new StringBuffer(strings[i]);
328
                    taskName= strings[++i];
329
                    if (taskName.length() > 0) {
330
                        name.append(": "); //$NON-NLS-1$
331
                        name.append(taskName);
332
                    }
333
                } else {
334
                    name= new StringBuffer(strings[++i]);
335
                }
336
                filePath= strings[++i];
337
                lineNumber= Integer.parseInt(strings[++i]);
338
                addFrame(stackFrameId++, name.toString(), filePath, lineNumber);
339
            }
340
            //wake up the call from getStackFrames
341
            fFrames.notifyAll();
342
        }
343
    }
344
    
345
    private void addFrame(int stackFrameId, String name, String filePath, int lineNumber) {
346
    	AntStackFrame frame= getOldFrame();
347
    	
348
    	if (frame == null || !frame.getFilePath().equals(filePath)) {
349
    		frame= new AntStackFrame(this, stackFrameId, name, filePath, lineNumber);
350
    	} else {
351
    		frame.setFilePath(filePath);
352
    		frame.setId(stackFrameId);
353
    		frame.setLineNumber(lineNumber);
354
    		frame.setName(name);
355
    	}
356
		fFrames.add(frame);
357
    }
358
    
359
    private AntStackFrame getOldFrame() {
360
    	if (fOldFrames == null) {
361
    		return null;
362
    	}
363
    	AntStackFrame frame= (AntStackFrame) fOldFrames.remove(0);
364
    	if (fOldFrames.isEmpty()) {
365
    		fOldFrames= null;
366
    	}
367
    	return frame;
368
    }
369
    
370
    public void newProperties(String data) {
371
        synchronized (fPropertiesLock) {
372
            try {
373
                String[] datum= data.split(DebugMessageIds.MESSAGE_DELIMITER);
374
                if (fUserProperties == null) {
375
                    initializePropertyGroups();
376
                }
377
378
                List userProperties= ((AntPropertiesValue)fUserProperties.getLastValue()).getProperties();
379
                List systemProperties= ((AntPropertiesValue)fSystemProperties.getLastValue()).getProperties();
380
                List runtimeProperties= ((AntPropertiesValue)fRuntimeProperties.getLastValue()).getProperties();
381
                //0 PROPERTIES message
382
                //1 propertyName length
383
                //2 propertyName
384
                //3 propertyValue length
385
                //3 propertyValue
386
                //4 propertyType
387
                //5 ...
388
                if (datum.length > 1) { //new properties
389
                    StringBuffer propertyName;
390
                    StringBuffer propertyValue;
391
                    int propertyNameLength;
392
                    int propertyValueLength;
393
                    for (int i = 1; i < datum.length; i++) {
394
                        propertyNameLength= Integer.parseInt(datum[i]);
395
                        propertyName= new StringBuffer(datum[++i]);
396
                        while (propertyName.length() != propertyNameLength) {
397
                            propertyName.append(DebugMessageIds.MESSAGE_DELIMITER);
398
                            propertyName.append(datum[++i]);
399
                        }
400
401
                        propertyName= getAntDebugTarget().getAntDebugController().unescapeString(propertyName);
402
403
                        propertyValueLength= Integer.parseInt(datum[++i]);
404
                        if (propertyValueLength == 0 && i + 1 == datum.length) { //bug 81299
405
                            propertyValue= new StringBuffer(""); //$NON-NLS-1$
406
                        } else {
407
                            propertyValue= new StringBuffer(datum[++i]);
408
                        }
409
                        while (propertyValue.length() != propertyValueLength) {
410
                            propertyValue.append(DebugMessageIds.MESSAGE_DELIMITER);
411
                            propertyValue.append(datum[++i]);
412
                        }
413
414
                        propertyValue= getAntDebugTarget().getAntDebugController().unescapeString(propertyValue);
415
416
                        int propertyType= Integer.parseInt(datum[++i]);
417
                        addProperty(userProperties, systemProperties, runtimeProperties, propertyName.toString(), propertyValue.toString(), propertyType);
418
                    }
419
                }
420
            } finally {
421
                fRefreshProperties= false;
422
                setPropertiesValid(true);
423
                //wake up the call from getVariables
424
                fPropertiesLock.notifyAll();
425
            }
426
        }
427
	}
428
429
	private void addProperty(List userProperties, List systemProperties, List runtimeProperties, String propertyName, String propertyValue, int propertyType) {
430
		AntProperty property= new AntProperty((AntDebugTarget) getDebugTarget(), propertyName, propertyValue);
431
		switch (propertyType) {
432
			case DebugMessageIds.PROPERTY_SYSTEM:
433
				systemProperties.add(property);
434
				break;
435
			case DebugMessageIds.PROPERTY_USER:
436
				userProperties.add(property);
437
				break;
438
			case DebugMessageIds.PROPERTY_RUNTIME:
439
				runtimeProperties.add(property);
440
				break;
441
		}
442
	}
443
444
	private void initializePropertyGroups() {
445
        AntDebugTarget target= getAntDebugTarget();
446
		fUserProperties= new AntProperties(target, DebugModelMessages.AntThread_0);
447
		fUserProperties.setValue(new AntPropertiesValue(target));
448
		fSystemProperties= new AntProperties(target, DebugModelMessages.AntThread_1);
449
		fSystemProperties.setValue(new AntPropertiesValue(target));
450
		fRuntimeProperties= new AntProperties(target, DebugModelMessages.AntThread_2);
451
		fRuntimeProperties.setValue(new AntPropertiesValue(target));
452
	}
453
    
454
    protected IVariable[] getVariables() throws DebugException {
455
        synchronized (fPropertiesLock) {
456
            if (fRefreshProperties) {
457
                getAntDebugTarget().getProperties();
458
                if (fRefreshProperties) { 
459
                    //properties have not been set; need to wait
460
                    try {
461
                        int attempts= 0;
462
                        while (fRefreshProperties && !isTerminated()) {
463
                            fPropertiesLock.wait(50);
464
                            if (attempts == 20 && fRefreshProperties && !isTerminated()) {
465
                                throwDebugException(DebugModelMessages.AntThread_4);
466
                            }
467
                            attempts++;
468
                        }
469
                    } catch (InterruptedException ie) {
470
                    }
471
                }
472
            }
473
            if (fSystemProperties == null) {
474
                return new IVariable[0];
475
            }
476
            return new IVariable[]{fSystemProperties, fUserProperties, fRuntimeProperties};
477
        }
478
    }
479
}
(-)src/org/eclipse/ant/internal/launching/debug/model/AntValue.java (+71 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
public class AntValue extends AntDebugElement implements IValue  {
18
19
    private String fValueString;
20
    protected static final IVariable[] EMPTY = new IVariable[0];
21
    
22
    /**
23
     * @param target
24
     */
25
    public AntValue(AntDebugTarget target, String value) {
26
        super(target);
27
        fValueString= value;
28
    }
29
30
    /* (non-Javadoc)
31
     * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
32
     */
33
    public String getReferenceTypeName() {
34
        return ""; //$NON-NLS-1$
35
    }
36
37
    /* (non-Javadoc)
38
     * @see org.eclipse.debug.core.model.IValue#getValueString()
39
     */
40
    public String getValueString() {
41
        return fValueString;
42
    }
43
44
    /* (non-Javadoc)
45
     * @see org.eclipse.debug.core.model.IValue#isAllocated()
46
     */
47
    public boolean isAllocated() {
48
        return true;
49
    }
50
51
    /* (non-Javadoc)
52
     * @see org.eclipse.debug.core.model.IValue#getVariables()
53
     */
54
    public IVariable[] getVariables() {
55
        return EMPTY;
56
    }
57
58
    /* (non-Javadoc)
59
     * @see org.eclipse.debug.core.model.IValue#hasVariables()
60
     */
61
    public boolean hasVariables() {
62
        return false;
63
    }
64
65
    /* (non-Javadoc)
66
     * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
67
     */
68
    public String getModelIdentifier() {
69
        return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
70
    }
71
}
(-)src/org/eclipse/ant/internal/launching/debug/model/DebugMessageIds.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.debug.model;
12
13
14
public class DebugMessageIds {
15
	
16
	public final static String MESSAGE_DELIMITER= ","; //$NON-NLS-1$
17
	
18
	public final static String BUILD_STARTED=   "build_started"; //$NON-NLS-1$
19
	public final static String TARGET_STARTED= "target_started"; //$NON-NLS-1$
20
	public final static String TARGET_FINISHED= "target_finished"; //$NON-NLS-1$
21
	public final static String TASK_STARTED= "task_started"; //$NON-NLS-1$
22
	public final static String TASK_FINISHED= "task_finished"; //$NON-NLS-1$
23
	
24
	public final static String STEP= "step"; //$NON-NLS-1$
25
	public final static String STEP_OVER= "step_over"; //$NON-NLS-1$
26
	public final static String STEP_INTO= "step_into"; //$NON-NLS-1$
27
	
28
	public final static String TERMINATE= "terminate"; //$NON-NLS-1$
29
	public final static String TERMINATED= "terminated"; //$NON-NLS-1$
30
	public final static String SUSPEND= "suspend"; //$NON-NLS-1$
31
	public final static String SUSPENDED= "suspended"; //$NON-NLS-1$
32
	public final static String RESUME= "resume"; //$NON-NLS-1$
33
	
34
	public final static String STACK= "stack"; //$NON-NLS-1$
35
	
36
	public final static String ADD_BREAKPOINT= "add"; //$NON-NLS-1$
37
	public final static String REMOVE_BREAKPOINT= "remove"; //$NON-NLS-1$
38
	
39
	public final static String CLIENT_REQUEST= "client"; //$NON-NLS-1$
40
	public final static String BREAKPOINT= "breakpoint"; //$NON-NLS-1$
41
	
42
	public final static String PROPERTIES= "prop"; //$NON-NLS-1$
43
	public final static String PROPERTY_VALUE= "value"; //$NON-NLS-1$
44
	public final static int PROPERTY_USER= 0;
45
	public final static int PROPERTY_SYSTEM= 1;
46
	public final static int PROPERTY_RUNTIME= 2;
47
}
(-)src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.java (+32 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.launching.debug.model;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class DebugModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.debug.model.DebugModelMessages";//$NON-NLS-1$
16
17
	public static String AntDebugTarget_0;
18
19
	public static String AntLineBreakpoint_0;
20
	public static String AntThread_0;
21
	public static String AntThread_1;
22
	public static String AntThread_2;
23
    public static String AntThread_3;
24
    public static String AntThread_4;
25
    
26
    public static String AntProperties_1;
27
    
28
	static {
29
		// load message values from bundle file
30
		NLS.initializeMessages(BUNDLE_NAME, DebugModelMessages.class);
31
	}
32
}
(-)src/org/eclipse/ant/internal/launching/debug/model/DebugModelMessages.properties (+21 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2004, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
AntDebugTarget_0=Ant Build
13
14
AntLineBreakpoint_0=Ant breakpoint [line: {0}]
15
AntThread_0=User Properties
16
AntThread_1=System Properties
17
AntThread_2=Runtime Properties
18
AntThread_3=Request to retrieve Ant stack frames failed
19
AntThread_4=Request to retrieve Ant properties failed
20
21
AntProperties_1=Request to Ant properties value failed
(-)src/org/eclipse/ant/internal/launching/debug/model/RemoteAntDebugBuildListener.java (+321 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.debug.model;
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.InputStreamReader;
17
import java.io.PrintWriter;
18
import java.net.Socket;
19
import java.net.UnknownHostException;
20
21
import org.eclipse.ant.internal.launching.AntLaunching;
22
import org.eclipse.ant.internal.launching.debug.IAntDebugController;
23
import org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.DebugEvent;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.model.IBreakpoint;
29
import org.eclipse.debug.core.model.ILineBreakpoint;
30
import org.eclipse.debug.core.model.IProcess;
31
32
public class RemoteAntDebugBuildListener extends RemoteAntBuildListener implements IAntDebugController {
33
	
34
	// sockets to communicate with the remote Ant debug build logger
35
	private Socket fRequestSocket;
36
	private PrintWriter fRequestWriter;
37
	private BufferedReader fResponseReader;
38
	
39
	private int fRequestPort= -1;
40
	private Thread fReaderThread;
41
	
42
	private AntDebugTarget fTarget;
43
	
44
	/**
45
	 * Reader thread that processes request responses from the remote Ant debug build logger
46
	 */
47
	private class ReaderThread extends Thread {
48
		public ReaderThread() {
49
			super("Ant Request Response Reader Thread"); //$NON-NLS-1$
50
			setDaemon(true);
51
		}
52
53
		public void run(){
54
			try { 
55
				String message= null; 
56
				while (fResponseReader != null) { 
57
				    synchronized (RemoteAntDebugBuildListener.this) {
58
				        if (fResponseReader != null && (message= fResponseReader.readLine()) != null) {
59
				            receiveMessage(message);
60
				        }
61
				    }
62
				} 
63
			} catch (IOException ie) { //the other end has shutdown
64
				RemoteAntDebugBuildListener.this.shutDown();
65
			} catch (Exception e) {
66
				AntLaunching.log("Internal error processing remote response", e); //$NON-NLS-1$
67
				RemoteAntDebugBuildListener.this.shutDown();
68
			}
69
		}
70
	}	
71
	
72
	public RemoteAntDebugBuildListener(ILaunch launch) {
73
		super(launch);
74
		//fDebug= true;
75
	}
76
	
77
	protected void receiveMessage(String message) {
78
		if (message.startsWith(DebugMessageIds.BUILD_STARTED)) {
79
			buildStarted();
80
		} else if (message.startsWith(DebugMessageIds.SUSPENDED)){
81
			handleSuspendMessage(message);
82
		} else if (message.startsWith(DebugMessageIds.TERMINATED)){
83
			fTarget.terminated();
84
		} else if (message.startsWith(DebugMessageIds.STACK)){
85
			AntThread thread= (AntThread) fTarget.getThreads()[0];
86
			thread.buildStack(message);
87
		} else if (message.startsWith(DebugMessageIds.PROPERTIES)){
88
		    AntThread thread= (AntThread) fTarget.getThreads()[0];
89
		    thread.newProperties(message);
90
		} else {
91
			super.receiveMessage(message);
92
		}
93
	}
94
95
    private void handleSuspendMessage(String message) {
96
        if (message.endsWith(DebugMessageIds.CLIENT_REQUEST)) {
97
        	fTarget.suspended(DebugEvent.CLIENT_REQUEST);
98
        } else if (message.endsWith(DebugMessageIds.STEP)) {
99
        	fTarget.suspended(DebugEvent.STEP_END);
100
        } else if (message.indexOf(DebugMessageIds.BREAKPOINT) >= 0) {
101
        	fTarget.breakpointHit(message);
102
        }
103
    }
104
105
    private void buildStarted() {
106
        IProcess process= getProcess();
107
        while(process == null) {
108
        	try {
109
        		synchronized (this) {
110
        			wait(400);
111
        		}
112
        		process= getProcess();
113
        	} catch (InterruptedException ie) {
114
        	}
115
        }
116
        fTarget= new AntDebugTarget(fLaunch, process, this);
117
        fLaunch.addDebugTarget(fTarget);
118
        
119
        if (!connectRequest()) {
120
			RemoteAntDebugBuildListener.this.shutDown();
121
			return;
122
        }
123
        
124
        fTarget.buildStarted();
125
    }
126
127
    private boolean connectRequest() {
128
    	Exception exception= null;
129
    	for (int i= 1; i < 20; i++) {
130
    		try {
131
    			fRequestSocket = new Socket("localhost", fRequestPort); //$NON-NLS-1$
132
    			fRequestWriter = new PrintWriter(fRequestSocket.getOutputStream(), true);
133
    			fResponseReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
134
    			
135
    			fReaderThread= new ReaderThread();
136
    			fReaderThread.start();
137
    			return true;
138
    		} catch (UnknownHostException e) {
139
    			exception= e;
140
    			break;
141
    		} catch (IOException e) {
142
    			exception= e;
143
    		}
144
    		try {
145
				Thread.sleep(500);
146
			} catch(InterruptedException e) {
147
			}
148
    	}
149
    	AntLaunching.log("Internal error attempting to connect to debug target", exception); //$NON-NLS-1$
150
    	return false;
151
	}
152
153
	/**
154
	 * Start listening to an Ant build. Start a server connection that
155
	 * the RemoteAntDebugBuildLogger can connect to.
156
	 * 
157
	 * @param eventPort The port number to create the server connection on
158
     * @param requestPort The port number to use for sending requests to the remote logger
159
	 */
160
	public synchronized void startListening(int eventPort, int requestPort) {
161
		super.startListening(eventPort);
162
		fRequestPort= requestPort;
163
	}
164
	
165
	/**
166
	 * Sends a request to the Ant build
167
	 * 
168
	 * @param request debug command
169
	 */
170
	protected void sendRequest(String request) {
171
		if (fRequestSocket == null) {
172
			return;
173
		}
174
		synchronized (fRequestSocket) {
175
			fRequestWriter.println(request);
176
		}		
177
	}
178
	
179
	protected synchronized void shutDown() {
180
        if (fTarget != null) {
181
            fTarget.terminated();
182
            fTarget= null;
183
        }
184
		fLaunch= null;
185
		if (DebugPlugin.getDefault() != null) {
186
			DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
187
		}
188
		try {
189
			if (fReaderThread != null)   {
190
				// interrupt reader thread so that we don't block on close
191
				// on a lock held by the BufferedReader
192
				// see bug: 38955
193
				fReaderThread.interrupt();
194
			}
195
			if (fResponseReader != null) {
196
				fResponseReader.close();
197
				fResponseReader= null;
198
			}
199
		} catch(IOException e) {
200
		}	
201
		if (fRequestWriter != null) {
202
			fRequestWriter.close();
203
			fRequestWriter= null;
204
		}
205
		try{
206
			if(fRequestSocket != null) {
207
				fRequestSocket.close();
208
				fRequestSocket= null;
209
			}
210
		} catch(IOException e) {
211
		}
212
		super.shutDown();
213
	}
214
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#resume()
217
	 */
218
	public void resume() {
219
		sendRequest(DebugMessageIds.RESUME);
220
	}
221
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#suspend()
224
	 */
225
	public void suspend() {
226
		sendRequest(DebugMessageIds.SUSPEND);
227
	}
228
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepInto()
231
	 */
232
	public void stepInto() {
233
		sendRequest(DebugMessageIds.STEP_INTO);
234
	}
235
236
	/* (non-Javadoc)
237
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepOver()
238
	 */
239
	public void stepOver() {
240
		sendRequest(DebugMessageIds.STEP_OVER);
241
	}
242
243
	/* (non-Javadoc)
244
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#handleBreakpoint(IBreakpoint, boolean)
245
	 */
246
	public void handleBreakpoint(IBreakpoint breakpoint, boolean add) {
247
		if (fTarget == null || !fTarget.supportsBreakpoint(breakpoint)) {
248
			return;
249
		}
250
		StringBuffer message= new StringBuffer();
251
		if (add) {
252
			try {
253
				if (!breakpoint.isEnabled()) {
254
					return;
255
				}
256
			} catch (CoreException e) {
257
				AntLaunching.log(e);
258
				return;
259
			}
260
			message.append(DebugMessageIds.ADD_BREAKPOINT);
261
		} else {
262
			message.append(DebugMessageIds.REMOVE_BREAKPOINT);
263
		}
264
		message.append(DebugMessageIds.MESSAGE_DELIMITER);
265
		message.append(breakpoint.getMarker().getResource().getLocation().toOSString());
266
		message.append(DebugMessageIds.MESSAGE_DELIMITER);
267
		try {
268
			message.append(((ILineBreakpoint)breakpoint).getLineNumber());
269
			sendRequest(message.toString());
270
		} catch (CoreException ce) {
271
			AntLaunching.log(ce);
272
		}
273
	}
274
275
	/* (non-Javadoc)
276
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getProperties()
277
	 */
278
	public void getProperties() {
279
		sendRequest(DebugMessageIds.PROPERTIES);
280
	}
281
282
	/* (non-Javadoc)
283
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getStackFrames()
284
	 */
285
	public void getStackFrames() {
286
		sendRequest(DebugMessageIds.STACK);
287
	}
288
289
	/* (non-Javadoc)
290
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#unescapeString(java.lang.StringBuffer)
291
	 */
292
	public StringBuffer unescapeString(StringBuffer property) {
293
		if (property.indexOf("\\r") == -1 && property.indexOf("\\n") == -1) { //$NON-NLS-1$ //$NON-NLS-2$
294
			return property;
295
		}
296
		for (int i= 0; i < property.length(); i++) {
297
			if ('\\' == property.charAt(i)) {
298
				String newString= ""; //$NON-NLS-1$
299
				if ('r' == property.charAt(i + 1)) {
300
					if (i-1 > - 1 && '\\' == property.charAt(i-1)) {
301
						newString= "r"; //$NON-NLS-1$
302
					} else {
303
						newString+= '\r';
304
					}
305
				} else if ('n' == property.charAt(i + 1)) {
306
					if (i-1 > - 1 && '\\' == property.charAt(i-1)) {
307
						newString= "n"; //$NON-NLS-1$
308
					} else {
309
						newString+= '\n';
310
					}
311
					
312
				}
313
				if (newString.length() > 0) {
314
					property.replace(i, i + 2, newString);
315
				}
316
			}
317
		}
318
319
		return property;
320
	}
321
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntClasspathProvider.java (+50 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
21
import org.eclipse.jdt.launching.JavaRuntime;
22
import org.eclipse.jdt.launching.StandardClasspathProvider;
23
24
public class AntClasspathProvider extends StandardClasspathProvider {
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
28
	 */
29
	public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
30
		boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
31
		if (useDefault) {
32
			List rtes = new ArrayList(10);
33
			IRuntimeClasspathEntry jreEntry = null;
34
			try {
35
				jreEntry = JavaRuntime.computeJREEntry(configuration);
36
			} catch (CoreException e) {
37
				// not a java project
38
			}
39
			if (jreEntry == null) {
40
				jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
41
						JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
42
			}
43
			rtes.add(jreEntry);
44
			rtes.add(new AntHomeClasspathEntry());
45
			rtes.add(new ContributedClasspathEntriesEntry());
46
			return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
47
		}
48
		return super.computeUnresolvedClasspath(configuration);
49
	}
50
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntHomeClasspathEntry.java (+210 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import java.io.File;
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.ant.core.AntCorePlugin;
18
import org.eclipse.ant.core.AntCorePreferences;
19
import org.eclipse.ant.core.IAntClasspathEntry;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
25
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
26
import org.eclipse.jdt.launching.JavaRuntime;
27
import org.w3c.dom.Document;
28
import org.w3c.dom.Element;
29
30
import com.ibm.icu.text.MessageFormat;
31
32
/**
33
 * A classpath entry that contains a set of archives for a particular
34
 * ANT_HOME.
35
 * 
36
 * @since 3.0 
37
 */
38
public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry {
39
	
40
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$
41
	
42
	/**
43
	 * Local path on disk where Ant Home is located or <code>null</code>
44
	 * to indicate the use of the default Ant Home.
45
	 */
46
	private String antHomeLocation = null;
47
	
48
	/**
49
	 * Creates an AntHome entry for the default AntHome installation.
50
	 */
51
	public AntHomeClasspathEntry() {
52
		antHomeLocation = null;
53
	}
54
	
55
	/**
56
	 * Constructs an AntHome entry for the Ant installed at the specified
57
	 * root directory.
58
	 * 
59
	 * @param antHome path in the local file system to an Ant installation
60
	 */
61
	public AntHomeClasspathEntry(String antHome) {
62
		antHomeLocation = antHome;
63
	}
64
		
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
67
	 */
68
	protected void buildMemento(Document document, Element memento) throws CoreException {
69
		if (antHomeLocation == null) {
70
			memento.setAttribute("default", "true");  //$NON-NLS-1$//$NON-NLS-2$
71
		} else {
72
			memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$
73
		}
74
	}
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
77
	 */
78
	public void initializeFrom(Element memento) throws CoreException {
79
		String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$
80
		if (antHome != null && (antHome.length() > 0)) {
81
			IPath path = new Path(antHome);
82
			antHomeLocation = path.toOSString();
83
		} else {
84
			antHomeLocation = null;
85
		}
86
	}
87
	/* (non-Javadoc)
88
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
89
	 */
90
	public String getTypeId() {
91
		return TYPE_ID;
92
	}
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
95
	 */
96
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
97
		List libs = new ArrayList(40);
98
		AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences();
99
		if (antHomeLocation == null) {
100
			IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries();
101
			for (int i = 0; i < entries.length; i++) {
102
				IAntClasspathEntry entry = entries[i];
103
				libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
104
			}
105
		} else {
106
			File lib= resolveAntHome();
107
			IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
108
			String[] fileNames = lib.list();
109
			for (int i = 0; i < fileNames.length; i++) {
110
				String name = fileNames[i];
111
				IPath path = new Path(name);
112
				String fileExtension = path.getFileExtension();
113
				if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$
114
					libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path)));
115
				}
116
			}
117
		}
118
		return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]);
119
	}
120
	
121
	public File resolveAntHome() throws CoreException {
122
		if (antHomeLocation == null) { //using the default ant home
123
			return null;
124
		}
125
		IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
126
		File lib= libDir.toFile();
127
		File parentDir= lib.getParentFile();
128
		if (parentDir == null || !parentDir.exists()) {
129
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null);
130
		}
131
		if (!lib.exists() || !lib.isDirectory()) {
132
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null);
133
		}
134
		return lib;
135
	}
136
	
137
	/* (non-Javadoc)
138
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
139
	 */
140
	public String getName() {
141
		if (antHomeLocation == null) {
142
			return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8;
143
		}
144
		return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation});
145
	}
146
	
147
	/* (non-Javadoc)
148
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
149
	 */
150
	public int getType() {
151
		return IRuntimeClasspathEntry.OTHER;
152
	}
153
	
154
	/* (non-Javadoc)
155
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
156
	 */
157
	public boolean isComposite() {
158
		return true;
159
	}
160
	
161
	/* (non-Javadoc)
162
	 * @see java.lang.Object#equals(java.lang.Object)
163
	 */
164
	public boolean equals(Object obj) {
165
		return obj instanceof AntHomeClasspathEntry &&
166
		  equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation);
167
	}
168
	
169
	/**
170
	 * Return whether s1 is equivalent to s2.
171
	 * 
172
	 * @param s1
173
	 * @param s2
174
	 * @return whether s1 is equivalent to s2
175
	 */
176
	private boolean equalsOrNull(String s1, String s2) {
177
		if (s1 == null || s2 == null) {
178
			return s1 == s2;
179
		} 
180
		return s1.equalsIgnoreCase(s2);
181
	}
182
183
	/* (non-Javadoc)
184
	 * @see java.lang.Object#hashCode()
185
	 */
186
	public int hashCode() {
187
		return getClass().hashCode();
188
	}	
189
	
190
	/**
191
	 * Sets the ant home to use.
192
	 * 
193
	 * @param path path to toor of an ant home installation
194
	 */
195
	public void setAntHome(String path) {
196
		antHomeLocation = path;
197
	}
198
	
199
	/**
200
	 * Returns the ant home location
201
	 * 
202
	 * @return path to root ant installation directory
203
	 */
204
	public String getAntHome() {
205
		if (antHomeLocation == null) {
206
			return AntCorePlugin.getPlugin().getPreferences().getAntHome();
207
		}
208
		return antHomeLocation;
209
	}
210
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntJavaLaunchDelegate.java (+47 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
17
import org.eclipse.jdt.launching.JavaLaunchDelegate;
18
19
/**
20
 * Used by the AntLaunchDelegate for Ant builds in a separate VM
21
 * The subclassing is needed to be able to launch an Ant build from a non-Java project
22
 */
23
public class AntJavaLaunchDelegate extends JavaLaunchDelegate {
24
	/* (non-Javadoc)
25
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#preLaunchCheck(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
26
	 */
27
	public boolean preLaunchCheck(ILaunchConfiguration configuration,String mode, IProgressMonitor monitor) throws CoreException {
28
		try {
29
			return super.preLaunchCheck(configuration, mode, monitor);
30
		} catch (CoreException ce) {
31
			//likely dealing with a non-Java project
32
		}
33
		//no need to check for breakpoints as always in run mode
34
		return true;
35
	}
36
	
37
	/* (non-Javadoc)
38
	 * @see org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration)
39
	 */
40
	public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
41
		try {
42
			return super.getProgramArguments(configuration);
43
		} catch (CoreException ce) {
44
		}
45
		return configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$
46
	}
47
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.java (+37 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 * dakshinamurthy.karra@gmail.com - bug 165371
10
 **********************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.osgi.util.NLS;
14
15
public class AntLaunchConfigurationMessages extends NLS {
16
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchConfigurationMessages";//$NON-NLS-1$
17
18
	public static String AntLaunchDelegate_Launching__0__1;
19
	public static String AntLaunchDelegate_Running__0__2;
20
	public static String AntLaunchDelegate_Build_In_Progress;
21
	public static String AntLaunchDelegate_Failure;
22
	public static String AntLaunchDelegate_22;
23
	public static String AntLaunchDelegate_23;
24
	public static String AntLaunchDelegate_28;
25
26
	public static String AntHomeClasspathEntry_8;
27
	public static String AntHomeClasspathEntry_9;
28
	public static String AntHomeClasspathEntry_10;
29
	public static String AntHomeClasspathEntry_11;
30
31
	public static String ContributedClasspathEntriesEntry_1;
32
33
	static {
34
		// load message values from bundle file
35
		NLS.initializeMessages(BUNDLE_NAME, AntLaunchConfigurationMessages.class);
36
	}
37
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchConfigurationMessages.properties (+26 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
#     dakshinamurthy.karra@gmail.com - bug 165371
11
###############################################################################
12
13
AntLaunchDelegate_Launching__0__1=Launching {0}
14
AntLaunchDelegate_Running__0__2=Running {0}
15
AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE.
16
AntLaunchDelegate_Failure=Failure of Background Ant Build
17
AntLaunchDelegate_22=&Do not show error dialog when Ant build fails
18
AntLaunchDelegate_23=Ant Build Failed
19
AntLaunchDelegate_28=Waiting for virtual machine to exit...
20
21
AntHomeClasspathEntry_8=Ant Home (Default)
22
AntHomeClasspathEntry_9=Ant Home ({0})
23
AntHomeClasspathEntry_10=Ant Home {0} does not exist
24
AntHomeClasspathEntry_11=Ant Home {0} does not contain a "lib" directory
25
26
ContributedClasspathEntriesEntry_1=Additional Tasks & Support
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntLaunchDelegate.java (+888 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Juan A. Hernandez - bug 89926
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.ant.internal.launching.launchConfigurations;
14
15
import java.io.File;
16
import java.io.IOException;
17
import java.net.URL;
18
import java.util.HashMap;
19
import java.util.Iterator;
20
import java.util.List;
21
import java.util.Map;
22
23
import org.apache.tools.ant.ProjectHelper;
24
import org.eclipse.ant.core.AntCorePlugin;
25
import org.eclipse.ant.core.AntCorePreferences;
26
import org.eclipse.ant.core.AntRunner;
27
import org.eclipse.ant.core.Property;
28
import org.eclipse.ant.core.Task;
29
import org.eclipse.ant.core.Type;
30
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
31
import org.eclipse.ant.internal.launching.AntLaunch;
32
import org.eclipse.ant.internal.launching.AntLaunching;
33
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
34
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
35
import org.eclipse.ant.internal.launching.debug.model.RemoteAntDebugBuildListener;
36
import org.eclipse.ant.launching.IAntLaunchConstants;
37
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
38
import org.eclipse.core.externaltools.internal.launchConfigurations.BackgroundResourceRefresher;
39
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
40
import org.eclipse.core.resources.IProject;
41
import org.eclipse.core.runtime.CoreException;
42
import org.eclipse.core.runtime.FileLocator;
43
import org.eclipse.core.runtime.IPath;
44
import org.eclipse.core.runtime.IProgressMonitor;
45
import org.eclipse.core.runtime.IStatus;
46
import org.eclipse.core.runtime.Path;
47
import org.eclipse.core.runtime.Platform;
48
import org.eclipse.core.runtime.Status;
49
import org.eclipse.core.runtime.SubProgressMonitor;
50
import org.eclipse.core.variables.VariablesPlugin;
51
import org.eclipse.debug.core.DebugEvent;
52
import org.eclipse.debug.core.DebugPlugin;
53
import org.eclipse.debug.core.IBreakpointManager;
54
import org.eclipse.debug.core.IDebugEventSetListener;
55
import org.eclipse.debug.core.ILaunch;
56
import org.eclipse.debug.core.ILaunchConfiguration;
57
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
58
import org.eclipse.debug.core.ILaunchManager;
59
import org.eclipse.debug.core.RefreshUtil;
60
import org.eclipse.debug.core.model.IBreakpoint;
61
import org.eclipse.debug.core.model.IProcess;
62
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
63
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
64
import org.eclipse.jdt.launching.IVMInstall;
65
import org.eclipse.jdt.launching.JavaRuntime;
66
import org.eclipse.jdt.launching.SocketUtil;
67
import org.eclipse.osgi.service.resolver.BundleDescription;
68
import org.osgi.framework.Bundle;
69
70
import com.ibm.icu.text.MessageFormat;
71
72
/**
73
 * Launch delegate for Ant builds
74
 */
75
public class AntLaunchDelegate extends LaunchConfigurationDelegate {
76
77
	private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.launching.runtime.logger.AntProcessBuildLogger"; //$NON-NLS-1$
78
	private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.launching.runtime.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$
79
	private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.launching.runtime.logger.NullBuildLogger"; //$NON-NLS-1$
80
	private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.launching.remote.logger.RemoteAntBuildLogger"; //$NON-NLS-1$
81
	private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.launching.remote.logger.RemoteAntDebugBuildLogger"; //$NON-NLS-1$
82
	private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
83
	private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$
84
	private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$
85
86
	private static final IProject[] NO_PROJECTS = new IProject[0];
87
88
	/**
89
	 * String attribute identifying the build scope for a launch configuration.
90
	 * <code>null</code> indicates the default workspace build.
91
	 */
92
	private static final String ATTR_BUILD_SCOPE = AntLaunching
93
			.getUniqueIdentifier()
94
			+ ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
95
96
	/**
97
	 * Attribute identifier specifying whether referenced projects should be
98
	 * considered when computing the projects to build. Default value is
99
	 * <code>true</code>.
100
	 */
101
	private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntLaunching
102
			.getUniqueIdentifier()
103
			+ ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
104
105
	private static String fgSWTLibraryLocation;
106
107
	private String fMode;
108
	ILaunchManager launchManager;
109
110
	private boolean fUserSpecifiedLogger = false;
111
112
	private String getProgramArguments(ILaunchConfiguration configuration)
113
			throws CoreException {
114
		String arguments = configuration.getAttribute(
115
				IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
116
		return VariablesPlugin.getDefault().getStringVariableManager()
117
				.performStringSubstitution(arguments);
118
	}
119
120
	/**
121
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
122
	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
123
	 *      org.eclipse.core.runtime.IProgressMonitor)
124
	 */
125
	public void launch(ILaunchConfiguration configuration, String mode,
126
			ILaunch launch, IProgressMonitor monitor) throws CoreException {
127
		if (monitor.isCanceled()) {
128
			return;
129
		}
130
		fUserSpecifiedLogger = false;
131
		fMode = mode;
132
		launchManager = DebugPlugin.getDefault().getLaunchManager();
133
134
		// migrate the config to the new classpath format if required
135
		AntLaunchingUtil.migrateToNewClasspathFormat(configuration);
136
137
		boolean isSeparateJRE = AntLaunchingUtil
138
				.isSeparateJREAntBuild(configuration);
139
140
		if (ExternalToolsCoreUtil.isAsynchronousBuild(configuration)) {
141
			monitor.beginTask(MessageFormat.format(
142
				AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1,
143
						new String[] { configuration.getName() }), 10);
144
		} else {
145
			monitor.beginTask(MessageFormat.format(
146
				AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2,
147
						new String[] { configuration.getName() }), 100);
148
		}
149
150
		// resolve location
151
		IPath location = ExternalToolsCoreUtil.getLocation(configuration);
152
		monitor.worked(1);
153
154
		if (monitor.isCanceled()) {
155
			return;
156
		}
157
158
		if (!isSeparateJRE && AntRunner.isBuildRunning()) {
159
			IStatus status = new Status(
160
					IStatus.ERROR,
161
					AntLaunching.PLUGIN_ID,
162
					1,
163
					MessageFormat
164
							.format(
165
									AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress,
166
									new String[] { location.toOSString() }),
167
					null);
168
			throw new CoreException(status);
169
		}
170
171
		// resolve working directory
172
		IPath workingDirectory = ExternalToolsCoreUtil
173
				.getWorkingDirectory(configuration);
174
		String basedir = null;
175
		if (workingDirectory != null) {
176
			basedir = workingDirectory.toOSString();
177
		}
178
		monitor.worked(1);
179
180
		if (monitor.isCanceled()) {
181
			return;
182
		}
183
184
		// link the process to its build logger via a timestamp
185
		long timeStamp = System.currentTimeMillis();
186
		String idStamp = Long.toString(timeStamp);
187
		StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$
188
		idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID);
189
		idProperty.append('=');
190
		idProperty.append(idStamp);
191
192
		// resolve arguments
193
		String[] arguments = null;
194
		if (isSeparateJRE) {
195
			arguments = new String[] { getProgramArguments(configuration) };
196
		} else {
197
			arguments = ExternalToolsCoreUtil.getArguments(configuration);
198
		}
199
200
		Map userProperties = AntLaunchingUtil.getProperties(configuration);
201
		if (userProperties != null) {// create a copy so as to not affect the
202
			// configuration with transient
203
			// properties
204
			userProperties = new HashMap(userProperties);
205
		}
206
		String[] propertyFiles = AntLaunchingUtil
207
				.getPropertyFiles(configuration);
208
		String[] targets = AntLaunchingUtil.getTargetNames(configuration);
209
		URL[] customClasspath = AntLaunchingUtil
210
				.getCustomClasspath(configuration);
211
		String antHome = AntLaunchingUtil.getAntHome(configuration);
212
213
		boolean setInputHandler = true;
214
		try {
215
			// check if set specify inputhandler
216
			setInputHandler = configuration.getAttribute(
217
					AntLaunching.SET_INPUTHANDLER, true);
218
		} catch (CoreException ce) {
219
			AntLaunching.log(ce);
220
		}
221
222
		AntRunner runner = null;
223
		if (!isSeparateJRE) {
224
			runner = configureAntRunner(configuration, location, basedir,
225
					idProperty, arguments, userProperties, propertyFiles,
226
					targets, customClasspath, antHome, setInputHandler);
227
		}
228
229
		monitor.worked(1);
230
231
		if (monitor.isCanceled()) {
232
			return;
233
		}
234
		boolean captureOutput = ExternalToolsCoreUtil
235
				.getCaptureOutput(configuration);
236
		int port = -1;
237
		int requestPort = -1;
238
		if (isSeparateJRE && captureOutput) {
239
			if (userProperties == null) {
240
				userProperties = new HashMap();
241
			}
242
			port = SocketUtil.findFreePort();
243
			userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID,
244
					idStamp);
245
			userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$
246
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
247
				requestPort = SocketUtil.findFreePort();
248
				userProperties
249
						.put(
250
								"eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$
251
			}
252
		}
253
254
		StringBuffer commandLine = generateCommandLine(location, arguments,
255
				userProperties, propertyFiles, targets, antHome, basedir,
256
				isSeparateJRE, captureOutput, setInputHandler);
257
258
		if (isSeparateJRE) {
259
			monitor
260
					.beginTask(
261
							MessageFormat
262
									.format(
263
											AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1,
264
											new String[] { configuration
265
													.getName() }), 10);
266
			runInSeparateVM(configuration, launch, monitor, idStamp, antHome,
267
					port, requestPort, commandLine, captureOutput,
268
					setInputHandler);
269
		} else {
270
			runInSameVM(configuration, launch, monitor, location, idStamp,
271
					runner, commandLine);
272
		}
273
274
		monitor.done();
275
	}
276
277
	private void runInSameVM(ILaunchConfiguration configuration,
278
			ILaunch launch, IProgressMonitor monitor, IPath location,
279
			String idStamp, AntRunner runner, StringBuffer commandLine) throws CoreException {
280
		Map attributes = new HashMap(2);
281
		attributes.put(IProcess.ATTR_PROCESS_TYPE,
282
				IAntLaunchConstants.ID_ANT_PROCESS_TYPE);
283
		attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
284
285
		final AntProcess process = new AntProcess(location.toOSString(),
286
				launch, attributes);
287
		setProcessAttributes(process, idStamp, commandLine);
288
		boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE);
289
		if (debug || ExternalToolsCoreUtil.isAsynchronousBuild(configuration)) {
290
			final AntRunner finalRunner = runner;
291
			Runnable r = new Runnable() {
292
				public void run() {
293
					try {
294
						finalRunner.run(process);
295
					} catch (CoreException e) {
296
						handleException(
297
								e,
298
								AntLaunchConfigurationMessages.AntLaunchDelegate_Failure);
299
					}
300
					process.terminated();
301
				}
302
			};
303
			Thread background = new Thread(r);
304
			background.setDaemon(true);
305
			background.start();
306
			monitor.worked(1);
307
			// refresh resources after process finishes
308
			if (configuration.getAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, (String)null) != null) {
309
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
310
						configuration, process);
311
				refresher.startBackgroundRefresh();
312
			}
313
		} else {
314
			// execute the build
315
			try {
316
				runner.run(monitor);
317
			} catch (CoreException e) {
318
				process.terminated();
319
				monitor.done();
320
				handleException(e,
321
						AntLaunchConfigurationMessages.AntLaunchDelegate_23);
322
				return;
323
			}
324
			process.terminated();
325
326
			// refresh resources
327
			RefreshUtil.refreshResources(configuration, monitor);
328
		}
329
	}
330
331
	private AntRunner configureAntRunner(ILaunchConfiguration configuration,
332
			IPath location, String baseDir, StringBuffer idProperty,
333
			String[] arguments, Map userProperties, String[] propertyFiles,
334
			String[] targets, URL[] customClasspath, String antHome,
335
			boolean setInputHandler) throws CoreException {
336
		int argLength = 1; // at least one user property - timestamp
337
		if (arguments != null) {
338
			argLength += arguments.length;
339
		}
340
		if (baseDir != null && baseDir.length() > 0) {
341
			argLength++;
342
		}
343
		String[] runnerArgs = new String[argLength];
344
		if (arguments != null) {
345
			System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length);
346
		}
347
		if (baseDir != null && baseDir.length() > 0) {
348
			runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir;
349
		}
350
		runnerArgs[runnerArgs.length - 1] = idProperty.toString();
351
352
		AntRunner runner = new AntRunner();
353
		runner.setBuildFileLocation(location.toOSString());
354
		boolean captureOutput = ExternalToolsCoreUtil
355
				.getCaptureOutput(configuration);
356
		if (captureOutput) {
357
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
358
				runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS);
359
			} else {
360
				runner.addBuildLogger(ANT_LOGGER_CLASS);
361
			}
362
		} else {
363
			runner.addBuildLogger(NULL_LOGGER_CLASS);
364
		}
365
		if (setInputHandler) {
366
			runner.setInputHandler(INPUT_HANDLER_CLASS);
367
		} else {
368
			runner.setInputHandler(""); //$NON-NLS-1$
369
		}
370
		runner.setArguments(runnerArgs);
371
		if (userProperties != null) {
372
			runner.addUserProperties(userProperties);
373
		}
374
375
		if (propertyFiles != null) {
376
			runner.setPropertyFiles(propertyFiles);
377
		}
378
379
		if (targets != null) {
380
			runner.setExecutionTargets(targets);
381
		}
382
383
		if (customClasspath != null) {
384
			runner.setCustomClasspath(customClasspath);
385
		}
386
387
		if (antHome != null) {
388
			runner.setAntHome(antHome);
389
		}
390
		return runner;
391
	}
392
393
	private void handleException(final CoreException e, final String title) {
394
		AntLaunching.log(title, e);
395
	}
396
397
	private void setProcessAttributes(IProcess process, String idStamp,
398
			StringBuffer commandLine) {
399
		// link the process to the Eclipse build logger via a timestamp
400
		if (!fUserSpecifiedLogger) {
401
			process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID,
402
					idStamp);
403
		}
404
405
		// create "fake" command line for the process
406
		if (commandLine != null) {
407
			process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString());
408
		}
409
	}
410
411
	private StringBuffer generateCommandLine(IPath location,
412
			String[] arguments, Map userProperties, String[] propertyFiles,
413
			String[] targets, String antHome, String basedir,
414
			boolean separateVM, boolean captureOutput, boolean setInputHandler) {
415
		StringBuffer commandLine = new StringBuffer();
416
417
		if (!separateVM) {
418
			commandLine.append("ant"); //$NON-NLS-1$
419
		}
420
421
		if (arguments != null) {
422
			for (int i = 0; i < arguments.length; i++) {
423
				commandLine.append(' ');
424
				commandLine.append(arguments[i]);
425
			}
426
		}
427
428
		AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
429
		if (propertyFiles == null) { // global
430
			String[] files = prefs.getCustomPropertyFiles();
431
			for (int i = 0; i < files.length; i++) {
432
				String path = files[i];
433
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
434
				commandLine.append(path);
435
				commandLine.append('\"');
436
			}
437
		} else {// "local" configuration
438
			for (int i = 0; i < propertyFiles.length; i++) {
439
				String path = propertyFiles[i];
440
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
441
				commandLine.append(path);
442
				commandLine.append('\"');
443
			}
444
		}
445
		// "local" configuration
446
		if (userProperties != null) {
447
			Iterator keys = userProperties.keySet().iterator();
448
			String key;
449
			while (keys.hasNext()) {
450
				key = (String) keys.next();
451
				appendProperty(commandLine, key, (String) userProperties
452
						.get(key));
453
			}
454
		}
455
456
		// global
457
		List properties = null;
458
		if (!separateVM) {
459
			properties = prefs.getProperties();
460
		} else {
461
			properties = prefs.getRemoteAntProperties();
462
		}
463
464
		// if we have user properties this means that the user has chosen to
465
		// override the global properties
466
		// if in a separate VM and have only two (or three if debug) user
467
		// properties these are really only Eclipse generated properties
468
		// and the user is still using the global properties
469
		int numberOfEclipseProperties = 2;
470
		if (userProperties != null
471
				&& userProperties.get("eclipse.connect.request_port") != null) { //$NON-NLS-1$
472
			numberOfEclipseProperties = 3; // debug mode
473
		}
474
		boolean useGlobalProperties = userProperties == null
475
				|| (separateVM && userProperties.size() == numberOfEclipseProperties);
476
		if (useGlobalProperties) {
477
			for (Iterator iter = properties.iterator(); iter.hasNext();) {
478
				Property property = (Property) iter.next();
479
				String key = property.getName();
480
				String value = property.getValue(false);
481
				if (value != null) {
482
					appendProperty(commandLine, key, value);
483
				}
484
			}
485
		}
486
487
		if (basedir != null && basedir.length() > 0) {
488
			appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$
489
		}
490
491
		if (antHome != null) {
492
			commandLine.append(" \"-Dant.home="); //$NON-NLS-1$
493
			commandLine.append(antHome);
494
			commandLine.append('\"');
495
		}
496
497
		if (separateVM) {
498
			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
499
				if (captureOutput) {
500
					commandLine.append(" -logger "); //$NON-NLS-1$
501
					if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
502
						commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS);
503
					} else {
504
						commandLine.append(REMOTE_ANT_LOGGER_CLASS);
505
					}
506
				}
507
			} else {
508
				fUserSpecifiedLogger = true;
509
			}
510
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
511
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
512
				commandLine.append(REMOTE_INPUT_HANDLER_CLASS);
513
			}
514
		} else {
515
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
516
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
517
				commandLine.append(INPUT_HANDLER_CLASS);
518
			}
519
			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
520
				commandLine.append(" -logger "); //$NON-NLS-1$
521
				if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
522
					commandLine.append(ANT_DEBUG_LOGGER_CLASS);
523
				} else if (captureOutput) {
524
					commandLine.append(ANT_LOGGER_CLASS);
525
				} else {
526
					commandLine.append(NULL_LOGGER_CLASS);
527
				}
528
			}
529
		}
530
531
		if (separateVM) {
532
			appendTaskAndTypes(prefs, commandLine);
533
		}
534
		commandLine.append(" -buildfile \""); //$NON-NLS-1$
535
		commandLine.append(location.toOSString());
536
		commandLine.append('\"');
537
538
		if (targets != null) {
539
			for (int i = 0; i < targets.length; i++) {
540
				commandLine.append(" \""); //$NON-NLS-1$
541
				commandLine.append(targets[i]);
542
				commandLine.append('\"');
543
			}
544
		}
545
		return commandLine;
546
	}
547
548
	private void appendTaskAndTypes(AntCorePreferences prefs,
549
			StringBuffer commandLine) {
550
		List tasks = prefs.getRemoteTasks();
551
		Iterator itr = tasks.iterator();
552
		while (itr.hasNext()) {
553
			Task task = (Task) itr.next();
554
			commandLine.append(" -eclipseTask "); //$NON-NLS-1$
555
			String name = ProjectHelper.genComponentName(task.getURI(), task
556
					.getTaskName());
557
			commandLine.append(name);
558
			commandLine.append(',');
559
			commandLine.append(task.getClassName());
560
		}
561
562
		List types = prefs.getRemoteTypes();
563
		itr = types.iterator();
564
		while (itr.hasNext()) {
565
			Type type = (Type) itr.next();
566
			commandLine.append(" -eclipseType "); //$NON-NLS-1$
567
			String name = ProjectHelper.genComponentName(type.getURI(), type
568
					.getTypeName());
569
			commandLine.append(name);
570
			commandLine.append(',');
571
			commandLine.append(type.getClassName());
572
		}
573
	}
574
575
	private void appendProperty(StringBuffer commandLine, String name,
576
			String value) {
577
		commandLine.append(" \"-D"); //$NON-NLS-1$
578
		commandLine.append(name);
579
		commandLine.append('=');
580
		commandLine.append(value);
581
		if (value.length() > 0
582
				&& value.charAt(value.length() - 1) == File.separatorChar) {
583
			commandLine.append(File.separatorChar);
584
		}
585
		commandLine.append("\""); //$NON-NLS-1$
586
	}
587
588
	private void runInSeparateVM(ILaunchConfiguration configuration,
589
			ILaunch launch, IProgressMonitor monitor, String idStamp,
590
			String antHome, int port, int requestPort,
591
			StringBuffer commandLine, boolean captureOutput,
592
			boolean setInputHandler) throws CoreException {
593
		boolean debug = fMode.equals(ILaunchManager.DEBUG_MODE);
594
		if (captureOutput) {
595
			if (debug) {
596
				RemoteAntDebugBuildListener listener = new RemoteAntDebugBuildListener(
597
						launch);
598
				if (requestPort != -1) {
599
					listener.startListening(port, requestPort);
600
				}
601
			} else if (!fUserSpecifiedLogger) {
602
				RemoteAntBuildListener client = new RemoteAntBuildListener(
603
						launch);
604
				if (port != -1) {
605
					client.startListening(port);
606
				}
607
			}
608
		}
609
610
		ILaunchConfigurationWorkingCopy copy = configuration.getWorkingCopy();
611
		setDefaultWorkingDirectory(copy);
612
		copy.setAttribute(
613
				IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
614
				commandLine.toString());
615
		copy.setAttribute(
616
				IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
617
				IAntLaunchConstants.MAIN_TYPE_NAME);
618
		StringBuffer vmArgs = generateVMArguments(copy, setInputHandler,
619
				antHome);
620
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
621
				vmArgs.toString());
622
		copy.setAttribute(ILaunchManager.ATTR_PRIVATE, true);
623
		if (copy
624
				.getAttribute(
625
						IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL,
626
						false)) {
627
			setDefaultVM(configuration, copy);
628
		}
629
630
		if (debug) { // do not allow launch in foreground bug 83254
631
			copy.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
632
		}
633
634
		// set the ANT_HOME environment variable
635
		if (antHome != null) {
636
			Map vars = copy.getAttribute(
637
					ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1));
638
			vars.put("ANT_HOME", antHome); //$NON-NLS-1$
639
			copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars);
640
		}
641
642
		// copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
643
		// "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
644
		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 10);
645
		AntJavaLaunchDelegate delegate = new AntJavaLaunchDelegate();
646
		delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor);
647
		delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor);
648
		final IProcess[] processes = launch.getProcesses();
649
		for (int i = 0; i < processes.length; i++) {
650
			setProcessAttributes(processes[i], idStamp, null);
651
		}
652
653
		if (ExternalToolsCoreUtil.isAsynchronousBuild(copy)) {
654
			// refresh resources after process finishes
655
			if (configuration.getAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, (String)null) != null) {
656
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
657
						configuration, processes[0]);
658
				refresher.startBackgroundRefresh();
659
			}
660
		} else {
661
			final boolean[] terminated = new boolean[1];
662
			terminated[0] = launch.isTerminated();
663
			IDebugEventSetListener listener = new IDebugEventSetListener() {
664
				public void handleDebugEvents(DebugEvent[] events) {
665
					for (int i = 0; i < events.length; i++) {
666
						DebugEvent event = events[i];
667
						for (int j = 0, numProcesses = processes.length; j < numProcesses; j++) {
668
							if (event.getSource() == processes[j]
669
									&& event.getKind() == DebugEvent.TERMINATE) {
670
								terminated[0] = true;
671
								break;
672
							}
673
						}
674
					}
675
				}
676
			};
677
			DebugPlugin.getDefault().addDebugEventListener(listener);
678
			monitor
679
					.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28);
680
			while (!monitor.isCanceled() && !terminated[0]) {
681
				try {
682
					Thread.sleep(50);
683
				} catch (InterruptedException e) {
684
				}
685
			}
686
			DebugPlugin.getDefault().removeDebugEventListener(listener);
687
			if (!monitor.isCanceled()) {
688
				// refresh resources
689
				RefreshUtil.refreshResources(configuration, monitor);
690
			}
691
		}
692
	}
693
694
	private void setDefaultVM(ILaunchConfiguration configuration,
695
			ILaunchConfigurationWorkingCopy copy) {
696
		try {
697
			JavaRuntime.getJavaProject(configuration);
698
			// remove the vm name, install type and jre container path for the
699
			// Java launching concept of default VM
700
			copy.setAttribute(
701
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME,
702
					(String) null);
703
			copy.setAttribute(
704
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE,
705
					(String) null);
706
			copy.setAttribute(
707
					IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH,
708
					(String) null);
709
		} catch (CoreException ce) {
710
			// not in a Java project
711
			IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
712
			copy.setAttribute(
713
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME,
714
					defaultVMInstall.getName());
715
			copy.setAttribute(
716
					IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE,
717
					defaultVMInstall.getVMInstallType().getId());
718
		}
719
	}
720
721
	private StringBuffer generateVMArguments(ILaunchConfiguration config,
722
			boolean setInputHandler, String antHome) {
723
		StringBuffer vmArgs = new StringBuffer();
724
		try {
725
			String configArgs = config.getAttribute(
726
					IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
727
					(String) null);
728
			if (configArgs != null) {
729
				vmArgs.append(configArgs);
730
				vmArgs.append(' ');
731
			}
732
		} catch (CoreException e) {
733
		}
734
735
		if (antHome != null) {
736
			vmArgs.append("-Dant.home=\""); //$NON-NLS-1$
737
			vmArgs.append(antHome);
738
			vmArgs.append("\" "); //$NON-NLS-1$
739
740
			File antLibDir = new File(antHome, "lib"); //$NON-NLS-1$
741
			vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$
742
			vmArgs.append(antLibDir.getAbsolutePath());
743
			vmArgs.append('\"');
744
		}
745
		if (setInputHandler) {
746
			String swtLocation = getSWTLibraryLocation();
747
			if (swtLocation != null) {
748
				vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$
749
				String javaLibPath = System.getProperty("java.library.path"); //$NON-NLS-1$
750
				javaLibPath = stripUnescapedQuotes(javaLibPath);
751
				if (javaLibPath != null) {
752
					vmArgs.append(javaLibPath);
753
					if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) {
754
						vmArgs.append(File.pathSeparatorChar);
755
					}
756
				}
757
				vmArgs.append(swtLocation);
758
				vmArgs.append('"');
759
			}
760
		}
761
		return vmArgs;
762
	}
763
764
	private String stripUnescapedQuotes(String javaLibPath) {
765
		StringBuffer buf = new StringBuffer(javaLibPath.length());
766
		for (int i = 0; i < javaLibPath.length(); i++) {
767
			char c = javaLibPath.charAt(i);
768
			switch (c) {
769
			case '"':
770
				if (i != 0 && javaLibPath.charAt(i - 1) == '\\') {
771
					buf.append(c);
772
				}
773
				break;
774
			default:
775
				buf.append(c);
776
				break;
777
			}
778
		}
779
		return buf.toString();
780
	}
781
782
	/*
783
	 * (non-Javadoc)
784
	 * 
785
	 * @see
786
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder
787
	 * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
788
	 */
789
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration,
790
			String mode) throws CoreException {
791
		IProject[] projects = ExternalToolsCoreUtil.getBuildProjects(
792
				configuration, ATTR_BUILD_SCOPE);
793
		if (projects == null) {
794
			return NO_PROJECTS;
795
		}
796
		boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects(
797
				configuration, ATTR_INCLUDE_REFERENCED_PROJECTS);
798
		if (isRef) {
799
			return computeReferencedBuildOrder(projects);
800
		}
801
		return computeBuildOrder(projects);
802
	}
803
804
	private String getSWTLibraryLocation() {
805
		if (fgSWTLibraryLocation == null) {
806
			Bundle bundle = Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
807
			BundleDescription description = Platform.getPlatformAdmin()
808
					.getState(false).getBundle(bundle.getBundleId());
809
			BundleDescription[] fragments = description.getFragments();
810
			if (fragments == null || fragments.length == 0) {
811
				return null;
812
			}
813
			Bundle fragBundle = Platform.getBundle(fragments[0]
814
					.getSymbolicName());
815
			try {
816
				URL url = FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$
817
				IPath path = new Path(url.getPath());
818
				path = path.removeTrailingSeparator();
819
				fgSWTLibraryLocation = path.toOSString();
820
			} catch (IOException e) {
821
			}
822
		}
823
		return fgSWTLibraryLocation;
824
	}
825
826
	/*
827
	 * (non-Javadoc)
828
	 * 
829
	 * @see
830
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints
831
	 * (org.eclipse.debug.core.ILaunchConfiguration)
832
	 */
833
	protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
834
		IBreakpointManager breakpointManager = DebugPlugin.getDefault()
835
				.getBreakpointManager();
836
		if (!breakpointManager.isEnabled()) {
837
			// no need to check breakpoints individually.
838
			return null;
839
		}
840
		return breakpointManager
841
				.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
842
	}
843
844
	/*
845
	 * (non-Javadoc)
846
	 * 
847
	 * @see
848
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch
849
	 * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String,
850
	 * org.eclipse.core.runtime.IProgressMonitor)
851
	 */
852
	protected boolean saveBeforeLaunch(ILaunchConfiguration configuration,
853
			String mode, IProgressMonitor monitor) throws CoreException {
854
		if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY
855
				.equals(configuration.getType().getCategory())) {
856
			// don't prompt for builders
857
			return true;
858
		}
859
		return super.saveBeforeLaunch(configuration, mode, monitor);
860
	}
861
862
	/**
863
	 * Sets the default working directory to be the parent folder of the
864
	 * buildfile if the user has not explicitly set the working directory.
865
	 */
866
	private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) {
867
		try {
868
			String wd = copy.getAttribute(
869
					IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
870
					(String) null);
871
			if (wd == null) {
872
				wd = ExternalToolsCoreUtil.getLocation(copy)
873
						.removeLastSegments(1).toOSString();
874
				copy
875
						.setAttribute(
876
								IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
877
								wd);
878
			}
879
		} catch (CoreException e) {
880
			AntLaunching.log(e.getStatus());
881
		}
882
	}
883
884
	public ILaunch getLaunch(ILaunchConfiguration configuration, String mode)
885
			throws CoreException {
886
		return new AntLaunch(configuration, mode, null);
887
	}
888
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntMigrationDelegate.java (+77 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
14
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
15
import org.eclipse.core.resources.IFile;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.variables.IStringVariableManager;
19
import org.eclipse.core.variables.VariablesPlugin;
20
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate;
22
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
24
/**
25
 * Delegate for migrating Ant launch configurations.
26
 * The migration process involves a resource mapping being created such that launch configurations
27
 * can be filtered from the launch configuration dialog based on resource availability.
28
 * 
29
 * @since 3.2
30
 */
31
public class AntMigrationDelegate implements ILaunchConfigurationMigrationDelegate {
32
	
33
	/**
34
	 * Method to get the file for the specified launch configuration that should be mapped to the launch configuration  
35
	 * 
36
	 * @param candidate the launch configuration that the file will be mapped to.
37
	 * @return the buildfile or <code>null</code> if not in the workspace
38
	 */
39
	protected IFile getFileForCandidate(ILaunchConfiguration candidate) {
40
		IFile file= null;
41
		String expandedLocation= null;
42
		String location= null;
43
		IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
44
		try {
45
			location= candidate.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null);
46
			if (location != null) {
47
				expandedLocation= manager.performStringSubstitution(location);
48
				if (expandedLocation != null) {
49
					file= AntLaunchingUtil.getFileForLocation(expandedLocation, null);
50
				}
51
			}
52
		} catch (CoreException e) {
53
		}
54
		return file;
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#isCandidate()
59
	 */
60
	public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
61
		IResource[] mappedResources = candidate.getMappedResources();
62
		if (mappedResources != null && mappedResources.length > 0) {
63
			return false;
64
		}
65
		return getFileForCandidate(candidate) != null;
66
	}
67
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#migrate(org.eclipse.debug.core.ILaunchConfiguration)
70
	 */
71
	public void migrate(ILaunchConfiguration candidate) throws CoreException {
72
		IFile file = getFileForCandidate(candidate);
73
		ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy();
74
		wc.setMappedResources(new IResource[] {file});
75
		wc.doSave();
76
	}
77
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntProcess.java (+172 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.PlatformObject;
19
import org.eclipse.debug.core.DebugEvent;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.ILaunch;
22
import org.eclipse.debug.core.model.IProcess;
23
import org.eclipse.debug.core.model.IStreamsProxy;
24
25
public class AntProcess extends PlatformObject implements IProcess, IProgressMonitor {
26
	
27
	private AntStreamsProxy fProxy;
28
	private String fLabel = null;
29
	private ILaunch fLaunch = null;
30
	private Map fAttributes = null;
31
	private boolean fTerminated = false;
32
	private boolean fCancelled = false;
33
	
34
	public AntProcess(String label, ILaunch launch, Map attributes) {
35
		fLabel = label;
36
		fLaunch = launch;
37
		if (attributes == null) {
38
			fAttributes = new HashMap();
39
		} else {
40
			fAttributes = attributes;
41
		}
42
		String captureOutput= launch.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT);
43
		if(!("false".equals(captureOutput))) { //$NON-NLS-1$
44
			fProxy= new AntStreamsProxy();
45
		}
46
		launch.addProcess(this);
47
	}
48
49
	/**
50
	 * @see org.eclipse.debug.core.model.IProcess#getLabel()
51
	 */
52
	public String getLabel() {
53
		return fLabel;
54
	}
55
56
	/**
57
	 * @see org.eclipse.debug.core.model.IProcess#getLaunch()
58
	 */
59
	public ILaunch getLaunch() {
60
		return fLaunch;
61
	}
62
63
	/**
64
	 * @see org.eclipse.debug.core.model.IProcess#getStreamsProxy()
65
	 */
66
	public IStreamsProxy getStreamsProxy() {
67
		return fProxy;
68
	}
69
70
	/**
71
	 * @see org.eclipse.debug.core.model.IProcess#setAttribute(java.lang.String, java.lang.String)
72
	 */
73
	public void setAttribute(String key, String value) {
74
		fAttributes.put(key, value);
75
	}
76
77
	/**
78
	 * @see org.eclipse.debug.core.model.IProcess#getAttribute(java.lang.String)
79
	 */
80
	public String getAttribute(String key) {
81
		return (String)fAttributes.get(key);
82
	}
83
84
	/**
85
	 * @see org.eclipse.debug.core.model.IProcess#getExitValue()
86
	 */
87
	public int getExitValue() {
88
		return 0;
89
	}
90
91
	/**
92
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
93
	 */
94
	public boolean canTerminate() {
95
		return !isCanceled() && !isTerminated();
96
	}
97
98
	/**
99
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
100
	 */
101
	public boolean isTerminated() {
102
		return fTerminated;
103
	}
104
	
105
	protected void terminated() {
106
		if (!fTerminated) {
107
			fTerminated = true;
108
			if (DebugPlugin.getDefault() != null) {
109
				DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
110
			}
111
		}
112
	}
113
114
	/**
115
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
116
	 */
117
	public void terminate() {
118
		setCanceled(true);
119
	}
120
	
121
	// IProgressMonitor implemented to support termination.
122
	
123
	/**
124
	 * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
125
	 */
126
	public void beginTask(String name, int totalWork) {
127
	}
128
129
	/**
130
	 * @see org.eclipse.core.runtime.IProgressMonitor#done()
131
	 */
132
	public void done() {
133
	}
134
135
	/**
136
	 * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
137
	 */
138
	public void internalWorked(double work) {
139
	}
140
141
	/**
142
	 * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
143
	 */
144
	public boolean isCanceled() {
145
		return fCancelled;
146
	}
147
148
	/**
149
	 * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
150
	 */
151
	public void setCanceled(boolean value) {
152
		fCancelled = value;
153
	}
154
155
	/**
156
	 * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
157
	 */
158
	public void setTaskName(String name) {
159
	}
160
161
	/**
162
	 * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String)
163
	 */
164
	public void subTask(String name) {
165
	}
166
167
	/**
168
	 * @see org.eclipse.core.runtime.IProgressMonitor#worked(int)
169
	 */
170
	public void worked(int work) {
171
	}
172
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamMonitor.java (+83 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import org.eclipse.core.runtime.ListenerList;
14
import org.eclipse.debug.core.IStreamListener;
15
import org.eclipse.debug.core.model.IFlushableStreamMonitor;
16
17
/**
18
 * Stream monitor implementation for an Ant build process.
19
 */
20
public class AntStreamMonitor implements IFlushableStreamMonitor {
21
22
	private StringBuffer fContents = new StringBuffer();
23
	private ListenerList fListeners = new ListenerList(1);
24
	private boolean fBuffered = true;
25
	
26
	/**
27
	 * @see org.eclipse.debug.core.model.IStreamMonitor#addListener(org.eclipse.debug.core.IStreamListener)
28
	 */
29
	public void addListener(IStreamListener listener) {
30
		fListeners.add(listener);
31
	}
32
33
	/**
34
	 * @see org.eclipse.debug.core.model.IStreamMonitor#getContents()
35
	 */
36
	public String getContents() {
37
		return fContents.toString();
38
	}
39
40
	/**
41
	 * @see org.eclipse.debug.core.model.IStreamMonitor#removeListener(org.eclipse.debug.core.IStreamListener)
42
	 */
43
	public void removeListener(IStreamListener listener) {
44
		fListeners.remove(listener);
45
	}
46
47
	/**
48
	 * Appends the given message to this stream, and notifies listeners.
49
	 * 
50
	 * @param message
51
	 */
52
	public void append(String message) {
53
		if (isBuffered()) {
54
			fContents.append(message);
55
		}
56
		Object[] listeners = fListeners.getListeners();
57
		for (int i = 0; i < listeners.length; i++) {
58
			IStreamListener listener = (IStreamListener)listeners[i];
59
			listener.streamAppended(message, this);
60
		}
61
	}
62
	/**
63
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#flushContents()
64
	 */
65
	public void flushContents() {
66
		fContents.setLength(0);
67
	}
68
69
	/**
70
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#isBuffered()
71
	 */
72
	public boolean isBuffered() {
73
		return fBuffered;
74
	}
75
76
	/**
77
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#setBuffered(boolean)
78
	 */
79
	public void setBuffered(boolean buffer) {
80
		fBuffered = buffer;
81
	}
82
}
83
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/AntStreamsProxy.java (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
14
import org.eclipse.ant.internal.launching.AntLaunching;
15
import org.eclipse.debug.core.model.IStreamMonitor;
16
import org.eclipse.debug.core.model.IStreamsProxy;
17
18
/**
19
 * 
20
 */
21
public class AntStreamsProxy implements IStreamsProxy {
22
	
23
	private AntStreamMonitor fErrorMonitor = new AntStreamMonitor();
24
	private AntStreamMonitor fOutputMonitor = new AntStreamMonitor();
25
	
26
	public static final String ANT_DEBUG_STREAM = AntLaunching.PLUGIN_ID + ".ANT_DEBUG_STREAM"; //$NON-NLS-1$
27
	public static final String ANT_VERBOSE_STREAM = AntLaunching.PLUGIN_ID + ".ANT_VERBOSE_STREAM"; //$NON-NLS-1$
28
	public static final String ANT_WARNING_STREAM = AntLaunching.PLUGIN_ID + ".ANT_WARNING_STREAM"; //$NON-NLS-1$
29
	
30
	private AntStreamMonitor fDebugMonitor = new AntStreamMonitor();
31
	private AntStreamMonitor fVerboseMonitor = new AntStreamMonitor();
32
	private AntStreamMonitor fWarningMonitor = new AntStreamMonitor();
33
34
	/**
35
	 * @see org.eclipse.debug.core.model.IStreamsProxy#getErrorStreamMonitor()
36
	 */
37
	public IStreamMonitor getErrorStreamMonitor() {
38
		return fErrorMonitor;
39
	}
40
41
	/**
42
	 * @see org.eclipse.debug.core.model.IStreamsProxy#getOutputStreamMonitor()
43
	 */
44
	public IStreamMonitor getOutputStreamMonitor() {
45
		return fOutputMonitor;
46
	}
47
48
	/**
49
	 * @see org.eclipse.debug.core.model.IStreamsProxy#write(java.lang.String)
50
	 */
51
	public void write(String input) {
52
	}
53
54
	public IStreamMonitor getWarningStreamMonitor() {
55
		return fWarningMonitor;
56
	}
57
	
58
	public IStreamMonitor getDebugStreamMonitor() {
59
		return fDebugMonitor;
60
	}	
61
	
62
	public IStreamMonitor getVerboseStreamMonitor() {
63
		return fVerboseMonitor;
64
	}	
65
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/ContributedClasspathEntriesEntry.java (+245 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.launching.launchConfigurations;
12
13
import java.io.File;
14
import java.io.FilenameFilter;
15
import java.io.IOException;
16
import java.net.MalformedURLException;
17
import java.net.URL;
18
import java.util.ArrayList;
19
import java.util.List;
20
21
import org.eclipse.ant.core.AntCorePlugin;
22
import org.eclipse.ant.core.AntCorePreferences;
23
import org.eclipse.ant.core.IAntClasspathEntry;
24
import org.eclipse.ant.internal.launching.AntLaunching;
25
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.FileLocator;
28
import org.eclipse.core.runtime.IPath;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.core.runtime.Platform;
31
import org.eclipse.debug.core.ILaunchConfiguration;
32
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
33
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
34
import org.eclipse.jdt.launching.IVMInstall;
35
import org.eclipse.jdt.launching.JavaRuntime;
36
import org.eclipse.osgi.service.resolver.BundleDescription;
37
import org.osgi.framework.Bundle;
38
import org.w3c.dom.Document;
39
import org.w3c.dom.Element;
40
41
/**
42
 * A classpath entry that contains a contributed classpath entries
43
 * via the <code>extraClasspathEntries</code> extension point.
44
 * 
45
 * @since 3.0 
46
 */
47
public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry {
48
	
49
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$
50
    
51
    public static List fgSWTEntries= null;
52
		
53
	/**
54
	 * Default contructor required to instantiate persisted extensions.
55
	 */
56
	public ContributedClasspathEntriesEntry() {
57
	}
58
	
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
61
	 */
62
	protected void buildMemento(Document document, Element memento) throws CoreException {
63
	}
64
	
65
	/* (non-Javadoc)
66
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
67
	 */
68
	public void initializeFrom(Element memento) throws CoreException {
69
	}
70
	
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
73
	 */
74
	public String getTypeId() {
75
		return TYPE_ID;
76
	}
77
	
78
	/* (non-Javadoc)
79
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
80
	 */
81
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
82
		boolean separateVM= AntLaunchingUtil.isSeparateJREAntBuild(configuration);
83
		boolean setInputHandler= configuration.getAttribute(AntLaunching.SET_INPUTHANDLER, true);
84
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
85
		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
86
		IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
87
		List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
88
		IAntClasspathEntry entry;
89
		for (int i = 0; i < antClasspathEntries.length; i++) {
90
			 entry= antClasspathEntries[i];
91
			if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
92
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
93
			}
94
		}
95
		boolean haveToolsEntry= false;
96
		String path;
97
		for (int i = 0; i < userEntries.length; i++) {
98
			entry = userEntries[i];
99
			path= entry.getLabel();
100
            IPath toolsPath= new Path(path);
101
			if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
102
				haveToolsEntry= true;
103
				// replace with dynamically resolved tools.jar based on
104
				// the JRE being used
105
				addToolsJar(configuration, rtes, path);
106
			} else {
107
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
108
			}
109
		}
110
		if (!haveToolsEntry) {
111
			addToolsJar(configuration, rtes, null);
112
		}
113
		
114
		if (setInputHandler && separateVM) {
115
			addSWTJars(rtes);
116
		}
117
		
118
		return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
119
	}
120
	
121
	private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) {
122
		IRuntimeClasspathEntry tools = getToolsJar(configuration);
123
		if (tools == null) {
124
			if (path != null) {
125
				//use the global entry
126
				rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
127
			} else {
128
				//use the default vm install to try to find a tools.jar
129
				IVMInstall install= JavaRuntime.getDefaultVMInstall();
130
				if (install != null) {
131
					IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
132
					if (entry != null) {
133
						rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())));
134
					}
135
				}
136
			}
137
		} else {
138
			rtes.add(tools);
139
		}
140
	}
141
	
142
	private void addSWTJars(List rtes) {
143
        if (fgSWTEntries == null) {
144
            fgSWTEntries= new ArrayList();
145
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
146
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
147
            BundleDescription[] fragments= description.getFragments();
148
            for (int i = 0; i < fragments.length; i++) {
149
                Bundle fragmentBundle= Platform.getBundle(fragments[i].getName());
150
                URL bundleURL;
151
                try {
152
                    bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$
153
                } catch (IOException e) {
154
                    AntLaunching.log(e);
155
                   continue;
156
                }
157
                String urlFileName= bundleURL.getFile();
158
                if (urlFileName.startsWith("file:")) { //$NON-NLS-1$
159
                    try {
160
                        urlFileName= new URL(urlFileName).getFile();
161
                        if (urlFileName.endsWith("!/")) { //$NON-NLS-1$
162
                            urlFileName= urlFileName.substring(0, urlFileName.length() - 2);
163
                        }
164
                    } catch (MalformedURLException e) {
165
                    	 AntLaunching.log(e);
166
                       continue;
167
                    }
168
                }
169
                IPath fragmentPath= new Path(urlFileName);
170
                if (fragmentPath.getFileExtension() != null) { //JAR file
171
                    fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
172
                } else { // folder
173
                    File bundleFolder= fragmentPath.toFile();
174
                    if (!bundleFolder.isDirectory()) {
175
                        continue;
176
                    }
177
                    String[] names= bundleFolder.list(new FilenameFilter() {
178
                        public boolean accept(File dir, String name) {
179
                            return name.endsWith(".jar"); //$NON-NLS-1$
180
                        }
181
                    });
182
                    for (int j = 0; j < names.length; j++) {
183
                        String jarName = names[j];
184
                        fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
185
                    }
186
                }
187
            }
188
        }
189
        rtes.addAll(fgSWTEntries);
190
	}
191
    
192
	/**
193
	 * Returns the tools.jar to use for this launch configuration, or <code>null</code>
194
	 * if none.
195
	 * 
196
	 * @param configuration configuration to resolve a tools.jar for
197
	 * @return associated tools.jar archive, or <code>null</code>
198
	 */
199
	private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) {
200
		try {
201
			IVMInstall install = JavaRuntime.computeVMInstall(configuration);
202
			if (install != null) {
203
				IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
204
				if (entry != null) {
205
					return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()));
206
				}
207
			}
208
		} catch (CoreException ce) {
209
			//likely dealing with a non-Java project
210
		}
211
			
212
		return null;
213
	}
214
	
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
217
	 */
218
	public String getName() {
219
		return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1;
220
	}
221
	/* (non-Javadoc)
222
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
223
	 */
224
	public int getType() {
225
		return IRuntimeClasspathEntry.OTHER;
226
	}
227
	/* (non-Javadoc)
228
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
229
	 */
230
	public boolean isComposite() {
231
		return true;
232
	}
233
	/* (non-Javadoc)
234
	 * @see java.lang.Object#equals(java.lang.Object)
235
	 */
236
	public boolean equals(Object obj) {
237
		return obj instanceof ContributedClasspathEntriesEntry;
238
	}
239
	/* (non-Javadoc)
240
	 * @see java.lang.Object#hashCode()
241
	 */
242
	public int hashCode() {
243
		return getClass().hashCode();
244
	}
245
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/MessageIds.java (+21 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
public class MessageIds {
15
16
	public final static String PROCESS_ID=   "processID"; //$NON-NLS-1$
17
	public final static String BUILD_CANCELLED= "cancelled"; //$NON-NLS-1$
18
	//constants need to start greater than the Project.MSG_* constants
19
    public final static String TASK= "6"; //$NON-NLS-1$
20
    public final static String TARGET= "7"; //$NON-NLS-1$
21
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntBuildListener.java (+401 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2003, 2009 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.InputStreamReader;
17
import java.net.ServerSocket;
18
import java.net.Socket;
19
import java.net.SocketException;
20
import java.net.SocketTimeoutException;
21
import java.util.ArrayList;
22
import java.util.Iterator;
23
import java.util.List;
24
import java.util.StringTokenizer;
25
26
import org.apache.tools.ant.Project;
27
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
28
import org.eclipse.ant.internal.launching.AntLaunch;
29
import org.eclipse.ant.internal.launching.AntLaunching;
30
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
31
import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants;
32
import org.eclipse.core.runtime.ISafeRunnable;
33
import org.eclipse.core.runtime.Platform;
34
import org.eclipse.debug.core.DebugPlugin;
35
import org.eclipse.debug.core.ILaunch;
36
import org.eclipse.debug.core.ILaunchesListener;
37
import org.eclipse.debug.core.model.IProcess;
38
39
/**
40
 * Parts adapted from org.eclipse.jdt.internal.junit.ui.RemoteTestRunnerClient
41
 * The client side of the RemoteAntBuildLogger. Handles the marshalling of the
42
 * different messages.
43
 */
44
public class RemoteAntBuildListener implements ILaunchesListener {
45
	public abstract class ListenerSafeRunnable implements ISafeRunnable {
46
		public void handleException(Throwable exception) {
47
			AntLaunching.log(exception);
48
		}
49
	}
50
51
	/**
52
	 * The server socket
53
	 */
54
	private ServerSocket fServerSocket;
55
	private Socket fSocket;
56
	private BufferedReader fBufferedReader;
57
	private IProcess fProcess;
58
	private String fProcessId;
59
	private List fMessageQueue;
60
	protected ILaunch fLaunch;
61
	private String fLastFileName = null;
62
	private String fLastTaskName = null;
63
	private boolean fBuildFailed = false;
64
65
	/**
66
	 * Reads the message stream from the RemoteAntBuildLogger
67
	 */
68
	private class ServerConnection extends Thread {
69
		private int fServerPort;
70
71
		public ServerConnection(int port) {
72
			super("Ant Build Server Connection"); //$NON-NLS-1$
73
			setDaemon(true);
74
			fServerPort = port;
75
		}
76
77
		public void run() {
78
			Exception exception = null;
79
			try {
80
				fServerSocket = new ServerSocket(fServerPort);
81
82
				int socketTimeout = Platform
83
						.getPreferencesService()
84
						.getInt(
85
								AntLaunching.getUniqueIdentifier(),
86
								IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
87
								20000, null);
88
				fServerSocket.setSoTimeout(socketTimeout);
89
				fSocket = fServerSocket.accept();
90
				fBufferedReader = new BufferedReader(new InputStreamReader(
91
						fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
92
				String message;
93
				while (fBufferedReader != null
94
						&& (message = fBufferedReader.readLine()) != null) {
95
					receiveMessage(message);
96
				}
97
			} catch (SocketException e) {
98
			} catch (SocketTimeoutException e) {
99
				exception = e;
100
			} catch (IOException e) {
101
				// fall through
102
				exception = e;
103
			}
104
			if (exception != null) {
105
				AntLaunching.log(exception);
106
			}
107
			shutDown();
108
		}
109
	}
110
111
	public RemoteAntBuildListener(ILaunch launch) {
112
		super();
113
		fLaunch = launch;
114
		DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
115
	}
116
117
	/**
118
	 * Start listening to an Ant build. Start a server connection that the
119
	 * RemoteAntBuildLogger can connect to.
120
	 * 
121
	 * @param eventPort
122
	 *            The port number to create the server connection on
123
	 */
124
	public synchronized void startListening(int eventPort) {
125
		ServerConnection connection = new ServerConnection(eventPort);
126
		connection.start();
127
	}
128
129
	protected synchronized void shutDown() {
130
		fLaunch = null;
131
		if (DebugPlugin.getDefault() != null) {
132
			DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(
133
					this);
134
		}
135
		try {
136
			if (fBufferedReader != null) {
137
				fBufferedReader.close();
138
				fBufferedReader = null;
139
			}
140
		} catch (IOException e) {
141
		}
142
		try {
143
			if (fSocket != null) {
144
				fSocket.close();
145
				fSocket = null;
146
			}
147
		} catch (IOException e) {
148
		}
149
		try {
150
			if (fServerSocket != null) {
151
				fServerSocket.close();
152
				fServerSocket = null;
153
			}
154
		} catch (IOException e) {
155
		}
156
	}
157
158
	protected void receiveMessage(String message) {
159
		if (message.startsWith(MessageIds.TASK)) {
160
			receiveTaskMessage(message);
161
		} else if (message.startsWith(MessageIds.TARGET)) {
162
			receiveTargetMessage(message);
163
		} else if (message.startsWith(MessageIds.PROCESS_ID)) {
164
			message = message.substring(MessageIds.PROCESS_ID.length());
165
			fProcessId = message;
166
		} else {
167
			int index = message.indexOf(',');
168
			if (index > 0) {
169
				int priority = Integer.parseInt(message.substring(0, index));
170
				message = message.substring(index + 1);
171
				writeMessage(
172
						message + System.getProperty("line.separator"), priority); //$NON-NLS-1$
173
				if (message.startsWith("BUILD FAILED")) { //$NON-NLS-1$
174
					fBuildFailed = true;
175
				} else if (fBuildFailed) {
176
					if (message.startsWith("Total time:")) { //$NON-NLS-1$
177
						fBuildFailed = false;
178
					} else {
179
						AntLaunchingUtil.linkBuildFailedMessage(message,
180
								getProcess());
181
					}
182
				}
183
184
			}
185
		}
186
	}
187
188
	private void receiveTargetMessage(String message) {
189
		message = message.substring(MessageIds.TARGET.length());
190
		StringTokenizer tokenizer = new StringTokenizer(message, ","); //$NON-NLS-1$
191
		message = tokenizer.nextToken();
192
		if (tokenizer.hasMoreTokens()) {
193
			int locationLength = Integer.parseInt(tokenizer.nextToken());
194
			String location = tokenizer.nextToken();
195
			while (location.length() < locationLength) { // path with a comma in
196
				// it
197
				location += ","; //$NON-NLS-1$
198
				location += tokenizer.nextToken();
199
			}
200
			int lineNumber = Integer.parseInt(tokenizer.nextToken());
201
			generateLink(message, location, lineNumber, 0, message.length() - 1);
202
		}
203
		writeMessage(
204
				message + System.getProperty("line.separator"), Project.MSG_INFO); //$NON-NLS-1$
205
	}
206
207
	private void receiveTaskMessage(String message) {
208
		message = message.substring(MessageIds.TASK.length());
209
210
		int index = message.indexOf(',');
211
		int priority = Integer.parseInt(message.substring(0, index));
212
		int index2 = message.indexOf(',', index + 1);
213
		String taskName = message.substring(index + 1, index2);
214
		if (taskName.length() == 0) {
215
			taskName = fLastTaskName;
216
		}
217
		int index3 = message.indexOf(',', index2 + 1);
218
		int lineLength = Integer
219
				.parseInt(message.substring(index2 + 1, index3));
220
		int index4 = index3 + 1 + lineLength;
221
222
		String line = message.substring(index3 + 1, index4);
223
		StringBuffer labelBuff = new StringBuffer();
224
		labelBuff.append('[');
225
		labelBuff.append(taskName);
226
		labelBuff.append("] "); //$NON-NLS-1$
227
		labelBuff.append(line);
228
		line = labelBuff.toString();
229
230
		fLastTaskName = taskName;
231
232
		int locationIndex = message.indexOf(',', index4 + 1);
233
		int finalIndex = locationIndex + 1;
234
		String fileName = message.substring(index4 + 1, locationIndex);
235
		int locationLength = 0;
236
		if (fileName.length() == 0) {
237
			fileName = fLastFileName;
238
		} else {
239
			finalIndex = message.indexOf(',', locationIndex) + 1;
240
			locationLength = Integer.parseInt(fileName);
241
			fileName = message.substring(finalIndex, finalIndex
242
					+ locationLength);
243
			locationLength += 1; // set past delimiter
244
		}
245
		fLastFileName = fileName;
246
		int lineNumber = Integer.parseInt(message.substring(finalIndex
247
				+ locationLength));
248
249
		int size = AntLaunching.LEFT_COLUMN_SIZE
250
				- (taskName.length() + 3);
251
		int offset = Math.max(size - 2, 1);
252
		int length = AntLaunching.LEFT_COLUMN_SIZE - size - 3;
253
		if (fileName != null) {
254
			generateLink(line, fileName, lineNumber, offset, length);
255
		}
256
257
		StringBuffer fullMessage = new StringBuffer();
258
		adornMessage(taskName, line, fullMessage);
259
		writeMessage(
260
				fullMessage
261
						.append(System.getProperty("line.separator")).toString(), priority); //$NON-NLS-1$
262
	}
263
264
	private void generateLink(String line, String fileName, int lineNumber,
265
			int offset, int length) {
266
		((AntLaunch) fLaunch).addLinkDescriptor(line, fileName, lineNumber,
267
				offset, length);
268
	}
269
270
	/**
271
	 * Returns the associated process, finding it if necessary.
272
	 */
273
	protected IProcess getProcess() {
274
		if (fProcess == null) {
275
			if (fProcessId != null) {
276
				IProcess[] all = DebugPlugin.getDefault().getLaunchManager()
277
						.getProcesses();
278
				for (int i = 0; i < all.length; i++) {
279
					IProcess process = all[i];
280
					if (fProcessId
281
							.equals(process
282
									.getAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID))) {
283
						fProcess = process;
284
						break;
285
					}
286
				}
287
			}
288
		}
289
		return fProcess;
290
	}
291
292
	private AntStreamMonitor getMonitor(int priority) {
293
		IProcess process = getProcess();
294
		if (process == null) {
295
			return null;
296
		}
297
		AntStreamsProxy proxy = (AntStreamsProxy) process.getStreamsProxy();
298
		if (proxy == null) {
299
			return null;
300
		}
301
		AntStreamMonitor monitor = null;
302
		switch (priority) {
303
		case Project.MSG_INFO:
304
			monitor = (AntStreamMonitor) proxy.getOutputStreamMonitor();
305
			break;
306
		case Project.MSG_ERR:
307
			monitor = (AntStreamMonitor) proxy.getErrorStreamMonitor();
308
			break;
309
		case Project.MSG_DEBUG:
310
			monitor = (AntStreamMonitor) proxy.getDebugStreamMonitor();
311
			break;
312
		case Project.MSG_WARN:
313
			monitor = (AntStreamMonitor) proxy.getWarningStreamMonitor();
314
			break;
315
		case Project.MSG_VERBOSE:
316
			monitor = (AntStreamMonitor) proxy.getVerboseStreamMonitor();
317
			break;
318
		}
319
		return monitor;
320
	}
321
322
	/**
323
	 * Builds a right justified task prefix for the given build event, placing
324
	 * it in the given string buffer.
325
	 * 
326
	 * @param event
327
	 *            build event
328
	 * @param fullMessage
329
	 *            buffer to place task prefix in
330
	 */
331
	private void adornMessage(String taskName, String line,
332
			StringBuffer fullMessage) {
333
		if (taskName == null) {
334
			taskName = "null"; //$NON-NLS-1$
335
		}
336
337
		int size = AntLaunching.LEFT_COLUMN_SIZE
338
				- (taskName.length() + 6);
339
		for (int i = 0; i < size; i++) {
340
			fullMessage.append(' ');
341
		}
342
343
		fullMessage.append(line);
344
	}
345
346
	protected void writeMessage(String message, int priority) {
347
		AntStreamMonitor monitor = getMonitor(priority);
348
		if (monitor == null) {
349
			if (fMessageQueue == null) {
350
				fMessageQueue = new ArrayList();
351
			}
352
			fMessageQueue.add(message);
353
			return;
354
		}
355
		if (fMessageQueue != null) {
356
			for (Iterator iter = fMessageQueue.iterator(); iter.hasNext();) {
357
				String oldMessage = (String) iter.next();
358
				monitor.append(oldMessage);
359
			}
360
			fMessageQueue = null;
361
		}
362
		monitor.append(message);
363
	}
364
365
	/*
366
	 * (non-Javadoc)
367
	 * 
368
	 * @see
369
	 * org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug
370
	 * .core.ILaunch[])
371
	 */
372
	public void launchesAdded(ILaunch[] launches) {
373
	}
374
375
	/*
376
	 * (non-Javadoc)
377
	 * 
378
	 * @see
379
	 * org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.
380
	 * debug.core.ILaunch[])
381
	 */
382
	public void launchesChanged(ILaunch[] launches) {
383
	}
384
385
	/*
386
	 * (non-Javadoc)
387
	 * 
388
	 * @see
389
	 * org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.
390
	 * debug.core.ILaunch[])
391
	 */
392
	public void launchesRemoved(ILaunch[] launches) {
393
		for (int i = 0; i < launches.length; i++) {
394
			ILaunch launch = launches[i];
395
			if (launch.equals(fLaunch)) {
396
				shutDown();
397
				return;
398
			}
399
		}
400
	}
401
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntProcessFactory.java (+34 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.ant.launching.IAntLaunchConstants;
18
import org.eclipse.debug.core.ILaunch;
19
import org.eclipse.debug.core.IProcessFactory;
20
import org.eclipse.debug.core.model.IProcess;
21
22
public class RemoteAntProcessFactory implements IProcessFactory {
23
24
	/* (non-Javadoc)
25
	 * @see org.eclipse.debug.core.IProcessFactory#newProcess(org.eclipse.debug.core.ILaunch, java.lang.Process, java.lang.String, java.util.Map)
26
	 */
27
	public IProcess newProcess(ILaunch launch, Process process, String label, Map attributes) {
28
		if (attributes == null) {
29
			attributes= new HashMap(1);
30
		}
31
		attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConstants.ID_ANT_PROCESS_TYPE);
32
		return new RemoteAntRuntimeProcess(launch, process, label, attributes);
33
	}
34
}
(-)src/org/eclipse/ant/internal/launching/launchConfigurations/RemoteAntRuntimeProcess.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.launching.launchConfigurations;
13
14
import java.util.Map;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.model.IStreamsProxy;
17
import org.eclipse.debug.core.model.RuntimeProcess;
18
19
public class RemoteAntRuntimeProcess extends RuntimeProcess {
20
21
	/**
22
	 * Constructs a RuntimeProcess on the given system process
23
	 * with the given name, adding this process to the given
24
	 * launch.
25
	 * Sets the streams proxy to an AntStreamsProxy if output is captured.
26
	 */
27
	public RemoteAntRuntimeProcess(ILaunch launch, Process process, String name, Map attributes) {
28
		super(launch, process, name, attributes);
29
	}
30
	
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.debug.core.model.RuntimeProcess#createStreamsProxy()
33
	 */
34
	protected IStreamsProxy createStreamsProxy() {
35
		return new AntStreamsProxy();
36
	}
37
}
(-)src/org/eclipse/ant/launching/IAntLaunchConstants.java (+126 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.launching;
13
14
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
15
16
/**
17
 * Constant definitions for Ant launch configurations.
18
 * 
19
 * @since 1.0
20
 * @noimplement This interface is not intended to be implemented by clients.
21
 */
22
public interface IAntLaunchConstants {
23
24
	/**
25
	 * Ant launch configuration type identifier.
26
	 */
27
	public static final String ID_ANT_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntLaunchConfigurationType"; //$NON-NLS-1$
28
29
	public static final String MAIN_TYPE_NAME= "org.eclipse.ant.internal.launching.remote.InternalAntRunner"; //$NON-NLS-1$
30
	
31
	/**
32
	 * Ant builder launch configuration type identifier. Ant project builders
33
	 * are of this type.
34
	 */
35
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$
36
37
	/**
38
	 * String attribute indicating the Ant targets to execute. Default value is
39
	 * <code>null</code> which indicates that the default target is to be
40
	 * executed. Format is a comma separated listing of targets.
41
	 */
42
	public static final String ATTR_ANT_TARGETS = IExternalToolConstants.UI_PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$
43
44
	/**
45
	 * String attribute indicating the Ant targets to execute after a clean
46
	 * (full build) for an Ant builder. Default value is <code>null</code> which
47
	 * indicates that the default target is to be executed. Format is a comma
48
	 * separated listing of targets.
49
	 */
50
	public static final String ATTR_ANT_AFTER_CLEAN_TARGETS = "org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS"; //$NON-NLS-1$
51
52
	/**
53
	 * String attribute indicating the Ant targets to execute during a manual
54
	 * build for an Ant builder. Default value is <code>null</code> which
55
	 * indicates that the default target is to be executed. Format is a comma
56
	 * separated listing of targets.
57
	 */
58
	public static final String ATTR_ANT_MANUAL_TARGETS = "org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS"; //$NON-NLS-1$
59
60
	/**
61
	 * String attribute indicating the Ant targets to execute during an auto
62
	 * build for an Ant builder. Default value is <code>null</code> which
63
	 * indicates that the default target is to be executed. Format is a comma
64
	 * separated listing of targets.
65
	 */
66
	public static final String ATTR_ANT_AUTO_TARGETS = "org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS"; //$NON-NLS-1$
67
68
	/**
69
	 * String attribute indicating the Ant targets to execute during a clean for
70
	 * an Ant builder. Default value is <code>null</code> which indicates that
71
	 * the default target is to be executed. Format is a comma separated listing
72
	 * of targets.
73
	 */
74
	public static final String ATTR_ANT_CLEAN_TARGETS = "org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS"; //$NON-NLS-1$
75
76
	/**
77
	 * Boolean attribute indicating whether or not target specification for an
78
	 * Ant builder has been updated for 3.1
79
	 */
80
	public static final String ATTR_TARGETS_UPDATED = "org.eclipse.ant.ui.ATTR_TARGETS_UPDATED"; //$NON-NLS-1$
81
82
	/**
83
	 * Map attribute indicating the Ant properties to be defined during the
84
	 * build. Default value is <code>null</code> which indicates no additional
85
	 * properties will be defined.
86
	 */
87
	public static final String ATTR_ANT_PROPERTIES = IExternalToolConstants.UI_PLUGIN_ID + ".ATTR_ANT_PROPERTIES"; //$NON-NLS-1$					
88
89
	/**
90
	 * String attribute indicating the Ant targets to execute. Default value is
91
	 * <code>null</code> which indicates that no additional property files will
92
	 * be defined. Format is a comma separated listing of property files.
93
	 */
94
	public static final String ATTR_ANT_PROPERTY_FILES = IExternalToolConstants.UI_PLUGIN_ID + ".ATTR_ANT_PROPERTY_FILES"; //$NON-NLS-1$
95
96
	/**
97
	 * Boolean attribute indicating whether or not internal targets (targets
98
	 * with no description) should be hidden from the user in the launch
99
	 * configuration dialog. Default value is <code>false</code> which indicates
100
	 * that all targets will be displayed.
101
	 */
102
	public static final String ATTR_HIDE_INTERNAL_TARGETS = IExternalToolConstants.UI_PLUGIN_ID + ".ATTR_HIDE_INTERNAL_TARGETS"; //$NON-NLS-1$
103
104
	/**
105
	 * Integer attribute indicating which column targets should be sorted on. A
106
	 * value of 0 indicates target name, 1 indicates target description, and -1
107
	 * indicates no sort. Default value is -1.
108
	 */
109
	public static final String ATTR_SORT_TARGETS = IExternalToolConstants.UI_PLUGIN_ID + "ATTR_SORT_TARGETS"; //$NON-NLS-1$
110
111
	/**
112
	 * Boolean attribute indicating if the default VM install should be used for
113
	 * the separate JRE build Default value is <code>false</code> for backwards
114
	 * compatibility
115
	 */
116
	public static final String ATTR_DEFAULT_VM_INSTALL = "org.eclipse.ant.ui.DEFAULT_VM_INSTALL"; //$NON-NLS-1$
117
118
	/**
119
	 * Identifier for Ant processes (value
120
	 * <code>org.eclipse.ant.ui.antProcess</code>). This identifier is set as
121
	 * the value for the <code>IProcess.ATTR_PROCESS_TYPE</code> attribute in
122
	 * processes created by the Ant launch delegate.
123
	 */
124
	public static final String ID_ANT_PROCESS_TYPE = "org.eclipse.ant.ui.antProcess"; //$NON-NLS-1$
125
126
}
(-)src/org/eclipse/ant/launching/package.html (+13 lines)
Added Link Here
1
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2
<html>
3
<head>
4
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5
   <title>Package-level Javadoc</title>
6
</head>
7
<body>
8
Provides support for Ant launching.
9
<h2>
10
Package Specification</h2>
11
This package defines constants for Ant launch configuration attributes. 
12
</body>
13
</html>
(-)Ant Debug Tests/org/eclipse/ant/tests/ui/debug/AbstractAntDebugTest.java (-5 / +5 lines)
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.tests.ui.debug;
11
package org.eclipse.ant.tests.ui.debug;
12
12
13
import org.eclipse.ant.internal.ui.debug.model.AntDebugTarget;
13
import org.eclipse.ant.internal.launching.debug.model.AntDebugTarget;
14
import org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint;
14
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
15
import org.eclipse.ant.internal.ui.debug.model.AntStackFrame;
15
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
16
import org.eclipse.ant.internal.ui.debug.model.AntThread;
16
import org.eclipse.ant.internal.launching.debug.model.AntThread;
17
import org.eclipse.ant.tests.ui.AbstractAntUIBuildTest;
17
import org.eclipse.ant.tests.ui.AbstractAntUIBuildTest;
18
import org.eclipse.ant.tests.ui.testplugin.DebugElementKindEventWaiter;
18
import org.eclipse.ant.tests.ui.testplugin.DebugElementKindEventWaiter;
19
import org.eclipse.ant.tests.ui.testplugin.DebugEventWaiter;
19
import org.eclipse.ant.tests.ui.testplugin.DebugEventWaiter;
Lines 307-313 Link Here
307
	 */	
307
	 */	
308
	protected AntDebugTarget debugLaunchAndTerminate(ILaunchConfiguration config, int timeout) throws Exception {
308
	protected AntDebugTarget debugLaunchAndTerminate(ILaunchConfiguration config, int timeout) throws Exception {
309
		DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.TERMINATE, AntDebugTarget.class);
309
		DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.TERMINATE, AntDebugTarget.class);
310
		waiter.setTimeout(timeout);
310
		waiter.setTimeout(2000000000);
311
311
312
		Object terminatee = launchAndWait(config, waiter);		
312
		Object terminatee = launchAndWait(config, waiter);		
313
		assertNotNull("Program did not terminate.", terminatee);
313
		assertNotNull("Program did not terminate.", terminatee);
(-)Ant Debug Tests/org/eclipse/ant/tests/ui/debug/BreakpointTests.java (-5 / +5 lines)
Lines 13-21 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.List;
14
import java.util.List;
15
15
16
import org.eclipse.ant.internal.ui.debug.model.AntDebugTarget;
16
import org.eclipse.ant.internal.launching.debug.model.AntDebugTarget;
17
import org.eclipse.ant.internal.ui.debug.model.AntThread;
17
import org.eclipse.ant.internal.launching.debug.model.AntThread;
18
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
18
import org.eclipse.ant.launching.IAntLaunchConstants;
19
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.debug.core.DebugException;
21
import org.eclipse.debug.core.DebugException;
Lines 116-122 Link Here
116
			}
116
			}
117
            ILaunchConfiguration config= getLaunchConfiguration(fileName);
117
            ILaunchConfiguration config= getLaunchConfiguration(fileName);
118
            ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
118
            ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
119
            copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, "entry1,entry2");
119
            copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "entry1,entry2");
120
			thread= launchToLineBreakpoint(copy, bp);
120
			thread= launchToLineBreakpoint(copy, bp);
121
			bp.setEnabled(false);
121
			bp.setEnabled(false);
122
            if (sepVM) {
122
            if (sepVM) {
Lines 200-206 Link Here
200
			}
200
			}
201
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
201
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
202
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
202
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
203
			copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, defaultTargetName);
203
			copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, defaultTargetName);
204
            if (!sepVM) {
204
            if (!sepVM) {
205
                Thread.sleep(3000); //TODO bug 121207: wait for previous launch to fully terminate
205
                Thread.sleep(3000); //TODO bug 121207: wait for previous launch to fully terminate
206
            }
206
            }
(-)Ant Debug Tests/org/eclipse/ant/tests/ui/debug/PropertyTests.java (-8 / +8 lines)
Lines 10-20 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.tests.ui.debug;
11
package org.eclipse.ant.tests.ui.debug;
12
12
13
import org.eclipse.ant.internal.ui.debug.model.AntProperty;
13
import org.eclipse.ant.internal.launching.debug.model.AntProperty;
14
import org.eclipse.ant.internal.ui.debug.model.AntStackFrame;
14
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
15
import org.eclipse.ant.internal.ui.debug.model.AntThread;
15
import org.eclipse.ant.internal.launching.debug.model.AntThread;
16
import org.eclipse.ant.internal.ui.debug.model.AntValue;
16
import org.eclipse.ant.internal.launching.debug.model.AntValue;
17
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
17
import org.eclipse.ant.launching.IAntLaunchConstants;
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.debug.core.DebugException;
19
import org.eclipse.debug.core.DebugException;
20
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 48-54 Link Here
48
			}
48
			}
49
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
49
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
50
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
50
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
51
			copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, "properties");
51
			copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "properties");
52
			thread= launchToLineBreakpoint(copy, bp);
52
			thread= launchToLineBreakpoint(copy, bp);
53
53
54
			AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
54
			AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
Lines 82-88 Link Here
82
			}
82
			}
83
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
83
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
84
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
84
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
85
			copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, "properties");
85
			copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "properties");
86
			thread= launchToLineBreakpoint(copy, bp);
86
			thread= launchToLineBreakpoint(copy, bp);
87
87
88
			AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
88
			AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
Lines 118-124 Link Here
118
			}
118
			}
119
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
119
			ILaunchConfiguration config= getLaunchConfiguration(fileName);
120
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
120
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
121
			copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, "properties");
121
			copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "properties");
122
			thread= launchToLineBreakpoint(copy, bp);
122
			thread= launchToLineBreakpoint(copy, bp);
123
123
124
			AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
124
			AntStackFrame frame = (AntStackFrame)thread.getTopStackFrame();
(-)Ant Debug Tests/org/eclipse/ant/tests/ui/debug/RunToLineTests.java (-2 / +2 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.tests.ui.debug;
11
package org.eclipse.ant.tests.ui.debug;
12
12
13
import org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint;
13
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
14
import org.eclipse.ant.internal.ui.debug.model.AntThread;
14
import org.eclipse.ant.internal.launching.debug.model.AntThread;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.DebugEvent;
16
import org.eclipse.debug.core.DebugEvent;
17
import org.eclipse.debug.core.model.IStackFrame;
17
import org.eclipse.debug.core.model.IStackFrame;
(-)Ant Debug Tests/org/eclipse/ant/tests/ui/debug/StackTests.java (-1 / +1 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.tests.ui.debug;
11
package org.eclipse.ant.tests.ui.debug;
12
12
13
import org.eclipse.ant.internal.ui.debug.model.AntThread;
13
import org.eclipse.ant.internal.launching.debug.model.AntThread;
14
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.model.ILineBreakpoint;
16
import org.eclipse.debug.core.model.ILineBreakpoint;
(-)Ant Debug Tests/org/eclipse/ant/tests/ui/debug/SteppingTests.java (-2 / +2 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.tests.ui.debug;
11
package org.eclipse.ant.tests.ui.debug;
12
12
13
import org.eclipse.ant.internal.ui.debug.model.AntStackFrame;
13
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
14
import org.eclipse.ant.internal.ui.debug.model.AntThread;
14
import org.eclipse.ant.internal.launching.debug.model.AntThread;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.DebugEvent;
16
import org.eclipse.debug.core.DebugEvent;
17
import org.eclipse.debug.core.DebugException;
17
import org.eclipse.debug.core.DebugException;
(-)Ant Tests/org/eclipse/ant/tests/ui/AbstractAntUIBuildTest.java (-1 / +1 lines)
Lines 81-87 Link Here
81
	 * @return thread in which the first suspend event occurred
81
	 * @return thread in which the first suspend event occurred
82
	 */
82
	 */
83
	protected void launch(ILaunchConfiguration config) throws CoreException {
83
	protected void launch(ILaunchConfiguration config) throws CoreException {
84
	    launchAndTerminate(config, 20000);
84
	    launchAndTerminate(config, 200000);
85
	}
85
	}
86
	
86
	
87
	protected void activateLink(final IHyperlink link) {
87
	protected void activateLink(final IHyperlink link) {
(-)Ant Tests/org/eclipse/ant/tests/ui/AntUtilTests.java (-4 / +4 lines)
Lines 16-27 Link Here
16
16
17
import org.eclipse.ant.internal.ui.AntUtil;
17
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.ant.internal.ui.model.AntTargetNode;
18
import org.eclipse.ant.internal.ui.model.AntTargetNode;
19
import org.eclipse.ant.launching.IAntLaunchConstants;
19
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
20
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
20
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
21
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
25
25
26
public class AntUtilTests extends AbstractAntUITest {
26
public class AntUtilTests extends AbstractAntUITest {
27
27
Lines 101-110 Link Here
101
		    copy.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
101
		    copy.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
102
		}
102
		}
103
		if (properties != null) {
103
		if (properties != null) {
104
		    copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, properties);
104
		    copy.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
105
		}
105
		}
106
		if (propertyFiles != null) {
106
		if (propertyFiles != null) {
107
		    copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, propertyFiles);
107
		    copy.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES, propertyFiles);
108
		}
108
		}
109
		return copy;
109
		return copy;
110
    }
110
    }
(-)Ant Tests/org/eclipse/ant/tests/ui/BuildTests.java (-4 / +4 lines)
Lines 18-25 Link Here
18
18
19
import org.eclipse.ant.internal.ui.AntUIPlugin;
19
import org.eclipse.ant.internal.ui.AntUIPlugin;
20
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
20
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
21
import org.eclipse.ant.launching.IAntLaunchConstants;
21
import org.eclipse.ant.tests.ui.testplugin.ConsoleLineTracker;
22
import org.eclipse.ant.tests.ui.testplugin.ConsoleLineTracker;
22
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
23
import org.eclipse.core.resources.IResource;
23
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 41-47 Link Here
41
   */
41
   */
42
  public void testOutput() throws CoreException {
42
  public void testOutput() throws CoreException {
43
	  launch("echoing");
43
	  launch("echoing");
44
	  assertTrue("Incorrect number of messages logged for build. Should be 8. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 8);
44
	  assertTrue("Incorrect number of messages logged for build. Should be 8. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 8); 
45
	  String message= ConsoleLineTracker.getMessage(6);
45
	  String message= ConsoleLineTracker.getMessage(6);
46
	  assertTrue("Incorrect last message. Should start with Total time:. Message: " + message, message.startsWith("Total time:"));
46
	  assertTrue("Incorrect last message. Should start with Total time:. Message: " + message, message.startsWith("Total time:"));
47
  }
47
  }
Lines 143-150 Link Here
143
		ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
143
		ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
144
		Map properties= new HashMap(1);
144
		Map properties= new HashMap(1);
145
		properties.put("platform.location", "${workspace_loc}");
145
		properties.put("platform.location", "${workspace_loc}");
146
		copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, properties);
146
		copy.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
147
		copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, properties);
147
		copy.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
148
		launchAndTerminate(copy, 20000);
148
		launchAndTerminate(copy, 20000);
149
		ConsoleLineTracker.waitForConsole();
149
		ConsoleLineTracker.waitForConsole();
150
		assertTrue("Incorrect number of messages logged for build. Should be 8. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 8);
150
		assertTrue("Incorrect number of messages logged for build. Should be 8. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 8);
(-)Ant Tests/org/eclipse/ant/tests/ui/performance/OpenLaunchConfigurationDialogTests.java (-1 / +1 lines)
Lines 14-19 Link Here
14
import org.eclipse.ant.internal.ui.IAntUIConstants;
14
import org.eclipse.ant.internal.ui.IAntUIConstants;
15
import org.eclipse.ant.tests.ui.editor.performance.EditorTestHelper;
15
import org.eclipse.ant.tests.ui.editor.performance.EditorTestHelper;
16
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
16
import org.eclipse.ant.tests.ui.testplugin.AbstractAntUITest;
17
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.core.runtime.Status;
Lines 26-32 Link Here
26
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.jface.viewers.StructuredSelection;
27
import org.eclipse.test.performance.Dimension;
28
import org.eclipse.test.performance.Dimension;
28
import org.eclipse.test.performance.PerformanceTestCase;
29
import org.eclipse.test.performance.PerformanceTestCase;
29
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
30
30
31
public class OpenLaunchConfigurationDialogTests extends PerformanceTestCase {
31
public class OpenLaunchConfigurationDialogTests extends PerformanceTestCase {
32
32
(-)Ant Tests/org/eclipse/ant/tests/ui/performance/SeparateVMTests.java (-1 / +1 lines)
Lines 15-26 Link Here
15
import junit.framework.TestSuite;
15
import junit.framework.TestSuite;
16
16
17
import org.eclipse.ant.tests.ui.AbstractAntUIBuildPerformanceTest;
17
import org.eclipse.ant.tests.ui.AbstractAntUIBuildPerformanceTest;
18
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.debug.core.DebugPlugin;
20
import org.eclipse.debug.core.DebugPlugin;
20
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
22
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
22
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.debug.ui.IDebugUIConstants;
23
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
24
24
25
public class SeparateVMTests extends AbstractAntUIBuildPerformanceTest {
25
public class SeparateVMTests extends AbstractAntUIBuildPerformanceTest {
26
		
26
		
(-)Ant Tests/org/eclipse/ant/tests/ui/separateVM/SeparateVMTests.java (-3 / +3 lines)
Lines 21-30 Link Here
21
21
22
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.AntUIPlugin;
23
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
23
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
24
import org.eclipse.ant.launching.IAntLaunchConstants;
24
import org.eclipse.ant.tests.ui.AbstractAntUIBuildTest;
25
import org.eclipse.ant.tests.ui.AbstractAntUIBuildTest;
25
import org.eclipse.ant.tests.ui.testplugin.ConsoleLineTracker;
26
import org.eclipse.ant.tests.ui.testplugin.ConsoleLineTracker;
26
import org.eclipse.ant.tests.ui.testplugin.ProjectHelper;
27
import org.eclipse.ant.tests.ui.testplugin.ProjectHelper;
27
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
28
import org.eclipse.core.resources.IFile;
28
import org.eclipse.core.resources.IFile;
29
import org.eclipse.core.resources.IResource;
29
import org.eclipse.core.resources.IResource;
30
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.CoreException;
Lines 158-164 Link Here
158
		assertNotNull("Could not locate launch configuration for " + "echoingSepVM", config);
158
		assertNotNull("Could not locate launch configuration for " + "echoingSepVM", config);
159
		ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
159
		ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
160
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getJavaProject().getProject().getLocation().toOSString());
160
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, getJavaProject().getProject().getLocation().toOSString());
161
		copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, "Bug42984");
161
		copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, "Bug42984");
162
		launchAndTerminate(copy, 20000);
162
		launchAndTerminate(copy, 20000);
163
		ConsoleLineTracker.waitForConsole();
163
		ConsoleLineTracker.waitForConsole();
164
		assertTrue("Incorrect number of messages logged for build. Should be 6. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 6);
164
		assertTrue("Incorrect number of messages logged for build. Should be 6. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 6);
Lines 175-181 Link Here
175
		ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
175
		ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
176
		Map properties= new HashMap(1);
176
		Map properties= new HashMap(1);
177
		properties.put("platform.location", "${workspace_loc}");
177
		properties.put("platform.location", "${workspace_loc}");
178
		copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, properties);
178
		copy.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
179
		launchAndTerminate(copy, 20000);
179
		launchAndTerminate(copy, 20000);
180
		ConsoleLineTracker.waitForConsole();
180
		ConsoleLineTracker.waitForConsole();
181
		assertTrue("Incorrect number of messages logged for build. Should be 6. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 6);
181
		assertTrue("Incorrect number of messages logged for build. Should be 6. Was " + ConsoleLineTracker.getNumberOfMessages(), ConsoleLineTracker.getNumberOfMessages() == 6);
(-)External Tools/org/eclipse/ant/tests/ui/externaltools/MigrationTests.java (-8 / +8 lines)
Lines 15-29 Link Here
15
15
16
import junit.framework.TestCase;
16
import junit.framework.TestCase;
17
17
18
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
19
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
19
import org.eclipse.ant.launching.IAntLaunchConstants;
20
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
21
import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration;
20
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.debug.core.DebugPlugin;
23
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
24
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
import org.eclipse.debug.ui.IDebugUIConstants;
25
import org.eclipse.debug.ui.IDebugUIConstants;
24
import org.eclipse.debug.ui.RefreshTab;
26
import org.eclipse.debug.ui.RefreshTab;
25
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
26
import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration;
27
27
28
/**
28
/**
29
 * Tests migration of Ant and External Tool configurations from old
29
 * Tests migration of Ant and External Tool configurations from old
Lines 42-52 Link Here
42
		ILaunchConfigurationWorkingCopy config = ExternalToolMigration.configFromArgumentMap(argumentMap);
42
		ILaunchConfigurationWorkingCopy config = ExternalToolMigration.configFromArgumentMap(argumentMap);
43
		assertNotNull("Migration failed", config);
43
		assertNotNull("Migration failed", config);
44
		
44
		
45
		assertEquals("Wrong configuration type", IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE, config.getType().getIdentifier());
45
		assertEquals("Wrong configuration type", IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE, config.getType().getIdentifier());
46
		assertEquals("ant tool", config.getName());
46
		assertEquals("ant tool", config.getName());
47
		assertEquals("location", config.getAttribute(IExternalToolConstants.ATTR_LOCATION, ""));
47
		assertEquals("location", config.getAttribute(IExternalToolConstants.ATTR_LOCATION, ""));
48
		assertEquals("refresh scope", config.getAttribute(RefreshTab.ATTR_REFRESH_SCOPE, ""));
48
		assertEquals("refresh scope", config.getAttribute(RefreshTab.ATTR_REFRESH_SCOPE, ""));
49
		String[] targets= AntUtil.getTargetNames(config);
49
		String[] targets= AntLaunchingUtil.getTargetNames(config);
50
		assertNotNull("No targets found", targets);
50
		assertNotNull("No targets found", targets);
51
		assertEquals("Wrong number of targets", 2, targets.length);
51
		assertEquals("Wrong number of targets", 2, targets.length);
52
		assertEquals("target1", targets[0]);
52
		assertEquals("target1", targets[0]);
Lines 131-137 Link Here
131
		ILaunchConfigurationWorkingCopy config = ExternalToolMigration.configFromArgumentMap(argumentMap);
131
		ILaunchConfigurationWorkingCopy config = ExternalToolMigration.configFromArgumentMap(argumentMap);
132
		assertNotNull("Migration failed", config);
132
		assertNotNull("Migration failed", config);
133
		
133
		
134
		assertEquals("Wrong config type", IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE, config.getType().getIdentifier());
134
		assertEquals("Wrong config type", IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE, config.getType().getIdentifier());
135
		assertEquals("ant config", config.getName());
135
		assertEquals("ant config", config.getName());
136
		assertEquals("location", config.getAttribute(IExternalToolConstants.ATTR_LOCATION, ""));
136
		assertEquals("location", config.getAttribute(IExternalToolConstants.ATTR_LOCATION, ""));
137
		assertEquals("working directory", config.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, ""));
137
		assertEquals("working directory", config.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, ""));
Lines 143-149 Link Here
143
		assertEquals(true, config.getAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, false));
143
		assertEquals(true, config.getAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, false));
144
		assertEquals("build kinds", config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, ""));
144
		assertEquals("build kinds", config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, ""));
145
		assertEquals("arg1 arg2", config.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""));
145
		assertEquals("arg1 arg2", config.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""));
146
		String[] targets= AntUtil.getTargetNames(config);
146
		String[] targets= AntLaunchingUtil.getTargetNames(config);
147
		assertEquals("Wrong number of targets", 2, targets.length);
147
		assertEquals("Wrong number of targets", 2, targets.length);
148
		assertEquals("target1", targets[0]);
148
		assertEquals("target1", targets[0]);
149
		assertEquals("target2", targets[1]);
149
		assertEquals("target2", targets[1]);
(-)META-INF/MANIFEST.MF (-1 / +3 lines)
Lines 35-39 Link Here
35
 org.eclipse.ant.ui,
35
 org.eclipse.ant.ui,
36
 org.eclipse.core.runtime,
36
 org.eclipse.core.runtime,
37
 org.eclipse.test.performance,
37
 org.eclipse.test.performance,
38
 org.eclipse.ui.console
38
 org.eclipse.ui.console,
39
 org.eclipse.ant.launching;bundle-version="1.0.0",
40
 org.eclipse.core.externaltools;bundle-version="1.0.0"
39
Bundle-ActivationPolicy: lazy
41
Bundle-ActivationPolicy: lazy
(-)test plugin/org/eclipse/ant/tests/ui/testplugin/AbstractAntUITest.java (-3 / +3 lines)
Lines 30-35 Link Here
30
import org.eclipse.ant.internal.ui.model.AntModel;
30
import org.eclipse.ant.internal.ui.model.AntModel;
31
import org.eclipse.ant.tests.ui.editor.support.TestLocationProvider;
31
import org.eclipse.ant.tests.ui.editor.support.TestLocationProvider;
32
import org.eclipse.ant.tests.ui.editor.support.TestProblemRequestor;
32
import org.eclipse.ant.tests.ui.editor.support.TestProblemRequestor;
33
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
33
import org.eclipse.core.resources.IFile;
34
import org.eclipse.core.resources.IFile;
34
import org.eclipse.core.resources.IFolder;
35
import org.eclipse.core.resources.IFolder;
35
import org.eclipse.core.resources.IProject;
36
import org.eclipse.core.resources.IProject;
Lines 53-59 Link Here
53
import org.eclipse.jface.text.Position;
54
import org.eclipse.jface.text.Position;
54
import org.eclipse.swt.graphics.Color;
55
import org.eclipse.swt.graphics.Color;
55
import org.eclipse.ui.console.IHyperlink;
56
import org.eclipse.ui.console.IHyperlink;
56
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
57
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
57
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
58
import org.eclipse.ui.internal.console.IOConsolePartition;
58
import org.eclipse.ui.internal.console.IOConsolePartition;
59
import org.xml.sax.InputSource;
59
import org.xml.sax.InputSource;
Lines 274-280 Link Here
274
    protected void launch(String buildFileName) throws CoreException {
274
    protected void launch(String buildFileName) throws CoreException {
275
        ILaunchConfiguration config = getLaunchConfiguration(buildFileName);
275
        ILaunchConfiguration config = getLaunchConfiguration(buildFileName);
276
        assertNotNull("Could not locate launch configuration for " + buildFileName, config);
276
        assertNotNull("Could not locate launch configuration for " + buildFileName, config);
277
        launchAndTerminate(config, 20000);
277
        launchAndTerminate(config, 2000000);
278
    }
278
    }
279
    
279
    
280
    /**
280
    /**
Lines 393-399 Link Here
393
     */
393
     */
394
    protected void launchAndTerminate(ILaunchConfiguration config, int timeout) throws CoreException {
394
    protected void launchAndTerminate(ILaunchConfiguration config, int timeout) throws CoreException {
395
        DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.TERMINATE, IProcess.class);
395
        DebugEventWaiter waiter= new DebugElementKindEventWaiter(DebugEvent.TERMINATE, IProcess.class);
396
        waiter.setTimeout(timeout);
396
        waiter.setTimeout(40000);
397
397
398
        Object terminatee = launchAndWait(config, waiter);      
398
        Object terminatee = launchAndWait(config, waiter);      
399
        assertNotNull("Program did not terminate.", terminatee);
399
        assertNotNull("Program did not terminate.", terminatee);
(-)test plugin/org/eclipse/ant/tests/ui/testplugin/ProjectHelper.java (-5 / +5 lines)
Lines 19-25 Link Here
19
import java.util.List;
19
import java.util.List;
20
20
21
import org.eclipse.ant.internal.ui.IAntUIConstants;
21
import org.eclipse.ant.internal.ui.IAntUIConstants;
22
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
22
import org.eclipse.ant.launching.IAntLaunchConstants;
23
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
23
import org.eclipse.core.resources.IFolder;
24
import org.eclipse.core.resources.IFolder;
24
import org.eclipse.core.resources.IProject;
25
import org.eclipse.core.resources.IProject;
25
import org.eclipse.core.resources.IProjectDescription;
26
import org.eclipse.core.resources.IProjectDescription;
Lines 40-46 Link Here
40
import org.eclipse.jdt.launching.IVMInstall;
41
import org.eclipse.jdt.launching.IVMInstall;
41
import org.eclipse.jdt.launching.JavaRuntime;
42
import org.eclipse.jdt.launching.JavaRuntime;
42
import org.eclipse.ui.dialogs.IOverwriteQuery;
43
import org.eclipse.ui.dialogs.IOverwriteQuery;
43
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
44
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
44
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
45
import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
45
import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider;
46
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
46
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
Lines 167-176 Link Here
167
	 */
167
	 */
168
	public static void createLaunchConfigurationForSeparateVM(String launchConfigName, String buildFileName) throws Exception {
168
	public static void createLaunchConfigurationForSeparateVM(String launchConfigName, String buildFileName) throws Exception {
169
		String bf = buildFileName;
169
		String bf = buildFileName;
170
		ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager().getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
170
		ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager().getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
171
		ILaunchConfigurationWorkingCopy config = type.newInstance(AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations"), launchConfigName);
171
		ILaunchConfigurationWorkingCopy config = type.newInstance(AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations"), launchConfigName);
172
		
172
		
173
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"); //$NON-NLS-1$
173
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.eclipse.ant.internal.launching.remote.InternalAntRunner"); //$NON-NLS-1$
174
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
174
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
175
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, AbstractAntUITest.getJavaProject().getElementName());
175
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, AbstractAntUITest.getJavaProject().getElementName());
176
		if (bf == null) {
176
		if (bf == null) {
Lines 216-222 Link Here
216
	 * @throws CoreException
216
	 * @throws CoreException
217
	 */
217
	 */
218
	public static ILaunchConfiguration createLaunchConfiguration(String launchConfigName, String path) throws CoreException {
218
	public static ILaunchConfiguration createLaunchConfiguration(String launchConfigName, String path) throws CoreException {
219
	    ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager().getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
219
	    ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager().getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
220
		ILaunchConfigurationWorkingCopy config = type.newInstance(AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations"), launchConfigName);
220
		ILaunchConfigurationWorkingCopy config = type.newInstance(AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations"), launchConfigName);
221
	
221
	
222
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, AbstractAntUITest.getJavaProject().getElementName());
222
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, AbstractAntUITest.getJavaProject().getElementName());
(-).classpath (-3 / +2 lines)
Lines 1-10 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="Ant Tools Support"/>
3
	<classpathentry kind="src" path="Ant Tools Support"/>
4
	<classpathentry output="ant_runner_support_bin" kind="src" path="Ant Runner Support"/>
4
	<classpathentry kind="src" output="ant_runner_support_bin" path="Ant Runner Support"/>
5
	<classpathentry kind="src" path="Ant Editor"/>
5
	<classpathentry kind="src" path="Ant Editor"/>
6
	<classpathentry output="remote_support_bin" kind="src" path="Remote Ant Support"/>
6
	<classpathentry kind="src" output="remote_support_bin" path="Remote Ant Support"/>
7
	<classpathentry output="common_ant_support_bin" kind="src" path="Common Ant Support"/>
8
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
7
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
9
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
8
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
10
	<classpathentry kind="output" path="bin"/>
9
	<classpathentry kind="output" path="bin"/>
(-)Ant Editor/org/eclipse/ant/internal/ui/editor/actions/RunToLineAdapter.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-22 Link Here
13
import java.util.HashMap;
13
import java.util.HashMap;
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
17
import org.eclipse.ant.internal.launching.debug.model.AntDebugElement;
18
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
19
import org.eclipse.ant.internal.ui.AntUIPlugin;
17
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
18
import org.eclipse.ant.internal.ui.debug.model.AntDebugElement;
19
import org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint;
20
import org.eclipse.core.resources.IFile;
20
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IMarker;
21
import org.eclipse.core.resources.IMarker;
22
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.CoreException;
(-)Ant Editor/org/eclipse/ant/internal/ui/editor/actions/ToggleLineBreakpointAction.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.editor.actions;
11
package org.eclipse.ant.internal.ui.editor.actions;
12
12
13
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
13
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
14
import org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint;
14
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
15
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.debug.core.DebugPlugin;
17
import org.eclipse.debug.core.DebugPlugin;
(-)Ant Editor/org/eclipse/ant/internal/ui/editor/text/AntAnnotationModel.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-21 Link Here
14
import java.util.Iterator;
14
import java.util.Iterator;
15
import java.util.List;
15
import java.util.List;
16
16
17
import org.eclipse.ant.internal.launching.debug.IAntDebugConstants;
17
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
19
import org.eclipse.ant.internal.ui.editor.outline.AntEditorMarkerUpdater;
19
import org.eclipse.ant.internal.ui.editor.outline.AntEditorMarkerUpdater;
20
import org.eclipse.ant.internal.ui.model.IProblem;
20
import org.eclipse.ant.internal.ui.model.IProblem;
21
import org.eclipse.ant.internal.ui.model.IProblemRequestor;
21
import org.eclipse.ant.internal.ui.model.IProblemRequestor;
(-)Ant Editor/org/eclipse/ant/internal/ui/editor/text/XMLTextHover.java (-13 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-40 Link Here
18
import org.apache.tools.ant.types.AbstractFileSet;
18
import org.apache.tools.ant.types.AbstractFileSet;
19
import org.apache.tools.ant.types.Path;
19
import org.apache.tools.ant.types.Path;
20
import org.apache.tools.ant.types.PatternSet;
20
import org.apache.tools.ant.types.PatternSet;
21
21
import org.eclipse.ant.internal.launching.debug.model.AntProperty;
22
import org.eclipse.swt.widgets.Shell;
22
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
23
23
import org.eclipse.ant.internal.launching.debug.model.AntValue;
24
import org.eclipse.ant.internal.ui.debug.model.AntProperty;
25
import org.eclipse.ant.internal.ui.debug.model.AntStackFrame;
26
import org.eclipse.ant.internal.ui.debug.model.AntValue;
27
import org.eclipse.ant.internal.ui.editor.AntEditor;
24
import org.eclipse.ant.internal.ui.editor.AntEditor;
28
import org.eclipse.ant.internal.ui.editor.AntEditorSourceViewerConfiguration;
25
import org.eclipse.ant.internal.ui.editor.AntEditorSourceViewerConfiguration;
29
import org.eclipse.ant.internal.ui.model.AntElementNode;
26
import org.eclipse.ant.internal.ui.model.AntElementNode;
30
import org.eclipse.ant.internal.ui.model.AntModel;
27
import org.eclipse.ant.internal.ui.model.AntModel;
31
import org.eclipse.ant.internal.ui.model.AntPropertyNode;
28
import org.eclipse.ant.internal.ui.model.AntPropertyNode;
32
import org.eclipse.ant.internal.ui.model.IAntModel;
29
import org.eclipse.ant.internal.ui.model.IAntModel;
33
34
import org.eclipse.core.runtime.IAdaptable;
30
import org.eclipse.core.runtime.IAdaptable;
35
31
import org.eclipse.debug.ui.DebugUITools;
36
import org.eclipse.jface.internal.text.html.HTMLPrinter;
32
import org.eclipse.jface.internal.text.html.HTMLPrinter;
37
38
import org.eclipse.jface.text.BadLocationException;
33
import org.eclipse.jface.text.BadLocationException;
39
import org.eclipse.jface.text.DefaultInformationControl;
34
import org.eclipse.jface.text.DefaultInformationControl;
40
import org.eclipse.jface.text.IDocument;
35
import org.eclipse.jface.text.IDocument;
Lines 50-60 Link Here
50
import org.eclipse.jface.text.source.Annotation;
45
import org.eclipse.jface.text.source.Annotation;
51
import org.eclipse.jface.text.source.IAnnotationModel;
46
import org.eclipse.jface.text.source.IAnnotationModel;
52
import org.eclipse.jface.text.source.ISourceViewer;
47
import org.eclipse.jface.text.source.ISourceViewer;
53
48
import org.eclipse.swt.widgets.Shell;
54
import org.eclipse.ui.editors.text.EditorsUI;
49
import org.eclipse.ui.editors.text.EditorsUI;
55
50
56
import org.eclipse.debug.ui.DebugUITools;
57
58
51
59
public class XMLTextHover implements ITextHover, ITextHoverExtension, IInformationProviderExtension2 {
52
public class XMLTextHover implements ITextHover, ITextHoverExtension, IInformationProviderExtension2 {
60
53
(-)Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/AntSupportMessages.java (-11 / +1 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 19-34 Link Here
19
	public static String AntInputHandler_Unable_to_respond_to__input__request_4;
19
	public static String AntInputHandler_Unable_to_respond_to__input__request_4;
20
	public static String AntInputHandler_5;
20
	public static String AntInputHandler_5;
21
21
22
	public static String NullBuildLogger_1;
23
	public static String AntProcessBuildLogger_Total_time;
24
	public static String AntProcessBuildLogger__minutes_2;
25
	public static String AntProcessBuildLogger__minute_3;
26
	public static String AntProcessBuildLogger__seconds_4;
27
	public static String AntProcessBuildLogger__second_5;
28
	public static String AntProcessBuildLogger__milliseconds_6;
29
	
30
	public static String AntProcessDebugBuildLogger_1;
31
32
	static {
22
	static {
33
		// load message values from bundle file
23
		// load message values from bundle file
34
		NLS.initializeMessages(BUNDLE_NAME, AntSupportMessages.class);
24
		NLS.initializeMessages(BUNDLE_NAME, AntSupportMessages.class);
(-)Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/AntSupportMessages.properties (-11 / +1 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2005 IBM Corporation and others.
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 13-25 Link Here
13
AntInputHandler_Invalid_input_2=Input does not match validargs attribute
13
AntInputHandler_Invalid_input_2=Input does not match validargs attribute
14
AntInputHandler_Unable_to_respond_to__input__request_4=Unable to respond to <input> request
14
AntInputHandler_Unable_to_respond_to__input__request_4=Unable to respond to <input> request
15
AntInputHandler_5=Unable to respond to input request as a result of the user specified -noinput command
15
AntInputHandler_5=Unable to respond to input request as a result of the user specified -noinput command
16
17
NullBuildLogger_1=BUILD FAILED
18
AntProcessBuildLogger_Total_time=Total time: 
19
AntProcessBuildLogger__minutes_2=\ minutes
20
AntProcessBuildLogger__minute_3=\ minute
21
AntProcessBuildLogger__seconds_4=\ seconds
22
AntProcessBuildLogger__second_5=\ second
23
AntProcessBuildLogger__milliseconds_6=\ milliseconds
24
25
AntProcessDebugBuildLogger_1=Build cancelled.
(-)Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessBuildLogger.java (-350 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Matt Conway - Patch for Bug 28052
11
 *******************************************************************************/
12
13
package org.eclipse.ant.internal.ui.antsupport.logger;
14
15
import java.io.BufferedReader;
16
import java.io.File;
17
import java.io.IOException;
18
import java.io.StringReader;
19
import java.util.HashMap;
20
import java.util.Map;
21
22
import org.apache.tools.ant.BuildEvent;
23
import org.apache.tools.ant.Location;
24
import org.apache.tools.ant.Project;
25
import org.apache.tools.ant.Target;
26
import org.apache.tools.ant.util.FileUtils;
27
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
28
import org.eclipse.ant.internal.ui.AntUtil;
29
import org.eclipse.ant.internal.ui.ExternalHyperlink;
30
import org.eclipse.ant.internal.ui.IAntUIConstants;
31
import org.eclipse.ant.internal.ui.antsupport.AntSupportMessages;
32
import org.eclipse.ant.internal.ui.antsupport.logger.util.AntDebugState;
33
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
34
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamMonitor;
35
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy;
36
import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager;
37
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.runtime.OperationCanceledException;
39
import org.eclipse.debug.core.DebugPlugin;
40
import org.eclipse.debug.core.model.IProcess;
41
import org.eclipse.debug.ui.console.FileLink;
42
import org.eclipse.jface.text.IRegion;
43
import org.eclipse.jface.text.Region;
44
import org.eclipse.ui.console.IHyperlink;
45
	
46
public class AntProcessBuildLogger extends NullBuildLogger {
47
	
48
	private File fBuildFileParent= null;
49
	private long fStartTime;
50
    private Map fFileNameToIFile= new HashMap();
51
52
	/**
53
	 * Associated process - discovered as needed to log messages
54
	 */
55
	private AntProcess fProcess = null;
56
	
57
	protected void logMessage(String message, BuildEvent event, int overridePriority) {
58
		int priority= overridePriority;
59
		if (priority == -1) {
60
			priority= event.getPriority();
61
		} 
62
		
63
		if (priority > getMessageOutputLevel()) {
64
			return;
65
		}
66
		AntProcess antProcess = getAntProcess(fProcessId);
67
		if (antProcess == null) {
68
			return;
69
		}
70
		
71
		StringBuffer fullMessage= new StringBuffer();
72
		 if (!loggingToLogFile()) {
73
			fullMessage.append(System.getProperty("line.separator")); //$NON-NLS-1$
74
		}
75
		if (event.getException() == null && event.getTask() != null && !fEmacsMode) {
76
			adornMessage(event, fullMessage);
77
		} else {
78
			fullMessage.append(message);
79
		}
80
		message= fullMessage.toString();
81
		
82
		if (loggingToLogFile()) {
83
			logMessageToLogFile(message, priority);
84
		} else {
85
			AntStreamMonitor monitor = getMonitor(priority);
86
			monitor.append(message);
87
		}
88
	}
89
90
	/**
91
	 * Builds a right justified task prefix for the given build event, placing it
92
	 * in the given string buffer. Creates the hyperlinks for the task prefix. 
93
	 *  
94
	 * @param event build event
95
	 * @param fullMessage buffer to place task prefix in
96
	 */
97
	private void adornMessage(BuildEvent event, StringBuffer fullMessage) {
98
		String name = event.getTask().getTaskName();
99
		if (name == null) {
100
			name = "null"; //$NON-NLS-1$
101
		}
102
		Location location = event.getTask().getLocation();
103
		StringBuffer column= new StringBuffer();
104
		int size = IAntUIConstants.LEFT_COLUMN_SIZE - (name.length() + 3);
105
		for (int i = 0; i < size; i++) {
106
			column.append(' ');
107
		}
108
		StringBuffer labelBuff= new StringBuffer();
109
		labelBuff.append('[');
110
		labelBuff.append(name);
111
		labelBuff.append("] "); //$NON-NLS-1$
112
		
113
		int offset = Math.max(size, 0) + 1;
114
		String label= labelBuff.toString();
115
		if (event.getMessage() == null) {
116
			return;
117
		}
118
		try {
119
			BufferedReader r = new BufferedReader(new StringReader(event.getMessage()));
120
			String line = r.readLine();
121
			fullMessage.append(column);
122
			appendAndLink(fullMessage, location, label, offset, line);
123
			line = r.readLine();
124
			while (line != null) {
125
				fullMessage.append(System.getProperty("line.separator")); //$NON-NLS-1$
126
				fullMessage.append(column);
127
				appendAndLink(fullMessage, location, label, offset, line);
128
				line = r.readLine();
129
			}
130
		} catch (IOException e) {
131
			if (event.getMessage() != null) {
132
				fullMessage.append(label).append(event.getMessage());
133
			}
134
		}
135
	}
136
	
137
	private void appendAndLink(StringBuffer fullMessage, Location location, String label, int offset, String line) {
138
		fullMessage.append(label);
139
		fullMessage.append(line);
140
		if (location != null) {
141
			String newLine= (label + line).trim();
142
			IRegion region= new Region(offset, label.length() - 3); // only want the name length "[name] "
143
			IHyperlink link= getLocationLink(location);
144
			if (link != null) {
145
				TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, newLine);
146
			}
147
		}
148
	}
149
150
	private AntStreamMonitor getMonitor(int priority) {
151
		AntStreamsProxy proxy = (AntStreamsProxy)fProcess.getStreamsProxy();
152
		AntStreamMonitor monitor = null;
153
		switch (priority) {
154
			case Project.MSG_INFO:
155
				monitor = (AntStreamMonitor)proxy.getOutputStreamMonitor();
156
				break;
157
			case Project.MSG_ERR:
158
				monitor = (AntStreamMonitor)proxy.getErrorStreamMonitor();
159
				break;
160
			case Project.MSG_DEBUG:
161
				monitor = (AntStreamMonitor)proxy.getDebugStreamMonitor();
162
				break;
163
			case Project.MSG_WARN:
164
				monitor = (AntStreamMonitor)proxy.getWarningStreamMonitor();
165
				break;
166
			case Project.MSG_VERBOSE:
167
				monitor = (AntStreamMonitor)proxy.getVerboseStreamMonitor();
168
				break;
169
		}
170
		return monitor;
171
	}
172
173
	private void logMessageToLogFile(String message, int priority) {
174
		if (priority == Project.MSG_ERR) {
175
			getErrorPrintStream().println(message);
176
		} else {
177
			getOutputPrintStream().println(message);
178
		}
179
	}
180
	
181
	/**
182
	 * Returns a hyperlink for the given task, or <code>null</code> if unable to
183
	 * parse a valid location for the task. The link is set to exist at the specified
184
	 * offset and length.
185
	 * 
186
	 * @return hyper link, or <code>null</code>
187
	 */
188
	private IHyperlink getLocationLink(Location location) {
189
		if (location != null && !location.equals(Location.UNKNOWN_LOCATION)) {
190
            try {
191
                String fileName= location.getFileName();
192
                IFile file= (IFile) fFileNameToIFile.get(fileName);
193
                int lineNumber= location.getLineNumber();
194
                if (file != null) {
195
                    return new FileLink(file, null, -1, -1, lineNumber);
196
                } 
197
                file= AntUtil.getFileForLocation(fileName, fBuildFileParent);
198
                if (file != null) {
199
                    fFileNameToIFile.put(fileName, file);
200
                    return new FileLink(file, null, -1, -1, lineNumber);
201
                }
202
                //maintain backwards compatibility
203
                File javaIOFile= FileUtils.newFileUtils().resolveFile(fBuildFileParent, fileName);
204
                if (javaIOFile.exists()) {
205
                    return new ExternalHyperlink(javaIOFile, lineNumber);
206
                }
207
            } catch (NoSuchMethodError e) {
208
                //support for Ant older than 1.6
209
                return AntUtil.getLocationLink(location.toString(), fBuildFileParent);
210
            }
211
		}
212
		return null;
213
	}	
214
	
215
	/**
216
	 * Returns the associated Ant process, finding it if necessary, if not
217
	 * already found.
218
	 */
219
	protected AntProcess getAntProcess(String processId) {
220
		if (fProcess == null && processId != null) {
221
			IProcess[] all = DebugPlugin.getDefault().getLaunchManager().getProcesses();
222
			for (int i = 0; i < all.length; i++) {
223
				IProcess process = all[i];
224
				if (process instanceof AntProcess && processId.equals(process.getAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID))) {
225
					fProcess = (AntProcess)process;
226
					break;
227
				}
228
			}
229
		}
230
		return fProcess;
231
	}
232
233
	/* (non-Javadoc)
234
	 * Set the start time.
235
	 * 
236
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
237
	 */
238
	public void buildStarted(BuildEvent event) {
239
		fStartTime= System.currentTimeMillis();
240
	}
241
	
242
	/* (non-Javadoc)
243
	 * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
244
	 */
245
	public void buildFinished(BuildEvent event) {
246
        String message= handleException(event);
247
        if (message != null) {
248
        	try {
249
    			BufferedReader r = new BufferedReader(new StringReader(message));
250
    			String line = r.readLine();
251
    			logMessage(line, event, Project.MSG_ERR);
252
    			line = r.readLine();
253
    			AntProcess antProcess = getAntProcess(fProcessId);
254
    			while (line != null) {
255
    				logMessage(line, event, Project.MSG_ERR);
256
    				if (!message.startsWith("Total time:")) { //$NON-NLS-1$
257
    					AntUtil.linkBuildFailedMessage(line, antProcess);
258
    				}
259
    				line = r.readLine();
260
    			}
261
    			logMessage("", event, Project.MSG_ERR); //$NON-NLS-1$
262
    		} catch (IOException e) {
263
    		}
264
        }
265
		fHandledException= null;
266
		fBuildFileParent= null;
267
		if (!(event.getException() instanceof OperationCanceledException)) {
268
			logMessage(getTimeString(System.currentTimeMillis() - fStartTime), event, fMessageOutputLevel);
269
		}
270
		fProcess= null;
271
		event.getProject().removeBuildListener(this);
272
        fFileNameToIFile= null;
273
	}
274
	
275
	private String getTimeString(long milliseconds) {
276
			long seconds = milliseconds / 1000;
277
			long minutes = seconds / 60;
278
			seconds= seconds % 60;
279
		
280
			StringBuffer result= new StringBuffer(AntSupportMessages.AntProcessBuildLogger_Total_time);
281
			if (minutes > 0) {
282
				result.append(minutes);
283
				if (minutes > 1) {
284
					result.append(AntSupportMessages.AntProcessBuildLogger__minutes_2);
285
				} else {
286
					result.append(AntSupportMessages.AntProcessBuildLogger__minute_3);
287
				}
288
			}
289
			if (seconds > 0) {
290
				if (minutes > 0) {
291
					result.append(' ');
292
				}
293
				result.append(seconds);
294
			
295
				if (seconds > 1) {
296
					result.append(AntSupportMessages.AntProcessBuildLogger__seconds_4);
297
				} else {
298
					result.append(AntSupportMessages.AntProcessBuildLogger__second_5);
299
				} 
300
			}
301
			if (seconds == 0 && minutes == 0) {
302
				result.append(milliseconds);
303
				result.append(AntSupportMessages.AntProcessBuildLogger__milliseconds_6);
304
			}
305
			
306
			result.append(System.getProperty("line.separator")); //$NON-NLS-1$
307
			return result.toString();
308
		}
309
	
310
	/* (non-Javadoc)
311
	 * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
312
	 */
313
	public void messageLogged(BuildEvent event) {
314
		if (event.getPriority() > getMessageOutputLevel()) {
315
			return;
316
		}
317
		if (event.getMessage() != null && event.getMessage().length() > 0) {
318
			logMessage(event.getMessage(), event, -1);
319
		}
320
	}
321
322
	/* (non-Javadoc)
323
	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
324
	 */
325
	public void targetStarted(BuildEvent event) {
326
		if (Project.MSG_INFO > getMessageOutputLevel()) {
327
			return;
328
		}
329
		Target target= event.getTarget();
330
		StringBuffer msg= new StringBuffer(System.getProperty("line.separator")); //$NON-NLS-1$
331
		String targetName= target.getName();
332
		msg.append(targetName);
333
		msg.append(':');
334
		String message= msg.toString();
335
		Location location= AntDebugState.getLocation(target);
336
		if (location != null && location != Location.UNKNOWN_LOCATION) {
337
			IRegion region= new Region(0, targetName.length());
338
			IHyperlink link= getLocationLink(location);
339
			if (link != null) {
340
				TaskLinkManager.addTaskHyperlink(getAntProcess(fProcessId), link, region, message.trim());
341
			}
342
		}
343
		logMessage(message, event, Project.MSG_INFO);
344
	}
345
	
346
	private boolean loggingToLogFile() {
347
		//check if user has designated to log to a log file
348
		return getErrorPrintStream() != null && getErrorPrintStream() != System.err;
349
	}
350
}
(-)Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/AntProcessDebugBuildLogger.java (-247 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger;
12
13
import java.io.File;
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.apache.tools.ant.BuildEvent;
18
import org.apache.tools.ant.Location;
19
import org.eclipse.ant.internal.ui.antsupport.AntSupportMessages;
20
import org.eclipse.ant.internal.ui.antsupport.logger.util.AntDebugState;
21
import org.eclipse.ant.internal.ui.antsupport.logger.util.IDebugBuildLogger;
22
import org.eclipse.ant.internal.ui.debug.IAntDebugController;
23
import org.eclipse.ant.internal.ui.debug.model.AntDebugTarget;
24
import org.eclipse.ant.internal.ui.debug.model.AntThread;
25
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
26
import org.eclipse.core.resources.IFile;
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.OperationCanceledException;
29
import org.eclipse.debug.core.DebugEvent;
30
import org.eclipse.debug.core.ILaunch;
31
import org.eclipse.debug.core.model.IBreakpoint;
32
import org.eclipse.debug.core.model.ILineBreakpoint;
33
import org.eclipse.debug.core.model.IProcess;
34
35
public class AntProcessDebugBuildLogger extends AntProcessBuildLogger implements IAntDebugController, IDebugBuildLogger {
36
	
37
	private AntDebugState fDebugState= null;
38
	
39
	private List fBreakpoints= null;
40
    
41
	private AntDebugTarget fAntDebugTarget;
42
	private boolean fResumed= false;
43
	
44
	/* (non-Javadoc)
45
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
46
	 */
47
	public void buildStarted(BuildEvent event) {
48
		fDebugState= new AntDebugState(this);
49
		super.buildStarted(event);
50
		IProcess process= getAntProcess(fProcessId);
51
		ILaunch launch= process.getLaunch();
52
		fAntDebugTarget= new AntDebugTarget(launch, process, this);
53
		launch.addDebugTarget(fAntDebugTarget);
54
        
55
        fAntDebugTarget.buildStarted();
56
        fDebugState.buildStarted();
57
	}
58
59
	/* (non-Javadoc)
60
	 * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
61
	 */
62
	public void taskFinished(BuildEvent event) {
63
		super.taskFinished(event);
64
		fDebugState.taskFinished();
65
	}
66
	
67
	/* (non-Javadoc)
68
	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
69
	 */
70
	public void taskStarted(BuildEvent event) {
71
        super.taskStarted(event);
72
		fDebugState.taskStarted(event);
73
	}
74
	
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.util.IDebugBuildLogger#waitIfSuspended()
77
	 */
78
	public synchronized void waitIfSuspended() {
79
		fResumed= false;
80
		IBreakpoint breakpoint= breakpointAtLineNumber(fDebugState.getBreakpointLocation());
81
		if (breakpoint != null) {
82
			 fAntDebugTarget.breakpointHit(breakpoint);
83
			 try {
84
				 while (!fResumed) {
85
					 wait(500);
86
					 checkCancelled();
87
				 }
88
			 } catch (InterruptedException e) {
89
			 }
90
		} else if (fDebugState.getCurrentTask() != null) {
91
			int detail= -1;
92
	        boolean shouldSuspend= true;
93
	        if (fDebugState.isStepIntoSuspend()) {
94
	            detail= DebugEvent.STEP_END;
95
	            fDebugState.setStepIntoSuspend(false);               
96
	        } else if ((fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fDebugState.getStepOverTask()) || fDebugState.shouldSuspend()) {
97
				detail= DebugEvent.STEP_END;
98
				fDebugState.setShouldSuspend(false);
99
				fDebugState.setStepOverTask(null);
100
	        } else if (fDebugState.isClientSuspend()) {
101
	            detail= DebugEvent.CLIENT_REQUEST;
102
	            fDebugState.setClientSuspend(false);
103
	        } else {
104
	            shouldSuspend= false;
105
	        }
106
	        if (shouldSuspend) {
107
                fAntDebugTarget.suspended(detail);
108
	            try {
109
	            	while (!fResumed) {
110
	            		wait(500);
111
	            		checkCancelled();
112
	            	}
113
	            } catch (InterruptedException e) {
114
	            }
115
	        }
116
	    }
117
	}
118
119
	private void checkCancelled() {
120
		AntProcess process= getAntProcess(fProcessId);
121
		if (process != null && process.isCanceled()) {
122
			throw new OperationCanceledException(AntSupportMessages.AntProcessDebugBuildLogger_1);
123
		}
124
	}
125
126
	/* (non-Javadoc)
127
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#resume()
128
	 */
129
	public synchronized void resume() {
130
		fResumed= true;
131
        notifyAll();
132
	}
133
134
	/* (non-Javadoc)
135
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#suspend()
136
	 */
137
	public synchronized void suspend() {
138
		fDebugState.setClientSuspend(true);
139
	}
140
141
	/* (non-Javadoc)
142
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepInto()
143
	 */
144
	public synchronized void stepInto() {
145
		fDebugState.setStepIntoSuspend(true);
146
		fResumed= true;
147
		notifyAll();
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepOver()
152
	 */
153
	public synchronized void stepOver() {
154
		fResumed= true;
155
		fDebugState.stepOver();
156
	}
157
158
	/* (non-Javadoc)
159
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#handleBreakpoint(org.eclipse.debug.core.model.IBreakpoint, boolean)
160
	 */
161
	public void handleBreakpoint(IBreakpoint breakpoint, boolean added) {
162
		if (added) {
163
			if (fBreakpoints == null) {
164
				fBreakpoints= new ArrayList();
165
			}
166
			if (!fBreakpoints.contains(breakpoint)) {
167
				fBreakpoints.add(breakpoint);
168
			}
169
		} else {
170
			if (fBreakpoints != null) {
171
				fBreakpoints.remove(breakpoint);
172
			}
173
		}
174
	}
175
176
	/* (non-Javadoc)
177
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getProperties()
178
	 */
179
	public void getProperties() {
180
		if (!fAntDebugTarget.isSuspended()) {
181
			return;
182
		}
183
	    StringBuffer propertiesRepresentation= new StringBuffer();
184
		fDebugState.marshallProperties(propertiesRepresentation, false);
185
		if (fAntDebugTarget.getThreads().length > 0) {
186
			((AntThread) fAntDebugTarget.getThreads()[0]).newProperties(propertiesRepresentation.toString());
187
		}
188
	}
189
190
	/* (non-Javadoc)
191
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getStackFrames()
192
	 */
193
	public void getStackFrames() {
194
		StringBuffer stackRepresentation= new StringBuffer();
195
		fDebugState.marshalStack(stackRepresentation);
196
		((AntThread) fAntDebugTarget.getThreads()[0]).buildStack(stackRepresentation.toString());
197
	}
198
    
199
    private IBreakpoint breakpointAtLineNumber(Location location) {
200
        if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
201
            return null;
202
        }
203
        int lineNumber= fDebugState.getLineNumber(location);
204
        File locationFile= new File(fDebugState.getFileName(location));
205
        for (int i = 0; i < fBreakpoints.size(); i++) {
206
            ILineBreakpoint breakpoint = (ILineBreakpoint) fBreakpoints.get(i);
207
            int breakpointLineNumber;
208
            try {
209
            	if (!breakpoint.isEnabled()) {
210
                	continue;
211
                }
212
            	breakpointLineNumber = breakpoint.getLineNumber();
213
            } catch (CoreException e) {
214
               return null;
215
            }
216
            IFile resource= (IFile) breakpoint.getMarker().getResource();
217
            if (breakpointLineNumber == lineNumber && resource.getLocation().toFile().equals(locationFile)) {
218
                return breakpoint;
219
            }
220
        }
221
        return null;
222
    }
223
    
224
    /* (non-Javadoc)
225
     * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
226
     */
227
    public void targetStarted(BuildEvent event) {
228
		fDebugState.targetStarted(event);
229
		waitIfSuspended();
230
		super.targetStarted(event);
231
    }
232
	
233
	/* (non-Javadoc)
234
	 * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
235
	 */
236
	public void targetFinished(BuildEvent event) {
237
		super.targetFinished(event);
238
		fDebugState.setTargetExecuting(null);
239
	}
240
241
	/* (non-Javadoc)
242
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#unescapeString(java.lang.StringBuffer)
243
	 */
244
	public StringBuffer unescapeString(StringBuffer propertyValue) {
245
		return propertyValue;
246
	}
247
}
(-)Ant Runner Support/org/eclipse/ant/internal/ui/antsupport/logger/NullBuildLogger.java (-180 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger;
12
13
14
import java.io.PrintStream;
15
16
import org.apache.tools.ant.BuildEvent;
17
import org.apache.tools.ant.BuildException;
18
import org.apache.tools.ant.BuildLogger;
19
import org.apache.tools.ant.Project;
20
import org.apache.tools.ant.util.StringUtils;
21
import org.eclipse.ant.core.AntSecurityException;
22
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
23
import org.eclipse.ant.internal.ui.antsupport.AntSupportMessages;
24
import org.eclipse.core.runtime.OperationCanceledException;
25
26
public class NullBuildLogger extends AbstractEclipseBuildLogger implements BuildLogger{
27
28
	protected int fMessageOutputLevel = Project.MSG_INFO;
29
	private PrintStream fErr= null;
30
	private PrintStream fOut= null;
31
	protected boolean fEmacsMode= false;
32
	
33
	/**
34
	 * An exception that has already been logged.
35
	 */
36
	protected Throwable fHandledException= null;
37
	
38
	/**
39
	 * @see org.apache.tools.ant.BuildLogger#setMessageOutputLevel(int)
40
	 */
41
	public void setMessageOutputLevel(int level) {
42
		fMessageOutputLevel= level;
43
	}
44
	
45
	protected int getMessageOutputLevel() {
46
		return fMessageOutputLevel;
47
	}
48
49
	/**
50
	 * @see org.apache.tools.ant.BuildLogger#setEmacsMode(boolean)
51
	 */
52
	public void setEmacsMode(boolean emacsMode) {
53
		fEmacsMode= emacsMode;
54
	}
55
56
	/**
57
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
58
	 */
59
	public void buildStarted(BuildEvent event) {
60
	}
61
62
	/**
63
	 * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
64
	 */
65
	public void buildFinished(BuildEvent event) {
66
		String message= handleException(event);
67
        if (message != null) {
68
            logMessage(message, getMessageOutputLevel());
69
        }
70
		fHandledException= null;
71
	}
72
73
	/**
74
	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
75
	 */
76
	public void targetStarted(BuildEvent event) {
77
	}
78
79
	/**
80
	 * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
81
	 */
82
	public void targetFinished(BuildEvent event) {
83
	}
84
85
	/**
86
	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
87
	 */
88
	public void taskStarted(BuildEvent event) {
89
	}
90
91
	/**
92
	 * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
93
	 */
94
	public void taskFinished(BuildEvent event) {
95
	}
96
97
	/* (non-Javadoc)
98
	 * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
99
	 */
100
	public void messageLogged(BuildEvent event) {
101
		logMessage(event.getMessage(), event.getPriority());
102
	}
103
104
	protected PrintStream getErrorPrintStream() {
105
		return fErr;
106
	}
107
	
108
	protected PrintStream getOutputPrintStream() {
109
		return fOut;
110
	}
111
	
112
	/**
113
	 * @see org.apache.tools.ant.BuildLogger#setErrorPrintStream(java.io.PrintStream)
114
	 */
115
	public void setErrorPrintStream(PrintStream err) {
116
		//this build logger logs to "null" unless
117
		//the user has explicitly set a logfile to use
118
		if (err == System.err) {
119
			fErr= null;
120
		} else {
121
			fErr= err;
122
		}
123
	}
124
125
	/**
126
	 * @see org.apache.tools.ant.BuildLogger#setOutputPrintStream(java.io.PrintStream)
127
	 */
128
	public void setOutputPrintStream(PrintStream output) {
129
		//this build logger logs to "null" unless
130
		//the user has explicitly set a logfile to use
131
		if (output == System.out) {
132
			fOut= null;
133
		} else {
134
			fOut= output;
135
		}
136
	}
137
	
138
	protected void logMessage(String message, int priority) {
139
		if (priority > getMessageOutputLevel()) {
140
			return;
141
		}
142
		
143
		if (priority == Project.MSG_ERR) {
144
			if (getErrorPrintStream() != null && getErrorPrintStream() != System.err) {
145
				//user has designated to log to a logfile
146
				getErrorPrintStream().println(message);
147
			}
148
		} else {
149
			if (getOutputPrintStream() != null && getOutputPrintStream() != System.out) {
150
				//user has designated to log to a logfile
151
				getOutputPrintStream().println(message);
152
			} 
153
		}
154
	}
155
	
156
	protected String handleException(BuildEvent event) {
157
		Throwable exception = event.getException();
158
		if (exception == null || exception == fHandledException
159
		|| exception instanceof OperationCanceledException
160
		|| exception instanceof AntSecurityException) {
161
			return null;
162
		}
163
		fHandledException= exception;
164
        StringBuffer message= new StringBuffer();
165
        message.append(StringUtils.LINE_SEP);
166
        message.append(AntSupportMessages.NullBuildLogger_1);
167
        message.append(StringUtils.LINE_SEP);
168
        if (Project.MSG_VERBOSE <= fMessageOutputLevel || !(exception instanceof BuildException)) {
169
            message.append(StringUtils.getStackTrace(exception));
170
        } else {
171
            if (exception instanceof BuildException) {
172
                message.append(exception.toString()).append(StringUtils.LINE_SEP);
173
            } else {
174
                message.append(exception.getMessage()).append(StringUtils.LINE_SEP);
175
            }
176
        }
177
        
178
		return message.toString();	
179
	}
180
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/AntUIPreferenceInitializer.java (-4 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 34-42 Link Here
34
		prefs.setDefault(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, "build.xml"); //$NON-NLS-1$
34
		prefs.setDefault(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, "build.xml"); //$NON-NLS-1$
35
		
35
		
36
		prefs.setDefault(IAntUIPreferenceConstants.DOCUMENTATION_URL, "http://ant.apache.org/manual"); //$NON-NLS-1$
36
		prefs.setDefault(IAntUIPreferenceConstants.DOCUMENTATION_URL, "http://ant.apache.org/manual"); //$NON-NLS-1$
37
        
37
	
38
        prefs.setDefault(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, 20000);
39
		
40
		EditorsUI.useAnnotationsPreferencePage(prefs);
38
		EditorsUI.useAnnotationsPreferencePage(prefs);
41
		EditorsUI.useQuickDiffPreferencePage(prefs);
39
		EditorsUI.useQuickDiffPreferencePage(prefs);
42
		if (AntUIPlugin.isMacOS()) {
40
		if (AntUIPlugin.isMacOS()) {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/AntUtil.java (-234 / +16 lines)
Lines 11-17 Link Here
11
package org.eclipse.ant.internal.ui;
11
package org.eclipse.ant.internal.ui;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
15
import java.net.MalformedURLException;
14
import java.net.MalformedURLException;
16
import java.net.URL;
15
import java.net.URL;
17
import java.util.ArrayList;
16
import java.util.ArrayList;
Lines 20-50 Link Here
20
import java.util.Iterator;
19
import java.util.Iterator;
21
import java.util.List;
20
import java.util.List;
22
import java.util.Map;
21
import java.util.Map;
23
import java.util.StringTokenizer;
24
import java.util.regex.Pattern;
22
import java.util.regex.Pattern;
25
23
26
import org.apache.tools.ant.BuildException;
27
import org.apache.tools.ant.Target;
24
import org.apache.tools.ant.Target;
28
import org.apache.tools.ant.util.FileUtils;
29
import org.eclipse.ant.core.AntCorePlugin;
25
import org.eclipse.ant.core.AntCorePlugin;
30
import org.eclipse.ant.internal.core.AntCoreUtil;
26
import org.eclipse.ant.internal.core.AntCoreUtil;
27
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
31
import org.eclipse.ant.internal.ui.editor.AntEditor;
28
import org.eclipse.ant.internal.ui.editor.AntEditor;
32
import org.eclipse.ant.internal.ui.launchConfigurations.AntHomeClasspathEntry;
33
import org.eclipse.ant.internal.ui.launchConfigurations.TaskLinkManager;
34
import org.eclipse.ant.internal.ui.model.AntElementNode;
29
import org.eclipse.ant.internal.ui.model.AntElementNode;
35
import org.eclipse.ant.internal.ui.model.AntModel;
30
import org.eclipse.ant.internal.ui.model.AntModel;
36
import org.eclipse.ant.internal.ui.model.AntProjectNode;
31
import org.eclipse.ant.internal.ui.model.AntProjectNode;
37
import org.eclipse.ant.internal.ui.model.AntTargetNode;
32
import org.eclipse.ant.internal.ui.model.AntTargetNode;
38
import org.eclipse.ant.internal.ui.model.IAntModel;
33
import org.eclipse.ant.internal.ui.model.IAntModel;
39
import org.eclipse.ant.internal.ui.model.LocationProvider;
34
import org.eclipse.ant.internal.ui.model.LocationProvider;
40
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
35
import org.eclipse.ant.launching.IAntLaunchConstants;
36
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
41
import org.eclipse.core.filebuffers.FileBuffers;
37
import org.eclipse.core.filebuffers.FileBuffers;
42
import org.eclipse.core.filebuffers.ITextFileBuffer;
38
import org.eclipse.core.filebuffers.ITextFileBuffer;
43
import org.eclipse.core.filebuffers.ITextFileBufferManager;
39
import org.eclipse.core.filebuffers.ITextFileBufferManager;
44
import org.eclipse.core.filebuffers.LocationKind;
40
import org.eclipse.core.filebuffers.LocationKind;
45
import org.eclipse.core.resources.IFile;
41
import org.eclipse.core.resources.IFile;
46
import org.eclipse.core.resources.IWorkspaceRoot;
47
import org.eclipse.core.resources.ResourcesPlugin;
48
import org.eclipse.core.runtime.CoreException;
42
import org.eclipse.core.runtime.CoreException;
49
import org.eclipse.core.runtime.IPath;
43
import org.eclipse.core.runtime.IPath;
50
import org.eclipse.core.runtime.IStatus;
44
import org.eclipse.core.runtime.IStatus;
Lines 54-70 Link Here
54
import org.eclipse.core.variables.IStringVariableManager;
48
import org.eclipse.core.variables.IStringVariableManager;
55
import org.eclipse.core.variables.VariablesPlugin;
49
import org.eclipse.core.variables.VariablesPlugin;
56
import org.eclipse.debug.core.ILaunchConfiguration;
50
import org.eclipse.debug.core.ILaunchConfiguration;
57
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
58
import org.eclipse.debug.core.model.IProcess;
59
import org.eclipse.debug.ui.console.FileLink;
51
import org.eclipse.debug.ui.console.FileLink;
60
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
61
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
62
import org.eclipse.jdt.launching.IRuntimeClasspathEntry2;
63
import org.eclipse.jdt.launching.JavaRuntime;
64
import org.eclipse.jface.dialogs.MessageDialog;
52
import org.eclipse.jface.dialogs.MessageDialog;
65
import org.eclipse.jface.text.BadLocationException;
53
import org.eclipse.jface.text.BadLocationException;
66
import org.eclipse.jface.text.IDocument;
54
import org.eclipse.jface.text.IDocument;
67
import org.eclipse.jface.text.Region;
68
import org.eclipse.swt.SWT;
55
import org.eclipse.swt.SWT;
69
import org.eclipse.swt.program.Program;
56
import org.eclipse.swt.program.Program;
70
import org.eclipse.swt.widgets.Shell;
57
import org.eclipse.swt.widgets.Shell;
Lines 79-86 Link Here
79
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
66
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
80
import org.eclipse.ui.console.IHyperlink;
67
import org.eclipse.ui.console.IHyperlink;
81
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
68
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
82
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
83
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
84
import org.eclipse.ui.ide.IDE;
69
import org.eclipse.ui.ide.IDE;
85
import org.eclipse.ui.part.FileEditorInput;
70
import org.eclipse.ui.part.FileEditorInput;
86
import org.eclipse.ui.texteditor.IDocumentProvider;
71
import org.eclipse.ui.texteditor.IDocumentProvider;
Lines 114-132 Link Here
114
	 * <code>null</code> if the array is empty.
99
	 * <code>null</code> if the array is empty.
115
	 */
100
	 */
116
	public static String combineStrings(String[] strings) {
101
	public static String combineStrings(String[] strings) {
117
		if (strings.length == 0)
102
		return AntLaunchingUtil.combineStrings(strings);
118
			return null;
119
120
		if (strings.length == 1)
121
			return strings[0];
122
123
		StringBuffer buf = new StringBuffer();
124
		for (int i = 0; i < strings.length - 1; i++) {
125
			buf.append(strings[i]);
126
			buf.append(ATTRIBUTE_SEPARATOR);
127
		}
128
		buf.append(strings[strings.length - 1]);
129
		return buf.toString();
130
	}
103
	}
131
104
132
	/**
105
	/**
Lines 138-172 Link Here
138
	 * @throws CoreException if unable to access the associated attribute
111
	 * @throws CoreException if unable to access the associated attribute
139
	 */
112
	 */
140
	public static String[] getTargetNames(ILaunchConfiguration configuration) throws CoreException {
113
	public static String[] getTargetNames(ILaunchConfiguration configuration) throws CoreException {
141
        String attribute= null;
114
		return AntLaunchingUtil.getTargetNames(configuration);
142
        if (IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE.equals(configuration.getType().getIdentifier())) {
143
            attribute= getTargetNamesForAntBuilder(configuration);
144
        }
145
        if (attribute == null) {
146
            attribute = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String) null);
147
            if (attribute == null) {
148
                return null;
149
            } 
150
        }
151
		
152
		return AntUtil.parseRunTargets(attribute);
153
	}
115
	}
154
	
155
	private static String getTargetNamesForAntBuilder(ILaunchConfiguration configuration) throws CoreException {
156
        String buildType= ExternalToolBuilder.getBuildType();
157
        String targets= null;
158
        if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(buildType)) {
159
            targets= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS, (String)null);
160
        } else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(buildType)) {
161
            targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS, (String) null);
162
        } else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(buildType)) {
163
            targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, (String) null);
164
        } else if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(buildType)) {
165
            targets = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS, (String) null);
166
        }
167
       
168
        return targets;
169
    }
170
116
171
    /**
117
    /**
172
	 * Returns a map of properties to be defined for the build, or
118
	 * Returns a map of properties to be defined for the build, or
Lines 177-185 Link Here
177
	 * @return map of properties (name --> value), or <code>null</code>
123
	 * @return map of properties (name --> value), or <code>null</code>
178
	 * @throws CoreException if unable to access the associated attribute
124
	 * @throws CoreException if unable to access the associated attribute
179
	 */
125
	 */
180
	public static Map getProperties(ILaunchConfiguration configuration) throws CoreException {
126
	public static Map getProperties(ILaunchConfiguration configuration) throws CoreException {		
181
		Map map = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, (Map) null);
127
		return AntLaunchingUtil.getProperties(configuration);
182
		return map;
183
	}
128
	}
184
	
129
	
185
	/**
130
	/**
Lines 190-206 Link Here
190
	 * @throws CoreException if unable to access the associated attribute
135
	 * @throws CoreException if unable to access the associated attribute
191
	 */
136
	 */
192
	public static String getAntHome(ILaunchConfiguration configuration) throws CoreException {
137
	public static String getAntHome(ILaunchConfiguration configuration) throws CoreException {
193
		IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(configuration);
138
		return AntLaunchingUtil.getAntHome(configuration);
194
		for (int i = 0; i < entries.length; i++) {
195
			IRuntimeClasspathEntry entry = entries[i];
196
			if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
197
				IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2)entry;
198
				if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) {
199
					return ((AntHomeClasspathEntry)entry2).getAntHome();
200
				}
201
			}
202
		}
203
		return null;
204
	}
139
	}
205
140
206
	/**
141
	/**
Lines 213-219 Link Here
213
	 * @throws CoreException if unable to access the associated attribute
148
	 * @throws CoreException if unable to access the associated attribute
214
	 */
149
	 */
215
	public static String[] getPropertyFiles(ILaunchConfiguration configuration) throws CoreException {
150
	public static String[] getPropertyFiles(ILaunchConfiguration configuration) throws CoreException {
216
		String attribute = configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, (String) null);
151
		String attribute = configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES, (String) null);
217
		if (attribute == null) {
152
		if (attribute == null) {
218
			return null;
153
			return null;
219
		}
154
		}
Lines 412-441 Link Here
412
	 * @throws CoreException if file does not exist, IO problems, or invalid format.
347
	 * @throws CoreException if file does not exist, IO problems, or invalid format.
413
	 */
348
	 */
414
	public static URL[] getCustomClasspath(ILaunchConfiguration config) throws CoreException {
349
	public static URL[] getCustomClasspath(ILaunchConfiguration config) throws CoreException {
415
		boolean useDefault = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
350
		return AntLaunchingUtil.getCustomClasspath(config);
416
		if (useDefault) {
417
			return null;
418
		}
419
		IRuntimeClasspathEntry[] unresolved = JavaRuntime.computeUnresolvedRuntimeClasspath(config);
420
		// don't consider bootpath entries
421
		List userEntries = new ArrayList(unresolved.length);
422
		for (int i = 0; i < unresolved.length; i++) {
423
			IRuntimeClasspathEntry entry = unresolved[i];
424
			if (entry.getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) {
425
				userEntries.add(entry);
426
			}
427
		}
428
		IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspath((IRuntimeClasspathEntry[])userEntries.toArray(new IRuntimeClasspathEntry[userEntries.size()]), config);
429
		URL[] urls = new URL[entries.length];
430
		for (int i = 0; i < entries.length; i++) {
431
			IRuntimeClasspathEntry entry = entries[i];
432
			try {
433
				urls[i] = new URL("file:"+entry.getLocation()); //$NON-NLS-1$
434
			} catch (MalformedURLException e) {
435
				throw new CoreException(new Status(IStatus.ERROR, AntUIPlugin.getUniqueIdentifier(), AntUIPlugin.INTERNAL_ERROR, AntUIModelMessages.AntUtil_7, e));
436
			}
437
		}
438
		return urls;		
439
	}
351
	}
440
352
441
	private static String expandVariableString(String variableString, String invalidMessage) throws CoreException {
353
	private static String expandVariableString(String variableString, String invalidMessage) throws CoreException {
Lines 456-462 Link Here
456
	 * @return a list of target names
368
	 * @return a list of target names
457
	 */
369
	 */
458
	public static String[] parseRunTargets(String extraAttibuteValue) {
370
	public static String[] parseRunTargets(String extraAttibuteValue) {
459
		return parseString(extraAttibuteValue, ATTRIBUTE_SEPARATOR);
371
		return AntLaunchingUtil.parseRunTargets(extraAttibuteValue);
460
	}
372
	}
461
	
373
	
462
	/**
374
	/**
Lines 466-484 Link Here
466
	 * @return a list of Strings
378
	 * @return a list of Strings
467
	 */
379
	 */
468
	public static String[] parseString(String delimString, String delim) {
380
	public static String[] parseString(String delimString, String delim) {
469
		if (delimString == null) {
381
		return AntLaunchingUtil.parseString(delimString, delim);
470
			return new String[0];
471
		}
472
		
473
		// Need to handle case where separator character is
474
		// actually part of the target name!
475
		StringTokenizer tokenizer = new StringTokenizer(delimString, delim);
476
		String[] results = new String[tokenizer.countTokens()];
477
		for (int i = 0; i < results.length; i++) {
478
			results[i] = tokenizer.nextToken();
479
		}
480
		
481
		return results;
482
	}
382
	}
483
	
383
	
484
	/**
384
	/**
Lines 486-493 Link Here
486
	 * The returned IFile may or may not exist.
386
	 * The returned IFile may or may not exist.
487
	 */
387
	 */
488
	public static IFile getFile(String fullPath) {
388
	public static IFile getFile(String fullPath) {
489
		IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
389
		return AntLaunchingUtil.getFile(fullPath);
490
		return root.getFile(new Path(fullPath));
491
	}
390
	}
492
391
493
	public static IHyperlink getLocationLink(String path, File buildFileParent) {
392
	public static IHyperlink getLocationLink(String path, File buildFileParent) {
Lines 540-587 Link Here
540
	 * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath)
439
	 * @see org.eclipse.core.resources.IWorkspaceRoot#findFilesForLocation(IPath)
541
	 */
440
	 */
542
	public static IFile getFileForLocation(String path, File buildFileParent) {
441
	public static IFile getFileForLocation(String path, File buildFileParent) {
543
		if (path == null) {
442
		return AntLaunchingUtil.getFileForLocation(path, buildFileParent);
544
			return null;
545
		}
546
		IPath filePath= new Path(path);
547
		IFile file = null;
548
		IFile[] files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath);
549
		if (files.length > 0) {
550
			file= files[0];
551
		}
552
		if (file == null) {
553
			//relative path
554
			File relativeFile= null;
555
			try {
556
				//this call is ok if buildFileParent is null
557
				relativeFile= FileUtils.getFileUtils().resolveFile(buildFileParent, path);
558
				filePath= new Path(relativeFile.getAbsolutePath());
559
				files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath);
560
				if (files.length > 0) {
561
					file= files[0];
562
				} else {
563
					return null;
564
				}
565
			} catch (BuildException be) {
566
				return null;
567
			}
568
		}
569
		
570
		if (file.exists()) {
571
			return file;
572
		} 
573
		File ioFile= file.getLocation().toFile();
574
		if (ioFile.exists()) {//needs to handle case insensitivity on WINOS
575
			try {
576
				files= ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(ioFile.getCanonicalPath()));
577
				if (files.length > 0) {
578
					return files[0];
579
				}
580
			} catch (IOException e) {
581
			}			
582
		}
583
			
584
		return null;
585
	}
443
	}
586
444
587
	/**
445
	/**
Lines 594-633 Link Here
594
	 * @since 3.0
452
	 * @since 3.0
595
	 */
453
	 */
596
	public static void migrateToNewClasspathFormat(ILaunchConfiguration configuration) throws CoreException {
454
	public static void migrateToNewClasspathFormat(ILaunchConfiguration configuration) throws CoreException {
597
		String oldClasspath = configuration.getAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, (String)null);
455
		AntLaunchingUtil.migrateToNewClasspathFormat(configuration);
598
		String oldAntHome = configuration.getAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String)null);
599
		String provider = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, (String)null);
600
		if (oldClasspath != null || oldAntHome != null || provider == null) {
601
			ILaunchConfigurationWorkingCopy workingCopy = null;
602
			if (configuration.isWorkingCopy()) {
603
				workingCopy = (ILaunchConfigurationWorkingCopy) configuration;
604
			} else {
605
				workingCopy = configuration.getWorkingCopy();
606
			}
607
			workingCopy.setAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_CUSTOM_CLASSPATH, (String)null);
608
			workingCopy.setAttribute(org.eclipse.ant.internal.ui.launchConfigurations.IAntLaunchConfigurationConstants.ATTR_ANT_HOME, (String)null);
609
			workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
610
			workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
611
			if (oldAntHome != null) {
612
				IRuntimeClasspathEntry[] entries = JavaRuntime.computeUnresolvedRuntimeClasspath(workingCopy);
613
				List mementos = new ArrayList(entries.length);
614
				for (int i = 0; i < entries.length; i++) {
615
					IRuntimeClasspathEntry entry = entries[i];
616
					if (entry.getType() == IRuntimeClasspathEntry.OTHER) {
617
						IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry;
618
						if (entry2.getTypeId().equals(AntHomeClasspathEntry.TYPE_ID)) {
619
							AntHomeClasspathEntry homeEntry = new AntHomeClasspathEntry(oldAntHome);
620
							mementos.add(homeEntry.getMemento());
621
							continue;
622
						}
623
					}
624
					mementos.add(entry.getMemento());
625
				}
626
				workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
627
				workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, mementos);
628
			}
629
			workingCopy.doSave();
630
		}
631
	}
456
	}
632
457
633
    private static int getOffset(int line, int column, ITextEditor editor) {
458
    private static int getOffset(int line, int column, ITextEditor editor) {
Lines 749-797 Link Here
749
	}
574
	}
750
    
575
    
751
    public static boolean isSeparateJREAntBuild(ILaunchConfiguration configuration) {
576
    public static boolean isSeparateJREAntBuild(ILaunchConfiguration configuration) {
752
    	boolean separateJRE= true;
577
    	return AntLaunchingUtil.isSeparateJREAntBuild(configuration);
753
		try {
754
			//always null for same JRE
755
			separateJRE = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null) != null;
756
		} catch (CoreException e) {
757
			AntUIPlugin.log(AntUIModelMessages.AntUtil_2, e);
758
		}
759
    	
760
		return separateJRE;
761
    }
762
    
763
    public static void linkBuildFailedMessage(String message, IProcess process) {
764
        String fileName = null;
765
        String lineNumber = ""; //$NON-NLS-1$
766
        int fileStart = 0;
767
        int index = message.indexOf("xml"); //$NON-NLS-1$
768
        if (index > 0) {
769
            int numberStart= index + 4;
770
            int numberEnd= message.indexOf(':', numberStart);
771
            int fileEnd = index + 3;
772
            if (numberStart > 0 && fileEnd > 0) {
773
                fileName = message.substring(fileStart, fileEnd).trim();
774
                if (numberEnd > 0) {
775
                    lineNumber = message.substring(numberStart, numberEnd).trim();
776
                }
777
            }
778
        }
779
        
780
        if (fileName != null) {
781
            int num = -1;
782
            try {
783
                num = Integer.parseInt(lineNumber);
784
            } catch (NumberFormatException e) {
785
            }
786
            IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileName));
787
            IFile file= null;
788
            if (files.length > 0) {
789
                file= files[0];
790
            }
791
            if (file != null && file.exists()) {
792
                FileLink link = new FileLink(file, null, -1, -1, num);
793
                TaskLinkManager.addTaskHyperlink(process, link, new Region(0, message.length()), message);
794
            }
795
        }
796
    }
578
    }
797
}
579
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIConstants.java (-2 / +2 lines)
Lines 105-112 Link Here
105
	/**
105
	/**
106
	 * Size of left-hand column for right-justified task name.
106
	 * Size of left-hand column for right-justified task name.
107
	 * Used for Ant Build logging.
107
	 * Used for Ant Build logging.
108
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger
108
	 * @see org.eclipse.ant.internal.launching.runtime.logger.AntProcessBuildLogger
109
     * @see org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntBuildListener
109
     * @see org.eclipse.ant.internal.launching.launchConfigurations.RemoteAntBuildListener
110
	  */
110
	  */
111
	public static final int LEFT_COLUMN_SIZE = 15;
111
	public static final int LEFT_COLUMN_SIZE = 15;
112
	
112
	
(-)Ant Tools Support/org/eclipse/ant/internal/ui/IAntUIPreferenceConstants.java (-7 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 34-45 Link Here
34
	public static final String CONSOLE_DEBUG_COLOR = "org.eclipse.ant.ui.debugColor"; //$NON-NLS-1$	
34
	public static final String CONSOLE_DEBUG_COLOR = "org.eclipse.ant.ui.debugColor"; //$NON-NLS-1$	
35
	
35
	
36
	public static final String ANT_TOOLS_JAR_WARNING= "toolsJAR"; //$NON-NLS-1$
36
	public static final String ANT_TOOLS_JAR_WARNING= "toolsJAR"; //$NON-NLS-1$
37
    
38
    /**
39
     * int preference identifier constant which specifies the length of time to wait
40
     * to connect with the socket that communicates with the separate JRE to capture the output
41
     */
42
    public static final String ANT_COMMUNICATION_TIMEOUT= "timeout"; //$NON-NLS-1$
43
	
37
	
44
	public static final String ANT_ERROR_DIALOG= "errorDialog"; //$NON-NLS-1$
38
	public static final String ANT_ERROR_DIALOG= "errorDialog"; //$NON-NLS-1$
45
	
39
	
(-)Ant Tools Support/org/eclipse/ant/internal/ui/console/AntConsoleColorProvider.java (-6 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.console;
11
package org.eclipse.ant.internal.ui.console;
12
12
13
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamsProxy;
13
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
15
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
15
import org.eclipse.ant.internal.ui.launchConfigurations.AntProcess;
16
import org.eclipse.ant.internal.ui.launchConfigurations.AntStreamsProxy;
17
import org.eclipse.debug.core.model.IProcess;
16
import org.eclipse.debug.core.model.IProcess;
18
import org.eclipse.debug.ui.IDebugUIConstants;
17
import org.eclipse.debug.ui.IDebugUIConstants;
19
import org.eclipse.debug.ui.console.ConsoleColorProvider;
18
import org.eclipse.debug.ui.console.ConsoleColorProvider;
Lines 58-66 Link Here
58
		//an AntStreamsProxy. The remote Ant builds make use of the
57
		//an AntStreamsProxy. The remote Ant builds make use of the
59
		// org.eclipse.debug.core.processFactories extension point
58
		// org.eclipse.debug.core.processFactories extension point
60
		AntStreamsProxy proxy = (AntStreamsProxy)process.getStreamsProxy();
59
		AntStreamsProxy proxy = (AntStreamsProxy)process.getStreamsProxy();
61
		if (process instanceof AntProcess) {
62
			((AntProcess)process).setConsole(console);
63
		}
64
		if (proxy != null) {
60
		if (proxy != null) {
65
			console.connect(proxy.getDebugStreamMonitor(), AntStreamsProxy.ANT_DEBUG_STREAM);
61
			console.connect(proxy.getDebugStreamMonitor(), AntStreamsProxy.ANT_DEBUG_STREAM);
66
			console.connect(proxy.getWarningStreamMonitor(), AntStreamsProxy.ANT_WARNING_STREAM);
62
			console.connect(proxy.getWarningStreamMonitor(), AntStreamsProxy.ANT_WARNING_STREAM);
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/AntDebugMessages.java (-23 lines)
Removed Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.ant.internal.ui.debug;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class AntDebugMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.AntDebugMessages";//$NON-NLS-1$
16
    
17
	public static String AntSourceContainer_0;
18
19
	static {
20
		// load message values from bundle file
21
		NLS.initializeMessages(BUNDLE_NAME, AntDebugMessages.class);
22
	}
23
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/AntDebugMessages.properties (-12 lines)
Removed Link Here
1
###############################################################################
2
# Copyright (c) 2005 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
AntSourceContainer_0=Ant Source Container
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/AntSourceContainer.java (-73 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.debug;
13
14
import java.io.File;
15
import java.io.IOException;
16
import java.util.ArrayList;
17
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IWorkspaceRoot;
20
import org.eclipse.core.resources.ResourcesPlugin;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
25
import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
26
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
27
28
public class AntSourceContainer extends AbstractSourceContainer {
29
30
	private IWorkspaceRoot fRoot;
31
32
	public AntSourceContainer() {
33
		fRoot = ResourcesPlugin.getWorkspace().getRoot();
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#findSourceElements(java.lang.String)
38
	 */
39
	public Object[] findSourceElements(String path) throws CoreException {
40
		ArrayList sources = new ArrayList();
41
		File osFile = new File(path);
42
		if (osFile.exists()) {
43
			try {
44
				IPath canonicalPath = new Path(osFile.getCanonicalPath());
45
				IFile[] files = fRoot.findFilesForLocation(canonicalPath);
46
				if (files.length > 0) {
47
					for (int i = 0; i < files.length; i++) {
48
						sources.add(files[i]);
49
					}
50
				} else {
51
					sources.add(new LocalFileStorage(osFile));
52
				}
53
			} catch (IOException e) {
54
			}
55
		}
56
		return sources.toArray();
57
	}
58
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
61
	 */
62
	public String getName() {
63
		return AntDebugMessages.AntSourceContainer_0;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
68
     * Not persisted via the launch configuration
69
	 */
70
	public ISourceContainerType getType() {
71
		return null;
72
	}
73
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/AntSourceLookupDirector.java (-36 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
15
import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
16
17
/**
18
 * Ant source lookup director. For Ant source lookup there is one source
19
 * lookup participant. 
20
 */
21
public class AntSourceLookupDirector extends AbstractSourceLookupDirector {
22
	
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
25
	 */
26
	public void initializeParticipants() {
27
		addParticipants(new ISourceLookupParticipant[]{new AntSourceLookupParticipant()});
28
	}
29
30
    /* (non-Javadoc)
31
     * @see org.eclipse.debug.core.model.IPersistableSourceLocator#getMemento()
32
     */
33
    public String getMemento() throws CoreException {
34
        return null;
35
    }
36
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/AntSourceLookupParticipant.java (-36 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug;
12
13
import org.eclipse.ant.internal.ui.debug.model.AntStackFrame;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
16
17
/**
18
 * The Ant source lookup participant knows how to translate a 
19
 * Ant stack frame into a source file name 
20
 */
21
public class AntSourceLookupParticipant extends AbstractSourceLookupParticipant {
22
	
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
25
	 */
26
	public String getSourceName(Object object) throws CoreException {
27
		if (object instanceof AntStackFrame) {
28
			return ((AntStackFrame)object).getFilePath();
29
		}
30
        if (object instanceof String) {
31
            // assume it's a file name
32
            return (String)object;
33
        }
34
		return null;
35
	}
36
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/AntSourcePathComputerDelegate.java (-33 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
17
import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
18
19
/**
20
 * Computes the default source lookup path for an Ant launch configuration.
21
 * The default source lookup is a container that knows how to map the 
22
 * fully qualified file system paths to either the <code>IFile</code> within the workspace or
23
 * a <code>LocalFileStorage</code> for buildfiles not in the workspace.
24
 */
25
public class AntSourcePathComputerDelegate implements ISourcePathComputerDelegate {
26
	
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
29
	 */
30
	public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
31
		return new ISourceContainer[] {new AntSourceContainer()};
32
	}
33
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/IAntDebugConstants.java (-33 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.debug;
13
14
public interface IAntDebugConstants {
15
	
16
	/**
17
	 * Unique identifier for the Ant debug model (value 
18
	 * <code>org.eclipse.ant.ui.debug</code>).
19
	 */
20
	public static final String ID_ANT_DEBUG_MODEL = "org.eclipse.ant.ui.debug"; //$NON-NLS-1$
21
	
22
	/**
23
	 * Unique identifier for the Ant line breakpoint markers 
24
	 * (value <code>org.eclipse.ant.ui.antLineBreakpointMarker</code>).
25
	 */
26
	public static final String ID_ANT_LINE_BREAKPOINT_MARKER= "org.eclipse.ant.ui.antLineBreakpointMarker"; //$NON-NLS-1$
27
    
28
    /**
29
     * Unique identifier for the Ant run to line breakpoints 
30
     * (value <code>org.eclipse.ant.ui.runToLineBreakpoint</code>).
31
     */
32
    public static final String ANT_RUN_TO_LINE= "org.eclipse.ant.ui.runToLineBreakpoint"; //$NON-NLS-1$
33
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/IAntDebugController.java (-66 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug;
12
13
import org.eclipse.debug.core.model.IBreakpoint;
14
15
public interface IAntDebugController {
16
	
17
    /**
18
     * Resume the Ant build
19
     */
20
	public void resume();
21
    
22
    /**
23
     * Suspend the Ant build
24
     */
25
	public void suspend();
26
    
27
     /**
28
     * Step into the current Ant task
29
     */
30
	public void stepInto();
31
    
32
     /**
33
     * Step over the current Ant task
34
     */
35
	public void stepOver();
36
    
37
    /**
38
     * The provided breakpoint has been added or removed depending on the <code>added</code> parameter.
39
     * Updates the controller for this change.
40
     * 
41
     * @param breakpoint the breakpoint that has been added or removed
42
     * @param added whether or not the breakpoint has been added 
43
     */
44
	public void handleBreakpoint(IBreakpoint breakpoint, boolean added);
45
    
46
     /**
47
     * Retrieve the properties of the Ant build.
48
     * May occur asynchronously depending on implementation.
49
     */
50
	public void getProperties();
51
    
52
    /**
53
     * Retrieve the stack frames of the Ant build.
54
     * May occur asynchronously depending on implementation.
55
     */
56
	public void getStackFrames();
57
58
	/**
59
	 * Some strings are escaped when marshalled for socket communication.
60
	 * The Ant debug controller will properly unescape these Strings if required.
61
	 * 
62
	 * @param value The buffer of the string to unescape
63
	 * @return The unescaped string
64
	 */
65
	public StringBuffer unescapeString(StringBuffer value);
66
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntDebugElement.java (-54 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
15
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.debug.core.DebugException;
18
import org.eclipse.debug.core.model.DebugElement;
19
20
/**
21
 * Common function of Ant debug model elements
22
 */
23
public abstract class AntDebugElement extends DebugElement {
24
	
25
	/**
26
	 * Constructs a new debug element contained in the given
27
	 * debug target.
28
	 * 
29
	 * @param target debug target
30
	 */
31
	public AntDebugElement(AntDebugTarget target) {
32
		super(target);
33
	}
34
	
35
	/* (non-Javadoc)
36
	 * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
37
	 */
38
	public String getModelIdentifier() {
39
		return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
40
	}
41
    
42
	/**
43
     * Throws a debug exception with the given message, error code, and underlying
44
     * exception.
45
     */
46
    protected void throwDebugException(String message) throws DebugException {
47
        throw new DebugException(new Status(IStatus.ERROR, AntUIPlugin.getUniqueIdentifier(),
48
            DebugException.TARGET_REQUEST_FAILED, message, null));
49
    }
50
    
51
    protected AntDebugTarget getAntDebugTarget() {
52
        return (AntDebugTarget)super.getDebugTarget();
53
    }
54
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntDebugModelPresentation.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-18 Link Here
13
13
14
import java.io.File;
14
import java.io.File;
15
15
16
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
17
import org.eclipse.ant.internal.launching.debug.model.AntProperties;
18
import org.eclipse.ant.internal.launching.debug.model.AntProperty;
19
import org.eclipse.ant.internal.launching.debug.model.AntStackFrame;
20
import org.eclipse.ant.internal.launching.debug.model.AntThread;
16
import org.eclipse.ant.internal.ui.AntUIImages;
21
import org.eclipse.ant.internal.ui.AntUIImages;
17
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.preferences.AntObjectLabelProvider;
23
import org.eclipse.ant.internal.ui.preferences.AntObjectLabelProvider;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntDebugTarget.java (-463 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
16
17
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
18
import org.eclipse.ant.internal.ui.debug.IAntDebugController;
19
import org.eclipse.core.resources.IMarkerDelta;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.variables.VariablesPlugin;
22
import org.eclipse.debug.core.DebugEvent;
23
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugPlugin;
25
import org.eclipse.debug.core.IBreakpointManager;
26
import org.eclipse.debug.core.IBreakpointManagerListener;
27
import org.eclipse.debug.core.IDebugEventSetListener;
28
import org.eclipse.debug.core.ILaunch;
29
import org.eclipse.debug.core.model.IBreakpoint;
30
import org.eclipse.debug.core.model.IDebugTarget;
31
import org.eclipse.debug.core.model.ILineBreakpoint;
32
import org.eclipse.debug.core.model.IMemoryBlock;
33
import org.eclipse.debug.core.model.IProcess;
34
import org.eclipse.debug.core.model.IThread;
35
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
36
37
/**
38
 * Ant Debug Target
39
 */
40
public class AntDebugTarget extends AntDebugElement implements IDebugTarget, IDebugEventSetListener, IBreakpointManagerListener {
41
	
42
	// associated system process (Ant Build)
43
	private IProcess fProcess;
44
	
45
	// containing launch object
46
	private ILaunch fLaunch;
47
	
48
	// Build file name
49
	private String fName;
50
51
	// suspend state
52
	private boolean fSuspended= false;
53
	
54
	// terminated state
55
	private boolean fTerminated= false;
56
	
57
	// threads
58
	private AntThread fThread;
59
	private IThread[] fThreads;
60
	
61
	private IAntDebugController fController;
62
    
63
    private List fRunToLineBreakpoints;
64
65
	/**
66
	 * Constructs a new debug target in the given launch for the 
67
	 * associated Ant build process.
68
	 * 
69
	 * @param launch containing launch
70
	 * @param process Ant build process
71
	 * @param controller the controller to communicate to the Ant build
72
	 */
73
	public AntDebugTarget(ILaunch launch, IProcess process, IAntDebugController controller) {
74
		super(null);
75
		fLaunch = launch;
76
		fProcess = process;
77
		
78
		fController= controller;
79
		
80
		fThread = new AntThread(this);
81
		fThreads = new IThread[] {fThread};
82
        
83
        DebugPlugin.getDefault().getBreakpointManager().addBreakpointManagerListener(this);
84
		DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
85
        DebugPlugin.getDefault().addDebugEventListener(this);
86
	}
87
	
88
	/* (non-Javadoc)
89
	 * @see org.eclipse.debug.core.model.IDebugTarget#getProcess()
90
	 */
91
	public IProcess getProcess() {
92
		return fProcess;
93
	}
94
	
95
	/* (non-Javadoc)
96
	 * @see org.eclipse.debug.core.model.IDebugTarget#getThreads()
97
	 */
98
	public IThread[] getThreads() {
99
		return fThreads;
100
	}
101
	
102
	/* (non-Javadoc)
103
	 * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
104
	 */
105
	public boolean hasThreads() throws DebugException {
106
		return !fTerminated && fThreads.length > 0;
107
	}
108
	
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.debug.core.model.IDebugTarget#getName()
111
	 */
112
	public String getName() throws DebugException {
113
		if (fName == null) {
114
			try {
115
				fName= getLaunch().getLaunchConfiguration().getAttribute(IExternalToolConstants.ATTR_LOCATION, DebugModelMessages.AntDebugTarget_0);
116
				fName= VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fName);
117
			} catch (CoreException e) {
118
				fName = DebugModelMessages.AntDebugTarget_0;
119
			}
120
		}
121
		return fName;
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.debug.core.model.IDebugTarget#supportsBreakpoint(org.eclipse.debug.core.model.IBreakpoint)
126
	 */
127
	public boolean supportsBreakpoint(IBreakpoint breakpoint) {
128
		if (breakpoint.getModelIdentifier().equals(IAntDebugConstants.ID_ANT_DEBUG_MODEL)) {
129
		    //need to consider all breakpoints as no way to tell which set
130
		    //of buildfiles will be executed (ant task)
131
		    return true;
132
		}
133
		return false;
134
	}
135
	
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.debug.core.model.IDebugElement#getDebugTarget()
138
	 */
139
	public IDebugTarget getDebugTarget() {
140
		return this;
141
	}
142
	
143
	/* (non-Javadoc)
144
	 * @see org.eclipse.debug.core.model.IDebugElement#getLaunch()
145
	 */
146
	public ILaunch getLaunch() {
147
		return fLaunch;
148
	}
149
	
150
	/* (non-Javadoc)
151
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
152
	 */
153
	public boolean canTerminate() {
154
		return !fTerminated;
155
	}
156
	
157
	/* (non-Javadoc)
158
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
159
	 */
160
	public boolean isTerminated() {
161
		return fTerminated;
162
	}
163
	
164
	/* (non-Javadoc)
165
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
166
	 */
167
	public void terminate() throws DebugException {
168
	    terminated();
169
	}
170
	
171
	/* (non-Javadoc)
172
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
173
	 */
174
	public boolean canResume() {
175
		return !isTerminated() && isSuspended();
176
	}
177
	
178
	/* (non-Javadoc)
179
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
180
	 */
181
	public boolean canSuspend() {
182
		return !isTerminated() && !isSuspended();
183
	}
184
	
185
	/* (non-Javadoc)
186
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
187
	 */
188
	public boolean isSuspended() {
189
		return fSuspended;
190
	}
191
	
192
	/* (non-Javadoc)
193
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
194
	 */
195
	public void resume() throws DebugException {
196
	    fSuspended= false;
197
	    fController.resume();
198
	}
199
	
200
	/**
201
	 * Notification the target has suspended for the given reason
202
	 * 
203
	 * @param detail reason for the suspend
204
	 */
205
	public void suspended(int detail) {
206
		fSuspended = true;
207
		fThread.setStepping(false);
208
		fThread.fireSuspendEvent(detail);
209
	}	
210
	
211
	/* (non-Javadoc)
212
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
213
	 */
214
	public void suspend() throws DebugException {
215
		fController.suspend();
216
	}
217
	
218
	/* (non-Javadoc)
219
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint)
220
	 */
221
	public void breakpointAdded(IBreakpoint breakpoint) {
222
		fController.handleBreakpoint(breakpoint, true);
223
        if (breakpoint instanceof AntLineBreakpoint) {
224
            if (((AntLineBreakpoint) breakpoint).isRunToLine()) {
225
                if (fRunToLineBreakpoints == null) {
226
                    fRunToLineBreakpoints= new ArrayList();
227
                }
228
                fRunToLineBreakpoints.add(breakpoint);
229
            }
230
        }
231
	}
232
233
    /* (non-Javadoc)
234
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
235
	 */
236
	public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
237
		fController.handleBreakpoint(breakpoint, false);
238
        if (fRunToLineBreakpoints != null) {
239
            if (fRunToLineBreakpoints.remove(breakpoint) && fRunToLineBreakpoints.isEmpty()) {
240
                fRunToLineBreakpoints= null;
241
            }
242
        }
243
	}
244
	
245
	/* (non-Javadoc)
246
	 * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
247
	 */
248
	public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
249
		if (supportsBreakpoint(breakpoint)) {
250
			try {
251
				if (breakpoint.isEnabled() && DebugPlugin.getDefault().getBreakpointManager().isEnabled()) {
252
					breakpointAdded(breakpoint);
253
				} else {
254
					breakpointRemoved(breakpoint, null);
255
				}
256
			} catch (CoreException e) {
257
			}
258
		}
259
	}
260
	
261
	/* (non-Javadoc)
262
	 * @see org.eclipse.debug.core.model.IDisconnect#canDisconnect()
263
	 */
264
	public boolean canDisconnect() {
265
		return false;
266
	}
267
	
268
	/* (non-Javadoc)
269
	 * @see org.eclipse.debug.core.model.IDisconnect#disconnect()
270
	 */
271
	public void disconnect() throws DebugException {
272
	}
273
	
274
	/* (non-Javadoc)
275
	 * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
276
	 */
277
	public boolean isDisconnected() {
278
		return false;
279
	}
280
	
281
	/* (non-Javadoc)
282
	 * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#supportsStorageRetrieval()
283
	 */
284
	public boolean supportsStorageRetrieval() {
285
		return false;
286
	}
287
	
288
	/* (non-Javadoc)
289
	 * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
290
	 */
291
	public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException {
292
		return null;
293
	}
294
295
	/**
296
	 * Notification we have connected to the Ant build logger and it has started.
297
	 * Resume the build.
298
	 */
299
	public void buildStarted() {
300
		fireCreationEvent();
301
		installDeferredBreakpoints();
302
		try {
303
			resume();
304
		} catch (DebugException e) {
305
		}
306
	}
307
	
308
	/**
309
	 * Install breakpoints that are already registered with the breakpoint
310
	 * manager if the breakpoint manager is enabled and the breakpoint is enabled.
311
	 */
312
	private void installDeferredBreakpoints() {
313
		IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager();
314
		if (!manager.isEnabled()) {
315
			return;
316
		}
317
		IBreakpoint[] breakpoints = manager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
318
		for (int i = 0; i < breakpoints.length; i++) {
319
            IBreakpoint breakpoint= breakpoints[i];
320
            try {
321
                if (breakpoint.isEnabled()) {
322
                    breakpointAdded(breakpoints[i]);
323
                }
324
            } catch (CoreException e) {
325
            }
326
		}
327
	}
328
	
329
	/**
330
	 * Called when this debug target terminates.
331
	 */
332
	protected void terminated() {
333
		fThreads= new IThread[0];
334
		fTerminated = true;
335
		fSuspended = false;
336
		if (DebugPlugin.getDefault() != null) {
337
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
338
			DebugPlugin.getDefault().removeDebugEventListener(this);
339
			DebugPlugin.getDefault().getBreakpointManager().removeBreakpointManagerListener(this);
340
		}
341
		if (!getProcess().isTerminated()) {
342
		    try {
343
                fProcess.terminate();
344
                resume();
345
		    } catch (DebugException e) {       
346
		    }
347
		}
348
		if (DebugPlugin.getDefault() != null) {
349
			fireTerminateEvent();
350
		}
351
	}
352
	
353
	/**
354
	 * Single step the Ant build.
355
	 * 
356
	 * @throws DebugException if the request fails
357
	 */
358
	protected void stepOver() {
359
	    fSuspended= false;
360
		fController.stepOver();
361
	}
362
	
363
	/**
364
	 * Step-into the Ant build.
365
	 * 
366
	 * @throws DebugException if the request fails
367
	 */
368
	protected void stepInto() {
369
	    fSuspended= false;
370
	    fController.stepInto();
371
	}
372
	
373
	/**
374
	 * Notification a breakpoint was encountered. Determine
375
	 * which breakpoint was hit and fire a suspend event.
376
	 * 
377
	 * @param event debug event
378
	 */
379
	protected void breakpointHit(String event) {
380
		// determine which breakpoint was hit, and set the thread's breakpoint
381
		String[] datum= event.split(DebugMessageIds.MESSAGE_DELIMITER);
382
		String fileName= datum[1];
383
		int lineNumber = Integer.parseInt(datum[2]);
384
		IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
385
        boolean found= false;
386
		for (int i = 0; i < breakpoints.length; i++) {
387
           ILineBreakpoint lineBreakpoint = (ILineBreakpoint)breakpoints[i];
388
           if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) {
389
               found= true;
390
               break;
391
           }
392
		}
393
        if (!found && fRunToLineBreakpoints != null) {
394
            Iterator iter= fRunToLineBreakpoints.iterator();
395
            while (iter.hasNext()) {
396
                ILineBreakpoint lineBreakpoint = (ILineBreakpoint) iter.next();
397
                if (setThreadBreakpoint(lineBreakpoint, lineNumber, fileName)) {
398
                    break;
399
                }
400
            }
401
        }
402
		suspended(DebugEvent.BREAKPOINT);
403
	}	
404
    
405
    private boolean setThreadBreakpoint(ILineBreakpoint lineBreakpoint, int lineNumber, String fileName) {
406
        try {
407
            if (lineBreakpoint.getLineNumber() == lineNumber && 
408
                    fileName.equals(lineBreakpoint.getMarker().getResource().getLocation().toOSString())) {
409
                fThread.setBreakpoints(new IBreakpoint[]{lineBreakpoint});
410
                return true;
411
            }
412
        } catch (CoreException e) {
413
        }
414
        return false;
415
    }
416
	
417
    public void breakpointHit (IBreakpoint breakpoint) {
418
        fThread.setBreakpoints(new IBreakpoint[]{breakpoint});
419
        suspended(DebugEvent.BREAKPOINT);
420
    }
421
    
422
	protected void getStackFrames() {
423
		fController.getStackFrames();
424
	}
425
	
426
	protected void getProperties() {
427
		fController.getProperties();
428
	}
429
430
    /* (non-Javadoc)
431
     * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
432
     */
433
    public void handleDebugEvents(DebugEvent[] events) {
434
        for (int i = 0; i < events.length; i++) {
435
            DebugEvent event = events[i];
436
            if (event.getKind() == DebugEvent.TERMINATE && event.getSource().equals(fProcess)) {
437
                terminated();
438
            }
439
        }
440
    }
441
    
442
    /**
443
     * When the breakpoint manager disables, remove all registered breakpoints
444
     * requests from the VM. When it enables, reinstall them.
445
     *
446
     * @see org.eclipse.debug.core.IBreakpointManagerListener#breakpointManagerEnablementChanged(boolean)
447
     */
448
    public void breakpointManagerEnablementChanged(boolean enabled) {
449
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
450
        for (int i = 0; i < breakpoints.length; i++) {
451
            IBreakpoint breakpoint = breakpoints[i];
452
            if (enabled) {
453
                breakpointAdded(breakpoint);
454
            } else {
455
                breakpointRemoved(breakpoint, null);
456
            }
457
        }
458
    }
459
460
	public IAntDebugController getAntDebugController() {
461
		return fController;
462
	}   
463
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntLineBreakpoint.java (-112 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import com.ibm.icu.text.MessageFormat;
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
18
import org.eclipse.core.resources.IMarker;
19
import org.eclipse.core.resources.IResource;
20
import org.eclipse.core.resources.IWorkspaceRunnable;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugPlugin;
25
import org.eclipse.debug.core.model.IBreakpoint;
26
import org.eclipse.debug.core.model.LineBreakpoint;
27
28
/**
29
 * Ant line breakpoint
30
 */
31
public class AntLineBreakpoint extends LineBreakpoint {
32
	
33
	/**
34
	 * Default constructor is required for the breakpoint manager
35
	 * to re-create persisted breakpoints. After instantiating a breakpoint,
36
	 * the <code>setMarker(...)</code> method is called to restore
37
	 * this breakpoint's attributes.
38
	 */
39
	public AntLineBreakpoint() {
40
	}
41
	
42
	/**
43
	 * Constructs a line breakpoint on the given resource at the given
44
	 * line number. The line number is 1-based (i.e. the first line of a
45
	 * file is line number 1).
46
	 * 
47
	 * @param resource file on which to set the breakpoint
48
	 * @param lineNumber 1-based line number of the breakpoint
49
	 * @throws CoreException if unable to create the breakpoint
50
	 */
51
	public AntLineBreakpoint(IResource resource, int lineNumber) throws CoreException {
52
	    this(resource, lineNumber, new HashMap(), true);
53
	}
54
	
55
	/**
56
	 * Constructs a line breakpoint on the given resource at the given
57
	 * line number. The line number is 1-based (i.e. the first line of a
58
	 * file is line number 1).
59
	 * 
60
	 * @param resource file on which to set the breakpoint
61
	 * @param lineNumber 1-based line number of the breakpoint
62
	 * @param attributes the marker attributes to set
63
	 * @param register whether to add this breakpoint to the breakpoint manager
64
	 * @throws CoreException if unable to create the breakpoint
65
	 */
66
	public AntLineBreakpoint(final IResource resource, final int lineNumber, final Map attributes, final boolean register) throws CoreException {
67
	    IWorkspaceRunnable wr= new IWorkspaceRunnable() {
68
			public void run(IProgressMonitor monitor) throws CoreException {
69
			    IMarker marker = resource.createMarker(IAntDebugConstants.ID_ANT_LINE_BREAKPOINT_MARKER);
70
			    setMarker(marker);
71
			    attributes.put(IBreakpoint.ENABLED, Boolean.TRUE);
72
			    attributes.put(IMarker.LINE_NUMBER, new Integer(lineNumber));
73
			    attributes.put(IBreakpoint.ID, IAntDebugConstants.ID_ANT_DEBUG_MODEL);
74
                attributes.put(IMarker.MESSAGE, MessageFormat.format(DebugModelMessages.AntLineBreakpoint_0, new String[] {Integer.toString(lineNumber)}));
75
			    ensureMarker().setAttributes(attributes);
76
                
77
                register(register);
78
			}
79
	    };
80
	    run(getMarkerRule(resource), wr);
81
	}
82
	
83
	/* (non-Javadoc)
84
	 * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
85
	 */
86
	public String getModelIdentifier() {
87
		return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
88
	}
89
90
    /**
91
     * @return whether this breakpoint is a run to line breakpoint
92
     */
93
    public boolean isRunToLine() {
94
        try {
95
            return ensureMarker().getAttribute(IAntDebugConstants.ANT_RUN_TO_LINE, false);
96
        } catch (DebugException e) {
97
           return false;
98
        }
99
    }
100
    
101
    /**
102
     * Add this breakpoint to the breakpoint manager,
103
     * or sets it as unregistered.
104
     */
105
    private void register(boolean register) throws CoreException {
106
        if (register) {
107
            DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
108
        } else {
109
            setRegistered(false);
110
        }
111
    }
112
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntProperties.java (-109 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import org.eclipse.debug.core.DebugException;
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
public class AntProperties extends AntDebugElement implements IVariable {
18
	
19
	private IValue fValue;
20
	private String fName;
21
    private boolean fValid= true;
22
23
	public AntProperties(AntDebugTarget target, String name) {
24
		super(target);
25
		fName= name;
26
	}
27
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.debug.core.model.IVariable#getValue()
30
	 */
31
	public synchronized IValue getValue() throws DebugException {
32
        int attempts= 0;
33
        while (!fValid && !getDebugTarget().isTerminated()) {
34
            try {
35
                wait(50);
36
            } catch (InterruptedException e) {
37
            }
38
            if (attempts == 20 && !fValid && !getDebugTarget().isTerminated()) {
39
                throwDebugException(DebugModelMessages.AntProperties_1);
40
            }
41
            attempts++;
42
        }
43
 		return fValue;
44
	}
45
    
46
    protected IValue getLastValue() {
47
        return fValue;
48
    }
49
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.debug.core.model.IVariable#getName()
52
	 */
53
	public String getName() {
54
		return fName;
55
	}
56
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
59
	 */
60
	public String getReferenceTypeName() {
61
		return ""; //$NON-NLS-1$
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
66
	 */
67
	public boolean hasValueChanged() {
68
		return false;
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
73
	 */
74
	public void setValue(String expression) {
75
	}
76
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
79
	 */
80
	public void setValue(IValue value) {
81
		fValue= value;
82
	}
83
84
	/* (non-Javadoc)
85
	 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
86
	 */
87
	public boolean supportsValueModification() {
88
		return false;
89
	}
90
91
	/* (non-Javadoc)
92
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
93
	 */
94
	public boolean verifyValue(String expression) {
95
		return false;
96
	}
97
98
	/* (non-Javadoc)
99
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
100
	 */
101
	public boolean verifyValue(IValue value) {
102
		return false;
103
	}
104
105
    protected synchronized void setValid(boolean valid) {
106
        fValid= valid;        
107
        notifyAll();
108
    }
109
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntPropertiesValue.java (-71 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Brock Janiczak (brockj@tpg.com.au) - bug 154907
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.ui.debug.model;
13
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.List;
17
import org.eclipse.debug.core.model.IValue;
18
import org.eclipse.debug.core.model.IVariable;
19
20
public class AntPropertiesValue extends AntDebugElement implements IValue {
21
	
22
	private List fProperties= new ArrayList();
23
	
24
	public AntPropertiesValue(AntDebugTarget target) {
25
		super(target);
26
	}
27
	
28
	/* (non-Javadoc)
29
	 * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
30
	 */
31
	public String getReferenceTypeName() {
32
		return ""; //$NON-NLS-1$
33
	}
34
	
35
	/* (non-Javadoc)
36
	 * @see org.eclipse.debug.core.model.IValue#getValueString()
37
	 */
38
	public String getValueString() {
39
		return ""; //$NON-NLS-1$
40
	}
41
	
42
	/* (non-Javadoc)
43
	 * @see org.eclipse.debug.core.model.IValue#isAllocated()
44
	 */
45
	public boolean isAllocated() {
46
		return true;
47
	}
48
	
49
	/* (non-Javadoc)
50
	 * @see org.eclipse.debug.core.model.IValue#getVariables()
51
	 */
52
	public IVariable[] getVariables() {
53
		Collections.sort(fProperties);
54
		return (IVariable[])fProperties.toArray(new IVariable[fProperties.size()]);
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.model.IValue#hasVariables()
59
	 */
60
	public boolean hasVariables() {
61
		return true;
62
	}
63
	
64
	protected void addProperties(List properties) {
65
		fProperties.addAll(properties);
66
	}
67
68
	protected List getProperties() {
69
		return fProperties;
70
	}
71
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntProperty.java (-121 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Brock Janiczak (brockj@tpg.com.au) - bug 154907
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.ui.debug.model;
13
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
/**
18
 * A property in an Ant build.
19
 */
20
public class AntProperty extends AntDebugElement implements IVariable, Comparable {
21
22
	private String fName;
23
	private AntValue fValue;
24
    private String fLabel;
25
	
26
	/**
27
	 * Constructs a variable associated with the debug target
28
	 * with the given name and value.
29
	 * 
30
	 * @param target the debug target
31
	 * @param name property name
32
	 * @param value property value
33
	 */
34
	public AntProperty(AntDebugTarget target, String name, String value) {
35
		super(target);
36
		fName = name;
37
		fValue= new AntValue(target, value);
38
	}
39
	
40
	/*
41
	 * @see org.eclipse.debug.core.model.IVariable#getValue()
42
	 */
43
	public IValue getValue() {
44
		return fValue;
45
	}
46
	
47
	/*
48
	 * @see org.eclipse.debug.core.model.IVariable#getName()
49
	 */
50
	public String getName() {
51
		return fName;
52
	}
53
	
54
	/*
55
	 * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
56
	 */
57
	public String getReferenceTypeName() {
58
		return ""; //$NON-NLS-1$
59
	}
60
	
61
	/*
62
	 * @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
63
	 */
64
	public boolean hasValueChanged() {
65
		return false;
66
	}
67
	
68
	/*
69
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
70
	 */
71
	public void setValue(String expression) {
72
	}
73
	
74
	/*
75
	 * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
76
	 */
77
	public void setValue(IValue value) {
78
	}
79
	
80
	/*
81
	 * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
82
	 */
83
	public boolean supportsValueModification() {
84
		return false;
85
	}
86
	
87
	/*
88
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
89
	 */
90
	public boolean verifyValue(String expression) {
91
		return false;
92
	}
93
	
94
	/*
95
	 * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
96
	 */
97
	public boolean verifyValue(IValue value) {
98
		return false;
99
	}
100
101
    /**
102
     * @return the text used to render this property
103
     */
104
    public String getText() {
105
        if (fLabel == null) {
106
            StringBuffer buffer= new StringBuffer(getName());
107
            buffer.append("= "); //$NON-NLS-1$
108
            buffer.append(fValue.getValueString());          
109
            fLabel=  buffer.toString();
110
        } 
111
        return fLabel;
112
    }
113
    
114
    /*
115
     * @see java.lang.Comparable#compareTo(java.lang.Object)
116
     */
117
    public int compareTo(Object other) {
118
    	AntProperty otherProperty = (AntProperty) other;
119
    	return fName.compareToIgnoreCase(otherProperty.getName());
120
    }
121
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntStackFrame.java (-314 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import org.eclipse.ant.internal.ui.AntUtil;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.debug.core.DebugException;
17
import org.eclipse.debug.core.model.IRegisterGroup;
18
import org.eclipse.debug.core.model.IStackFrame;
19
import org.eclipse.debug.core.model.IThread;
20
import org.eclipse.debug.core.model.IVariable;
21
22
/**
23
 * Ant stack frame.
24
 */
25
public class AntStackFrame extends AntDebugElement implements IStackFrame {
26
	
27
	private AntThread fThread;
28
	private String fName;
29
	private int fLineNumber;
30
	private String fFilePath;
31
	private int fId;
32
    private String fFullPath;
33
	
34
	/**
35
	 * Constructs a stack frame in the given thread with the given id.
36
	 * 
37
	 * @param thread
38
	 * @param id stack frame id (0 is the top of the stack)
39
	 */
40
	public AntStackFrame(AntThread thread, int id, String name, String fullPath, int lineNumber) {
41
		super((AntDebugTarget) thread.getDebugTarget());
42
		fId = id;
43
		fThread = thread;
44
		fLineNumber= lineNumber;
45
		fName= name;
46
		setFilePath(fullPath);
47
	}
48
	
49
	protected void setId(int id) {
50
		fId= id;
51
	}
52
	
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.debug.core.model.IStackFrame#getThread()
55
	 */
56
	public IThread getThread() {
57
		return fThread;
58
	}
59
	
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
62
	 */
63
	public IVariable[] getVariables() throws DebugException {
64
	   return fThread.getVariables();
65
	}
66
67
    /* (non-Javadoc)
68
	 * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
69
	 */
70
	public boolean hasVariables() {
71
		return isSuspended();
72
	}
73
	
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.debug.core.model.IStackFrame#getLineNumber()
76
	 */
77
	public int getLineNumber() {
78
		return fLineNumber;
79
	}
80
	
81
	protected void setLineNumber(int lineNumber) {
82
		fLineNumber= lineNumber;
83
	}
84
	
85
	protected void setFilePath(String fullPath) {
86
        fFullPath= fullPath;
87
        IFile file= AntUtil.getFileForLocation(fullPath, null);
88
        if (file != null) {
89
            fFilePath= file.getProjectRelativePath().toString();
90
        } else {
91
            fFilePath= new Path(fullPath).lastSegment();
92
        }
93
	}
94
	
95
	public String getFilePath() {
96
		return fFullPath;
97
	}
98
	
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.debug.core.model.IStackFrame#getCharStart()
101
	 */
102
	public int getCharStart() {
103
		return -1;
104
	}
105
	
106
	/* (non-Javadoc)
107
	 * @see org.eclipse.debug.core.model.IStackFrame#getCharEnd()
108
	 */
109
	public int getCharEnd() {
110
		return -1;
111
	}
112
	
113
	/* (non-Javadoc)
114
	 * @see org.eclipse.debug.core.model.IStackFrame#getName()
115
	 */
116
	public String getName() {
117
		return fName;
118
	}
119
	
120
	protected void setName(String name) {
121
		fName= name;
122
	}
123
	
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.debug.core.model.IStackFrame#getRegisterGroups()
126
	 */
127
	public IRegisterGroup[] getRegisterGroups() {
128
		return null;
129
	}
130
	
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.debug.core.model.IStackFrame#hasRegisterGroups()
133
	 */
134
	public boolean hasRegisterGroups() {
135
		return false;
136
	}
137
	
138
	/* (non-Javadoc)
139
	 * @see org.eclipse.debug.core.model.IStep#canStepInto()
140
	 */
141
	public boolean canStepInto() {
142
		return getThread().canStepInto();
143
	}
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.debug.core.model.IStep#canStepOver()
147
	 */
148
	public boolean canStepOver() {
149
		return getThread().canStepOver();
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
154
	 */
155
	public boolean canStepReturn() {
156
		return getThread().canStepReturn();
157
	}
158
	
159
	/* (non-Javadoc)
160
	 * @see org.eclipse.debug.core.model.IStep#isStepping()
161
	 */
162
	public boolean isStepping() {
163
		return getThread().isStepping();
164
	}
165
	
166
	/* (non-Javadoc)
167
	 * @see org.eclipse.debug.core.model.IStep#stepInto()
168
	 */
169
	public void stepInto() throws DebugException {
170
		getThread().stepInto();
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.debug.core.model.IStep#stepOver()
175
	 */
176
	public void stepOver() throws DebugException {
177
		getThread().stepOver();
178
	}
179
	
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.debug.core.model.IStep#stepReturn()
182
	 */
183
	public void stepReturn() throws DebugException {
184
		getThread().stepReturn();
185
	}
186
	
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
189
	 */
190
	public boolean canResume() {
191
		return getThread().canResume();
192
	}
193
	
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
196
	 */
197
	public boolean canSuspend() {
198
		return getThread().canSuspend();
199
	}
200
	
201
	/* (non-Javadoc)
202
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
203
	 */
204
	public boolean isSuspended() {
205
		return getThread().isSuspended();
206
	}
207
	
208
	/* (non-Javadoc)
209
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
210
	 */
211
	public void resume() throws DebugException {
212
		getThread().resume();
213
	}
214
	
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
217
	 */
218
	public void suspend() throws DebugException {
219
		getThread().suspend();
220
	}
221
	
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
224
	 */
225
	public boolean canTerminate() {
226
		return getThread().canTerminate();
227
	}
228
	
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
231
	 */
232
	public boolean isTerminated() {
233
		return getThread().isTerminated();
234
	}
235
	
236
	/* (non-Javadoc)
237
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
238
	 */
239
	public void terminate() throws DebugException {
240
		getThread().terminate();
241
	}
242
	
243
	/**
244
	 * Returns the name of the buildfile this stack frame is associated
245
	 * with.
246
	 * 
247
	 * @return the name of the buildfile this stack frame is associated
248
	 * with
249
	 */
250
	public String getSourceName() {
251
		return fFilePath;
252
	}
253
	
254
	/* (non-Javadoc)
255
	 * @see java.lang.Object#equals(java.lang.Object)
256
	 */
257
	public boolean equals(Object obj) {
258
		if (obj instanceof AntStackFrame) {
259
			AntStackFrame sf = (AntStackFrame)obj;
260
			if (getSourceName() != null) {
261
				return getSourceName().equals(sf.getSourceName()) &&
262
					sf.getLineNumber() == getLineNumber() &&
263
					sf.fId == fId;
264
			} 
265
			return sf.fId == fId;
266
		}
267
		return false;
268
	}
269
	
270
	/* (non-Javadoc)
271
	 * @see java.lang.Object#hashCode()
272
	 */
273
	public int hashCode() {
274
	    if (getSourceName() == null) {
275
	        return fId;
276
	    }
277
	    return getSourceName().hashCode() + fId;
278
	}
279
	
280
	/**
281
	 * Returns this stack frame's unique identifier within its thread
282
	 * 
283
	 * @return this stack frame's unique identifier within its thread
284
	 */
285
	protected int getIdentifier() {
286
		return fId;
287
	}
288
    
289
    /**
290
     * Returns the system, user or runtime property
291
     * name, or <code>null</code> if unable to resolve a property with the name.
292
     *
293
     * @param propertyName the name of the variable to search for
294
     * @return a property, or <code>null</code> if none
295
     */
296
    public AntProperty findProperty(String propertyName) {
297
        try {
298
            IVariable[] groups= getVariables();
299
            for (int i = 0; i < groups.length; i++) {
300
                AntProperties propertiesGrouping = (AntProperties) groups[i];
301
                AntPropertiesValue value= (AntPropertiesValue) propertiesGrouping.getValue();
302
                IVariable[] properties= value.getVariables();
303
                for (int j = 0; j < properties.length; j++) {
304
                    AntProperty property = (AntProperty) properties[j];
305
                    if (property.getName().equals(propertyName)) {
306
                        return property;
307
                    }
308
                }
309
            }
310
        } catch (DebugException e) {
311
        }
312
        return null;
313
    } 
314
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntThread.java (-479 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import java.util.ArrayList;
14
import java.util.List;
15
16
import org.eclipse.debug.core.DebugEvent;
17
import org.eclipse.debug.core.DebugException;
18
import org.eclipse.debug.core.model.IBreakpoint;
19
import org.eclipse.debug.core.model.IStackFrame;
20
import org.eclipse.debug.core.model.IThread;
21
import org.eclipse.debug.core.model.IVariable;
22
23
/**
24
 * An Ant build thread.
25
 */
26
public class AntThread extends AntDebugElement implements IThread {
27
	
28
	/**
29
	 * Breakpoints this thread is suspended at or <code>null</code>
30
	 * if none.
31
	 */
32
	private IBreakpoint[] fBreakpoints;
33
	
34
	/**
35
	 * The stackframes associated with this thread
36
	 */
37
	private List fFrames= new ArrayList(1);
38
	
39
	/**
40
	 * The stackframes to be reused on suspension
41
	 */
42
	private List fOldFrames;
43
	
44
	/**
45
	 * Whether this thread is stepping
46
	 */
47
	private boolean fStepping = false;
48
	
49
	private boolean fRefreshProperties= true;
50
	
51
	/**
52
	 * The user properties associated with this thread
53
	 */
54
	private AntProperties fUserProperties;
55
	
56
	/**
57
	 * The system properties associated with this thread
58
	 */
59
	private AntProperties fSystemProperties;
60
	
61
	/**
62
	 * The properties set during the build associated with this thread
63
	 */
64
	private AntProperties fRuntimeProperties;
65
    
66
    private Object fPropertiesLock= new Object();
67
	
68
	/**
69
	 * Constructs a new thread for the given target
70
	 * 
71
	 * @param target the Ant Build
72
	 */
73
	public AntThread(AntDebugTarget target) {
74
		super(target);
75
	}
76
	
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.debug.core.model.IThread#getStackFrames()
79
	 */
80
	public synchronized IStackFrame[] getStackFrames() throws DebugException {
81
		if (isSuspended()) {
82
			if (fFrames.size() == 0) {
83
				getStackFrames0();
84
			}
85
		} 
86
		
87
		return (IStackFrame[]) fFrames.toArray(new IStackFrame[fFrames.size()]);
88
	}
89
	
90
	/**
91
	 * Retrieves the current stack frames in the thread
92
	 * possibly waiting until the frames are populated
93
     * 
94
	 */
95
	private void getStackFrames0() throws DebugException {
96
        synchronized (fFrames) {
97
    		getAntDebugTarget().getStackFrames();
98
            if (fFrames.size() > 0) {
99
                //frames set..no need to wait
100
                return;
101
            }
102
            int attempts= 0;
103
    		try {
104
                while (fFrames.size() == 0 && !isTerminated()) {
105
                    fFrames.wait(50);
106
                    if (attempts == 20 && fFrames.size() == 0 && !isTerminated()) {
107
                        throwDebugException(DebugModelMessages.AntThread_3);
108
                    }
109
                    attempts++;
110
                }
111
    		} catch (InterruptedException e) {
112
    		}
113
        }
114
	}
115
	
116
	/* (non-Javadoc)
117
	 * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
118
	 */
119
	public boolean hasStackFrames() throws DebugException {
120
		return isSuspended();
121
	}
122
	
123
	/* (non-Javadoc)
124
	 * @see org.eclipse.debug.core.model.IThread#getPriority()
125
	 */
126
	public int getPriority() throws DebugException {
127
		return 0;
128
	}
129
	
130
	/* (non-Javadoc)
131
	 * @see org.eclipse.debug.core.model.IThread#getTopStackFrame()
132
	 */
133
	public synchronized IStackFrame getTopStackFrame() throws DebugException {
134
		if (isSuspended()) {
135
			if (fFrames.size() == 0) {
136
				getStackFrames0();
137
			}
138
			if (fFrames.size() > 0) {
139
				return (IStackFrame)fFrames.get(0);
140
			}
141
		} 
142
		return null;
143
	}
144
	
145
	/* (non-Javadoc)
146
	 * @see org.eclipse.debug.core.model.IThread#getName()
147
	 */
148
	public String getName() {
149
		return "Thread [Ant Build]"; //$NON-NLS-1$
150
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see org.eclipse.debug.core.model.IThread#getBreakpoints()
154
	 */
155
	public IBreakpoint[] getBreakpoints() {
156
		if (fBreakpoints == null) {
157
			return new IBreakpoint[0];
158
		}
159
		return fBreakpoints;
160
	}
161
	
162
	/**
163
	 * Sets the breakpoints this thread is suspended at, or <code>null</code>
164
	 * if none.
165
	 * 
166
	 * @param breakpoints the breakpoints this thread is suspended at, or <code>null</code>
167
	 * if none
168
	 */
169
	protected void setBreakpoints(IBreakpoint[] breakpoints) {
170
		fBreakpoints = breakpoints;
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
175
	 */
176
	public boolean canResume() {
177
		return isSuspended();
178
	}
179
	
180
	/* (non-Javadoc)
181
	 * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
182
	 */
183
	public boolean canSuspend() {
184
		return !isSuspended();
185
	}
186
	
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.debug.core.model.ISuspendResume#isSuspended()
189
	 */
190
	public boolean isSuspended() {
191
		return getDebugTarget().isSuspended();
192
	}
193
	
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.debug.core.model.ISuspendResume#resume()
196
	 */
197
	public synchronized void resume() throws DebugException {
198
		aboutToResume(DebugEvent.CLIENT_REQUEST, false);
199
		getDebugTarget().resume();
200
	}
201
	
202
	/* (non-Javadoc)
203
	 * @see org.eclipse.debug.core.model.ISuspendResume#suspend()
204
	 */
205
	public synchronized void suspend() throws DebugException {
206
		getDebugTarget().suspend();
207
	}
208
	
209
	/* (non-Javadoc)
210
	 * @see org.eclipse.debug.core.model.IStep#canStepInto()
211
	 */
212
	public boolean canStepInto() {
213
	    return isSuspended();
214
	}
215
	
216
	/* (non-Javadoc)
217
	 * @see org.eclipse.debug.core.model.IStep#canStepOver()
218
	 */
219
	public boolean canStepOver() {
220
		return isSuspended();
221
	}
222
	
223
	/* (non-Javadoc)
224
	 * @see org.eclipse.debug.core.model.IStep#canStepReturn()
225
	 */
226
	public boolean canStepReturn() {
227
		return false;
228
	}
229
	
230
	/* (non-Javadoc)
231
	 * @see org.eclipse.debug.core.model.IStep#isStepping()
232
	 */
233
	public boolean isStepping() {
234
		return fStepping;
235
	}
236
	
237
	/* (non-Javadoc)
238
	 * @see org.eclipse.debug.core.model.IStep#stepInto()
239
	 */
240
	public synchronized void stepInto() throws DebugException {
241
	    aboutToResume(DebugEvent.STEP_INTO, true);
242
		((AntDebugTarget)getDebugTarget()).stepInto();
243
	}
244
	
245
	private void aboutToResume(int detail, boolean stepping) {
246
	    fRefreshProperties= true;
247
	    fOldFrames= new ArrayList(fFrames);
248
        fFrames.clear();
249
        setPropertiesValid(false);
250
	    setStepping(stepping);
251
	    setBreakpoints(null);
252
		fireResumeEvent(detail);
253
    }
254
255
    private void setPropertiesValid(boolean valid) {
256
        if (fUserProperties != null) {
257
            fUserProperties.setValid(valid);
258
            fSystemProperties.setValid(valid);
259
            fRuntimeProperties.setValid(valid);
260
        }
261
    }
262
263
    /* (non-Javadoc)
264
	 * @see org.eclipse.debug.core.model.IStep#stepOver()
265
	 */
266
	public synchronized void stepOver() throws DebugException {
267
	    aboutToResume(DebugEvent.STEP_OVER, true);
268
		((AntDebugTarget)getDebugTarget()).stepOver();
269
	}
270
	
271
	/* (non-Javadoc)
272
	 * @see org.eclipse.debug.core.model.IStep#stepReturn()
273
	 */
274
	public synchronized void stepReturn() throws DebugException {
275
	}
276
	
277
	/* (non-Javadoc)
278
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
279
	 */
280
	public boolean canTerminate() {
281
		return !isTerminated();
282
	}
283
	
284
	/* (non-Javadoc)
285
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
286
	 */
287
	public boolean isTerminated() {
288
		return getDebugTarget().isTerminated();
289
	}
290
	
291
	/* (non-Javadoc)
292
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
293
	 */
294
	public void terminate() throws DebugException {
295
		fFrames.clear();
296
		getDebugTarget().terminate();
297
	}
298
	
299
	/**
300
	 * Sets whether this thread is stepping
301
	 * 
302
	 * @param stepping whether stepping
303
	 */
304
	protected void setStepping(boolean stepping) {
305
		fStepping = stepping;
306
	}
307
308
    public void buildStack(String data) { 
309
        synchronized (fFrames) {
310
            String[] strings= data.split(DebugMessageIds.MESSAGE_DELIMITER);
311
            //0 STACK message
312
            //1 targetName
313
            //2 taskName
314
            //3 filePath
315
            //4 lineNumber
316
            //5 ...
317
            if (fOldFrames != null && (strings.length - 1)/ 4 != fOldFrames.size()) {
318
                fOldFrames= null; //stack size changed..do not preserve
319
            }
320
            StringBuffer name;
321
            String filePath;
322
            int lineNumber;
323
            int stackFrameId= 0;
324
            String taskName;
325
            for (int i = 1; i < strings.length; i++) {
326
                if (strings[i].length() > 0) {
327
                    name= new StringBuffer(strings[i]);
328
                    taskName= strings[++i];
329
                    if (taskName.length() > 0) {
330
                        name.append(": "); //$NON-NLS-1$
331
                        name.append(taskName);
332
                    }
333
                } else {
334
                    name= new StringBuffer(strings[++i]);
335
                }
336
                filePath= strings[++i];
337
                lineNumber= Integer.parseInt(strings[++i]);
338
                addFrame(stackFrameId++, name.toString(), filePath, lineNumber);
339
            }
340
            //wake up the call from getStackFrames
341
            fFrames.notifyAll();
342
        }
343
    }
344
    
345
    private void addFrame(int stackFrameId, String name, String filePath, int lineNumber) {
346
    	AntStackFrame frame= getOldFrame();
347
    	
348
    	if (frame == null || !frame.getFilePath().equals(filePath)) {
349
    		frame= new AntStackFrame(this, stackFrameId, name, filePath, lineNumber);
350
    	} else {
351
    		frame.setFilePath(filePath);
352
    		frame.setId(stackFrameId);
353
    		frame.setLineNumber(lineNumber);
354
    		frame.setName(name);
355
    	}
356
		fFrames.add(frame);
357
    }
358
    
359
    private AntStackFrame getOldFrame() {
360
    	if (fOldFrames == null) {
361
    		return null;
362
    	}
363
    	AntStackFrame frame= (AntStackFrame) fOldFrames.remove(0);
364
    	if (fOldFrames.isEmpty()) {
365
    		fOldFrames= null;
366
    	}
367
    	return frame;
368
    }
369
    
370
    public void newProperties(String data) {
371
        synchronized (fPropertiesLock) {
372
            try {
373
                String[] datum= data.split(DebugMessageIds.MESSAGE_DELIMITER);
374
                if (fUserProperties == null) {
375
                    initializePropertyGroups();
376
                }
377
378
                List userProperties= ((AntPropertiesValue)fUserProperties.getLastValue()).getProperties();
379
                List systemProperties= ((AntPropertiesValue)fSystemProperties.getLastValue()).getProperties();
380
                List runtimeProperties= ((AntPropertiesValue)fRuntimeProperties.getLastValue()).getProperties();
381
                //0 PROPERTIES message
382
                //1 propertyName length
383
                //2 propertyName
384
                //3 propertyValue length
385
                //3 propertyValue
386
                //4 propertyType
387
                //5 ...
388
                if (datum.length > 1) { //new properties
389
                    StringBuffer propertyName;
390
                    StringBuffer propertyValue;
391
                    int propertyNameLength;
392
                    int propertyValueLength;
393
                    for (int i = 1; i < datum.length; i++) {
394
                        propertyNameLength= Integer.parseInt(datum[i]);
395
                        propertyName= new StringBuffer(datum[++i]);
396
                        while (propertyName.length() != propertyNameLength) {
397
                            propertyName.append(DebugMessageIds.MESSAGE_DELIMITER);
398
                            propertyName.append(datum[++i]);
399
                        }
400
401
                        propertyName= getAntDebugTarget().getAntDebugController().unescapeString(propertyName);
402
403
                        propertyValueLength= Integer.parseInt(datum[++i]);
404
                        if (propertyValueLength == 0 && i + 1 == datum.length) { //bug 81299
405
                            propertyValue= new StringBuffer(""); //$NON-NLS-1$
406
                        } else {
407
                            propertyValue= new StringBuffer(datum[++i]);
408
                        }
409
                        while (propertyValue.length() != propertyValueLength) {
410
                            propertyValue.append(DebugMessageIds.MESSAGE_DELIMITER);
411
                            propertyValue.append(datum[++i]);
412
                        }
413
414
                        propertyValue= getAntDebugTarget().getAntDebugController().unescapeString(propertyValue);
415
416
                        int propertyType= Integer.parseInt(datum[++i]);
417
                        addProperty(userProperties, systemProperties, runtimeProperties, propertyName.toString(), propertyValue.toString(), propertyType);
418
                    }
419
                }
420
            } finally {
421
                fRefreshProperties= false;
422
                setPropertiesValid(true);
423
                //wake up the call from getVariables
424
                fPropertiesLock.notifyAll();
425
            }
426
        }
427
	}
428
429
	private void addProperty(List userProperties, List systemProperties, List runtimeProperties, String propertyName, String propertyValue, int propertyType) {
430
		AntProperty property= new AntProperty((AntDebugTarget) getDebugTarget(), propertyName, propertyValue);
431
		switch (propertyType) {
432
			case DebugMessageIds.PROPERTY_SYSTEM:
433
				systemProperties.add(property);
434
				break;
435
			case DebugMessageIds.PROPERTY_USER:
436
				userProperties.add(property);
437
				break;
438
			case DebugMessageIds.PROPERTY_RUNTIME:
439
				runtimeProperties.add(property);
440
				break;
441
		}
442
	}
443
444
	private void initializePropertyGroups() {
445
        AntDebugTarget target= getAntDebugTarget();
446
		fUserProperties= new AntProperties(target, DebugModelMessages.AntThread_0);
447
		fUserProperties.setValue(new AntPropertiesValue(target));
448
		fSystemProperties= new AntProperties(target, DebugModelMessages.AntThread_1);
449
		fSystemProperties.setValue(new AntPropertiesValue(target));
450
		fRuntimeProperties= new AntProperties(target, DebugModelMessages.AntThread_2);
451
		fRuntimeProperties.setValue(new AntPropertiesValue(target));
452
	}
453
    
454
    protected IVariable[] getVariables() throws DebugException {
455
        synchronized (fPropertiesLock) {
456
            if (fRefreshProperties) {
457
                getAntDebugTarget().getProperties();
458
                if (fRefreshProperties) { 
459
                    //properties have not been set; need to wait
460
                    try {
461
                        int attempts= 0;
462
                        while (fRefreshProperties && !isTerminated()) {
463
                            fPropertiesLock.wait(50);
464
                            if (attempts == 20 && fRefreshProperties && !isTerminated()) {
465
                                throwDebugException(DebugModelMessages.AntThread_4);
466
                            }
467
                            attempts++;
468
                        }
469
                    } catch (InterruptedException ie) {
470
                    }
471
                }
472
            }
473
            if (fSystemProperties == null) {
474
                return new IVariable[0];
475
            }
476
            return new IVariable[]{fSystemProperties, fUserProperties, fRuntimeProperties};
477
        }
478
    }
479
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/AntValue.java (-71 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
14
import org.eclipse.debug.core.model.IValue;
15
import org.eclipse.debug.core.model.IVariable;
16
17
public class AntValue extends AntDebugElement implements IValue  {
18
19
    private String fValueString;
20
    protected static final IVariable[] EMPTY = new IVariable[0];
21
    
22
    /**
23
     * @param target
24
     */
25
    public AntValue(AntDebugTarget target, String value) {
26
        super(target);
27
        fValueString= value;
28
    }
29
30
    /* (non-Javadoc)
31
     * @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
32
     */
33
    public String getReferenceTypeName() {
34
        return ""; //$NON-NLS-1$
35
    }
36
37
    /* (non-Javadoc)
38
     * @see org.eclipse.debug.core.model.IValue#getValueString()
39
     */
40
    public String getValueString() {
41
        return fValueString;
42
    }
43
44
    /* (non-Javadoc)
45
     * @see org.eclipse.debug.core.model.IValue#isAllocated()
46
     */
47
    public boolean isAllocated() {
48
        return true;
49
    }
50
51
    /* (non-Javadoc)
52
     * @see org.eclipse.debug.core.model.IValue#getVariables()
53
     */
54
    public IVariable[] getVariables() {
55
        return EMPTY;
56
    }
57
58
    /* (non-Javadoc)
59
     * @see org.eclipse.debug.core.model.IValue#hasVariables()
60
     */
61
    public boolean hasVariables() {
62
        return false;
63
    }
64
65
    /* (non-Javadoc)
66
     * @see org.eclipse.debug.core.model.IDebugElement#getModelIdentifier()
67
     */
68
    public String getModelIdentifier() {
69
        return IAntDebugConstants.ID_ANT_DEBUG_MODEL;
70
    }
71
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/DebugMessageIds.java (-48 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.debug.model;
12
13
public class DebugMessageIds {
14
	
15
	public final static String MESSAGE_DELIMITER= ","; //$NON-NLS-1$
16
	
17
	public final static String BUILD_STARTED=   "build_started"; //$NON-NLS-1$
18
	public final static String TARGET_STARTED= "target_started"; //$NON-NLS-1$
19
	public final static String TARGET_FINISHED= "target_finished"; //$NON-NLS-1$
20
	public final static String TASK_STARTED= "task_started"; //$NON-NLS-1$
21
	public final static String TASK_FINISHED= "task_finished"; //$NON-NLS-1$
22
	
23
	public final static String STEP= "step"; //$NON-NLS-1$
24
	public final static String STEP_OVER= "step_over"; //$NON-NLS-1$
25
	public final static String STEP_INTO= "step_into"; //$NON-NLS-1$
26
	
27
	public final static String TERMINATE= "terminate"; //$NON-NLS-1$
28
	public final static String TERMINATED= "terminated"; //$NON-NLS-1$
29
	
30
	public final static String SUSPEND= "suspend"; //$NON-NLS-1$
31
	public final static String SUSPENDED= "suspended"; //$NON-NLS-1$
32
	
33
	public final static String RESUME= "resume"; //$NON-NLS-1$
34
	
35
	public final static String STACK= "stack"; //$NON-NLS-1$
36
	
37
	public final static String ADD_BREAKPOINT= "add"; //$NON-NLS-1$
38
	public final static String REMOVE_BREAKPOINT= "remove"; //$NON-NLS-1$
39
	
40
	public final static String CLIENT_REQUEST= "client"; //$NON-NLS-1$
41
	public final static String BREAKPOINT= "breakpoint"; //$NON-NLS-1$
42
	
43
	public final static String PROPERTIES= "prop"; //$NON-NLS-1$
44
	public final static String PROPERTY_VALUE= "value"; //$NON-NLS-1$
45
	public final static int PROPERTY_USER= 0;
46
	public final static int PROPERTY_SYSTEM= 1;
47
	public final static int PROPERTY_RUNTIME= 2;
48
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/DebugModelMessages.java (-10 lines)
Lines 14-21 Link Here
14
public class DebugModelMessages extends NLS {
14
public class DebugModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.model.DebugModelMessages";//$NON-NLS-1$
15
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.debug.model.DebugModelMessages";//$NON-NLS-1$
16
16
17
	public static String AntDebugTarget_0;
18
19
	public static String AntDebugModelPresentation_0;
17
	public static String AntDebugModelPresentation_0;
20
	public static String AntDebugModelPresentation_1;
18
	public static String AntDebugModelPresentation_1;
21
	public static String AntDebugModelPresentation_2;
19
	public static String AntDebugModelPresentation_2;
Lines 23-36 Link Here
23
	public static String AntDebugModelPresentation_4;
21
	public static String AntDebugModelPresentation_4;
24
	public static String AntDebugModelPresentation_5;
22
	public static String AntDebugModelPresentation_5;
25
23
26
	public static String AntLineBreakpoint_0;
27
	public static String AntThread_0;
28
	public static String AntThread_1;
29
	public static String AntThread_2;
30
    public static String AntThread_3;
31
    public static String AntThread_4;
32
    
33
    public static String AntProperties_1;
34
    
24
    
35
	static {
25
	static {
36
		// load message values from bundle file
26
		// load message values from bundle file
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/DebugModelMessages.properties (-11 lines)
Lines 9-28 Link Here
9
#     IBM Corporation - initial API and implementation
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
10
###############################################################################
11
11
12
AntDebugTarget_0=Ant Build
13
14
AntDebugModelPresentation_0=<not available>
12
AntDebugModelPresentation_0=<not available>
15
AntDebugModelPresentation_1=\ line: {0}
13
AntDebugModelPresentation_1=\ line: {0}
16
AntDebugModelPresentation_2=(breakpoint at line {0} in {1})
14
AntDebugModelPresentation_2=(breakpoint at line {0} in {1})
17
AntDebugModelPresentation_3=\ (Suspended {0})
15
AntDebugModelPresentation_3=\ (Suspended {0})
18
AntDebugModelPresentation_4=\ (Suspended)
16
AntDebugModelPresentation_4=\ (Suspended)
19
AntDebugModelPresentation_5=(run to line {0} in {1})
17
AntDebugModelPresentation_5=(run to line {0} in {1})
20
21
AntLineBreakpoint_0=Ant breakpoint [line: {0}]
22
AntThread_0=User Properties
23
AntThread_1=System Properties
24
AntThread_2=Runtime Properties
25
AntThread_3=Request to retrieve Ant stack frames failed
26
AntThread_4=Request to retrieve Ant properties failed
27
28
AntProperties_1=Request to Ant properties value failed
(-)Ant Tools Support/org/eclipse/ant/internal/ui/debug/model/RemoteAntDebugBuildListener.java (-321 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.debug.model;
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.InputStreamReader;
17
import java.io.PrintWriter;
18
import java.net.Socket;
19
import java.net.UnknownHostException;
20
21
import org.eclipse.ant.internal.ui.AntUIPlugin;
22
import org.eclipse.ant.internal.ui.debug.IAntDebugController;
23
import org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntBuildListener;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.DebugEvent;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.model.IBreakpoint;
29
import org.eclipse.debug.core.model.ILineBreakpoint;
30
import org.eclipse.debug.core.model.IProcess;
31
32
public class RemoteAntDebugBuildListener extends RemoteAntBuildListener implements IAntDebugController {
33
	
34
	// sockets to communicate with the remote Ant debug build logger
35
	private Socket fRequestSocket;
36
	private PrintWriter fRequestWriter;
37
	private BufferedReader fResponseReader;
38
	
39
	private int fRequestPort= -1;
40
	private Thread fReaderThread;
41
	
42
	private AntDebugTarget fTarget;
43
	
44
	/**
45
	 * Reader thread that processes request responses from the remote Ant debug build logger
46
	 */
47
	private class ReaderThread extends Thread {
48
		public ReaderThread() {
49
			super("Ant Request Response Reader Thread"); //$NON-NLS-1$
50
			setDaemon(true);
51
		}
52
53
		public void run(){
54
			try { 
55
				String message= null; 
56
				while (fResponseReader != null) { 
57
				    synchronized (RemoteAntDebugBuildListener.this) {
58
				        if (fResponseReader != null && (message= fResponseReader.readLine()) != null) {
59
				            receiveMessage(message);
60
				        }
61
				    }
62
				} 
63
			} catch (IOException ie) { //the other end has shutdown
64
				RemoteAntDebugBuildListener.this.shutDown();
65
			} catch (Exception e) {
66
				AntUIPlugin.log("Internal error processing remote response", e); //$NON-NLS-1$
67
				RemoteAntDebugBuildListener.this.shutDown();
68
			}
69
		}
70
	}	
71
	
72
	public RemoteAntDebugBuildListener(ILaunch launch) {
73
		super(launch);
74
		//fDebug= true;
75
	}
76
	
77
	protected void receiveMessage(String message) {
78
		if (message.startsWith(DebugMessageIds.BUILD_STARTED)) {
79
			buildStarted();
80
		} else if (message.startsWith(DebugMessageIds.SUSPENDED)){
81
			handleSuspendMessage(message);
82
		} else if (message.startsWith(DebugMessageIds.TERMINATED)){
83
			fTarget.terminated();
84
		} else if (message.startsWith(DebugMessageIds.STACK)){
85
			AntThread thread= (AntThread) fTarget.getThreads()[0];
86
			thread.buildStack(message);
87
		} else if (message.startsWith(DebugMessageIds.PROPERTIES)){
88
		    AntThread thread= (AntThread) fTarget.getThreads()[0];
89
		    thread.newProperties(message);
90
		} else {
91
			super.receiveMessage(message);
92
		}
93
	}
94
95
    private void handleSuspendMessage(String message) {
96
        if (message.endsWith(DebugMessageIds.CLIENT_REQUEST)) {
97
        	fTarget.suspended(DebugEvent.CLIENT_REQUEST);
98
        } else if (message.endsWith(DebugMessageIds.STEP)) {
99
        	fTarget.suspended(DebugEvent.STEP_END);
100
        } else if (message.indexOf(DebugMessageIds.BREAKPOINT) >= 0) {
101
        	fTarget.breakpointHit(message);
102
        }
103
    }
104
105
    private void buildStarted() {
106
        IProcess process= getProcess();
107
        while(process == null) {
108
        	try {
109
        		synchronized (this) {
110
        			wait(400);
111
        		}
112
        		process= getProcess();
113
        	} catch (InterruptedException ie) {
114
        	}
115
        }
116
        fTarget= new AntDebugTarget(fLaunch, process, this);
117
        fLaunch.addDebugTarget(fTarget);
118
        
119
        if (!connectRequest()) {
120
			RemoteAntDebugBuildListener.this.shutDown();
121
			return;
122
        }
123
        
124
        fTarget.buildStarted();
125
    }
126
127
    private boolean connectRequest() {
128
    	Exception exception= null;
129
    	for (int i= 1; i < 20; i++) {
130
    		try {
131
    			fRequestSocket = new Socket("localhost", fRequestPort); //$NON-NLS-1$
132
    			fRequestWriter = new PrintWriter(fRequestSocket.getOutputStream(), true);
133
    			fResponseReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
134
    			
135
    			fReaderThread= new ReaderThread();
136
    			fReaderThread.start();
137
    			return true;
138
    		} catch (UnknownHostException e) {
139
    			exception= e;
140
    			break;
141
    		} catch (IOException e) {
142
    			exception= e;
143
    		}
144
    		try {
145
				Thread.sleep(500);
146
			} catch(InterruptedException e) {
147
			}
148
    	}
149
    	AntUIPlugin.log("Internal error attempting to connect to debug target", exception); //$NON-NLS-1$
150
    	return false;
151
	}
152
153
	/**
154
	 * Start listening to an Ant build. Start a server connection that
155
	 * the RemoteAntDebugBuildLogger can connect to.
156
	 * 
157
	 * @param eventPort The port number to create the server connection on
158
     * @param requestPort The port number to use for sending requests to the remote logger
159
	 */
160
	public synchronized void startListening(int eventPort, int requestPort) {
161
		super.startListening(eventPort);
162
		fRequestPort= requestPort;
163
	}
164
	
165
	/**
166
	 * Sends a request to the Ant build
167
	 * 
168
	 * @param request debug command
169
	 */
170
	protected void sendRequest(String request) {
171
		if (fRequestSocket == null) {
172
			return;
173
		}
174
		synchronized (fRequestSocket) {
175
			fRequestWriter.println(request);
176
		}		
177
	}
178
	
179
	protected synchronized void shutDown() {
180
        if (fTarget != null) {
181
            fTarget.terminated();
182
            fTarget= null;
183
        }
184
		fLaunch= null;
185
		if (DebugPlugin.getDefault() != null) {
186
			DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
187
		}
188
		try {
189
			if (fReaderThread != null)   {
190
				// interrupt reader thread so that we don't block on close
191
				// on a lock held by the BufferedReader
192
				// see bug: 38955
193
				fReaderThread.interrupt();
194
			}
195
			if (fResponseReader != null) {
196
				fResponseReader.close();
197
				fResponseReader= null;
198
			}
199
		} catch(IOException e) {
200
		}	
201
		if (fRequestWriter != null) {
202
			fRequestWriter.close();
203
			fRequestWriter= null;
204
		}
205
		try{
206
			if(fRequestSocket != null) {
207
				fRequestSocket.close();
208
				fRequestSocket= null;
209
			}
210
		} catch(IOException e) {
211
		}
212
		super.shutDown();
213
	}
214
215
	/* (non-Javadoc)
216
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#resume()
217
	 */
218
	public void resume() {
219
		sendRequest(DebugMessageIds.RESUME);
220
	}
221
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#suspend()
224
	 */
225
	public void suspend() {
226
		sendRequest(DebugMessageIds.SUSPEND);
227
	}
228
229
	/* (non-Javadoc)
230
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepInto()
231
	 */
232
	public void stepInto() {
233
		sendRequest(DebugMessageIds.STEP_INTO);
234
	}
235
236
	/* (non-Javadoc)
237
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#stepOver()
238
	 */
239
	public void stepOver() {
240
		sendRequest(DebugMessageIds.STEP_OVER);
241
	}
242
243
	/* (non-Javadoc)
244
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#handleBreakpoint(IBreakpoint, boolean)
245
	 */
246
	public void handleBreakpoint(IBreakpoint breakpoint, boolean add) {
247
		if (fTarget == null || !fTarget.supportsBreakpoint(breakpoint)) {
248
			return;
249
		}
250
		StringBuffer message= new StringBuffer();
251
		if (add) {
252
			try {
253
				if (!breakpoint.isEnabled()) {
254
					return;
255
				}
256
			} catch (CoreException e) {
257
				AntUIPlugin.log(e);
258
				return;
259
			}
260
			message.append(DebugMessageIds.ADD_BREAKPOINT);
261
		} else {
262
			message.append(DebugMessageIds.REMOVE_BREAKPOINT);
263
		}
264
		message.append(DebugMessageIds.MESSAGE_DELIMITER);
265
		message.append(breakpoint.getMarker().getResource().getLocation().toOSString());
266
		message.append(DebugMessageIds.MESSAGE_DELIMITER);
267
		try {
268
			message.append(((ILineBreakpoint)breakpoint).getLineNumber());
269
			sendRequest(message.toString());
270
		} catch (CoreException ce) {
271
			AntUIPlugin.log(ce);
272
		}
273
	}
274
275
	/* (non-Javadoc)
276
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getProperties()
277
	 */
278
	public void getProperties() {
279
		sendRequest(DebugMessageIds.PROPERTIES);
280
	}
281
282
	/* (non-Javadoc)
283
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#getStackFrames()
284
	 */
285
	public void getStackFrames() {
286
		sendRequest(DebugMessageIds.STACK);
287
	}
288
289
	/* (non-Javadoc)
290
	 * @see org.eclipse.ant.internal.ui.debug.IAntDebugController#unescapeString(java.lang.StringBuffer)
291
	 */
292
	public StringBuffer unescapeString(StringBuffer property) {
293
		if (property.indexOf("\\r") == -1 && property.indexOf("\\n") == -1) { //$NON-NLS-1$ //$NON-NLS-2$
294
			return property;
295
		}
296
		for (int i= 0; i < property.length(); i++) {
297
			if ('\\' == property.charAt(i)) {
298
				String newString= ""; //$NON-NLS-1$
299
				if ('r' == property.charAt(i + 1)) {
300
					if (i-1 > - 1 && '\\' == property.charAt(i-1)) {
301
						newString= "r"; //$NON-NLS-1$
302
					} else {
303
						newString+= '\r';
304
					}
305
				} else if ('n' == property.charAt(i + 1)) {
306
					if (i-1 > - 1 && '\\' == property.charAt(i-1)) {
307
						newString= "n"; //$NON-NLS-1$
308
					} else {
309
						newString+= '\n';
310
					}
311
					
312
				}
313
				if (newString.length() > 0) {
314
					property.replace(i, i + 2, newString);
315
				}
316
			}
317
		}
318
319
		return property;
320
	}
321
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntBuilderTargetsTab.java (-30 / +30 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 17-22 Link Here
17
import org.eclipse.ant.internal.ui.AntUIPlugin;
17
import org.eclipse.ant.internal.ui.AntUIPlugin;
18
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.ant.internal.ui.AntUtil;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
19
import org.eclipse.ant.internal.ui.IAntUIConstants;
20
import org.eclipse.ant.launching.IAntLaunchConstants;
21
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
22
import org.eclipse.core.externaltools.internal.model.BuilderCoreUtils;
20
import org.eclipse.core.resources.IncrementalProjectBuilder;
23
import org.eclipse.core.resources.IncrementalProjectBuilder;
21
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfiguration;
Lines 36-43 Link Here
36
import org.eclipse.swt.widgets.Label;
39
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.swt.widgets.Text;
40
import org.eclipse.swt.widgets.Text;
38
import org.eclipse.ui.PlatformUI;
41
import org.eclipse.ui.PlatformUI;
39
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
40
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
41
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
42
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
42
43
43
public class AntBuilderTargetsTab extends AbstractLaunchConfigurationTab {
44
public class AntBuilderTargetsTab extends AbstractLaunchConfigurationTab {
Lines 68-83 Link Here
68
			Object source = e.getSource();
69
			Object source = e.getSource();
69
            Text text= null;
70
            Text text= null;
70
			if (source == fAfterCleanTarget) {
71
			if (source == fAfterCleanTarget) {
71
                attribute= org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS;
72
                attribute= IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS;
72
                text= fAfterCleanTargetText;
73
                text= fAfterCleanTargetText;
73
			} else if (source == fManualBuildTarget) {
74
			} else if (source == fManualBuildTarget) {
74
                attribute= org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS;
75
                attribute= IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS;
75
                text= fManualBuildTargetText;
76
                text= fManualBuildTargetText;
76
			} else if (source == fAutoBuildTarget) {
77
			} else if (source == fAutoBuildTarget) {
77
                attribute= org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS;
78
                attribute= IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS;
78
                text= fAutoBuildTargetText;
79
                text= fAutoBuildTargetText;
79
			} else if (source == fDuringCleanTarget) {
80
			} else if (source == fDuringCleanTarget) {
80
                attribute= org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS;
81
                attribute= IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS;
81
                text= fDuringCleanTargetText;
82
                text= fDuringCleanTargetText;
82
			}
83
			}
83
			
84
			
Lines 147-153 Link Here
147
        } catch (CoreException e) {
148
        } catch (CoreException e) {
148
           return;
149
           return;
149
        }
150
        }
150
        copy.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String)fAttributeToTargets.get(attribute));
151
        copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String)fAttributeToTargets.get(attribute));
151
		SetTargetsDialog dialog= new SetTargetsDialog(getShell(), copy);
152
		SetTargetsDialog dialog= new SetTargetsDialog(getShell(), copy);
152
		if (dialog.open() != Window.OK) {
153
		if (dialog.open() != Window.OK) {
153
		    return;
154
		    return;
Lines 211-217 Link Here
211
212
212
    public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
213
    public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
213
        configuration.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
214
        configuration.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
214
		configuration.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_TARGETS_UPDATED, true);
215
		configuration.setAttribute(IAntLaunchConstants.ATTR_TARGETS_UPDATED, true);
215
    }
216
    }
216
217
217
    public void initializeFrom(ILaunchConfiguration configuration) {
218
    public void initializeFrom(ILaunchConfiguration configuration) {
Lines 233-251 Link Here
233
        String afterCleanTargets= null;
234
        String afterCleanTargets= null;
234
        String duringCleanTargets= null;
235
        String duringCleanTargets= null;
235
        try {
236
        try {
236
			if (!configuration.getAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_TARGETS_UPDATED, false)) {
237
			if (!configuration.getAttribute(IAntLaunchConstants.ATTR_TARGETS_UPDATED, false)) {
237
				//not yet migrated to new format
238
				//not yet migrated to new format
238
				configTargets= configuration.getAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String)null);
239
				configTargets= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String)null);
239
			}
240
			}
240
            
241
            
241
            autoTargets= configuration.getAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS, (String)null);
242
            autoTargets= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS, (String)null);
242
            manualTargets= configuration.getAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS, (String)null);
243
            manualTargets= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS, (String)null);
243
            afterCleanTargets= configuration.getAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, (String)null);
244
            afterCleanTargets= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, (String)null);
244
            duringCleanTargets= configuration.getAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS, (String)null);
245
            duringCleanTargets= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS, (String)null);
245
			initializeAttributeToTargets(fAutoBuildTargetText, autoTargets, configTargets, org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS);
246
			initializeAttributeToTargets(fAutoBuildTargetText, autoTargets, configTargets, IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS);
246
			initializeAttributeToTargets(fManualBuildTargetText, manualTargets, configTargets, org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS);
247
			initializeAttributeToTargets(fManualBuildTargetText, manualTargets, configTargets, IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS);
247
			initializeAttributeToTargets(fDuringCleanTargetText, duringCleanTargets, configTargets, org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS);
248
			initializeAttributeToTargets(fDuringCleanTargetText, duringCleanTargets, configTargets, IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS);
248
			initializeAttributeToTargets(fAfterCleanTargetText, afterCleanTargets, configTargets, org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS);
249
			initializeAttributeToTargets(fAfterCleanTargetText, afterCleanTargets, configTargets, IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS);
249
        } catch (CoreException ce) {
250
        } catch (CoreException ce) {
250
            AntUIPlugin.log("Error reading configuration", ce); //$NON-NLS-1$
251
            AntUIPlugin.log("Error reading configuration", ce); //$NON-NLS-1$
251
        }
252
        }
Lines 273-279 Link Here
273
        } catch (CoreException e) {
274
        } catch (CoreException e) {
274
            AntUIPlugin.log("Error reading configuration", e); //$NON-NLS-1$
275
            AntUIPlugin.log("Error reading configuration", e); //$NON-NLS-1$
275
        }
276
        }
276
        int buildTypes[]= BuilderUtils.buildTypesToArray(buildKindString);
277
        int buildTypes[]= BuilderCoreUtils.buildTypesToArray(buildKindString);
277
        for (int i = 0; i < buildTypes.length; i++) {
278
        for (int i = 0; i < buildTypes.length; i++) {
278
            switch (buildTypes[i]) {
279
            switch (buildTypes[i]) {
279
                case IncrementalProjectBuilder.FULL_BUILD:
280
                case IncrementalProjectBuilder.FULL_BUILD:
Lines 308-323 Link Here
308
        }
309
        }
309
        configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
310
        configuration.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buffer.toString());
310
        
311
        
311
        String targets= (String) fAttributeToTargets.get(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS);
312
        String targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS);
312
        configuration.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, targets);
313
        configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS, targets);
313
        targets= (String) fAttributeToTargets.get(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS);
314
        targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS);
314
        configuration.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS, targets);
315
        configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS, targets);
315
        targets= (String) fAttributeToTargets.get(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS);
316
        targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS);
316
        configuration.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS, targets);
317
        configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS, targets);
317
        targets= (String) fAttributeToTargets.get(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS);
318
        targets= (String) fAttributeToTargets.get(IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS);
318
        configuration.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS, targets);
319
        configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS, targets);
319
		
320
		configuration.setAttribute(IAntLaunchConstants.ATTR_TARGETS_UPDATED, true);
320
		configuration.setAttribute(org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_TARGETS_UPDATED, true);
321
    }
321
    }
322
322
323
    /* (non-Javadoc)
323
    /* (non-Javadoc)
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathProvider.java (-50 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
14
import java.util.ArrayList;
15
import java.util.List;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.ILaunchConfiguration;
19
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
20
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
21
import org.eclipse.jdt.launching.JavaRuntime;
22
import org.eclipse.jdt.launching.StandardClasspathProvider;
23
24
public class AntClasspathProvider extends StandardClasspathProvider {
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathProvider#computeUnresolvedClasspath(org.eclipse.debug.core.ILaunchConfiguration)
28
	 */
29
	public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration configuration) throws CoreException {
30
		boolean useDefault = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true);
31
		if (useDefault) {
32
			List rtes = new ArrayList(10);
33
			IRuntimeClasspathEntry jreEntry = null;
34
			try {
35
				jreEntry = JavaRuntime.computeJREEntry(configuration);
36
			} catch (CoreException e) {
37
				// not a java project
38
			}
39
			if (jreEntry == null) {
40
				jreEntry = JavaRuntime.newRuntimeContainerClasspathEntry(
41
						JavaRuntime.newDefaultJREContainerPath(), IRuntimeClasspathEntry.STANDARD_CLASSES);
42
			}
43
			rtes.add(jreEntry);
44
			rtes.add(new AntHomeClasspathEntry());
45
			rtes.add(new ContributedClasspathEntriesEntry());
46
			return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
47
		}
48
		return super.computeUnresolvedClasspath(configuration);
49
	}
50
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntClasspathTab.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import org.eclipse.ant.internal.ui.AntUtil;
13
import org.eclipse.ant.internal.ui.AntUtil;
14
import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.core.ILaunchConfiguration;
16
import org.eclipse.debug.ui.ILaunchConfigurationTab;
17
import org.eclipse.debug.ui.ILaunchConfigurationTab;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntHomeClasspathEntry.java (-209 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
import java.io.File;
14
import com.ibm.icu.text.MessageFormat;
15
import java.util.ArrayList;
16
import java.util.List;
17
18
import org.eclipse.ant.core.AntCorePlugin;
19
import org.eclipse.ant.core.AntCorePreferences;
20
import org.eclipse.ant.core.IAntClasspathEntry;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
26
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
27
import org.eclipse.jdt.launching.JavaRuntime;
28
import org.w3c.dom.Document;
29
import org.w3c.dom.Element;
30
31
/**
32
 * A classpath entry that contains a set of archives for a particular
33
 * ANT_HOME.
34
 * 
35
 * @since 3.0 
36
 */
37
public class AntHomeClasspathEntry extends AbstractRuntimeClasspathEntry {
38
	
39
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.antHome"; //$NON-NLS-1$
40
	
41
	/**
42
	 * Local path on disk where Ant Home is located or <code>null</code>
43
	 * to indicate the use of the default Ant Home.
44
	 */
45
	private String antHomeLocation = null;
46
	
47
	/**
48
	 * Creates an AntHome entry for the default AntHome installation.
49
	 */
50
	public AntHomeClasspathEntry() {
51
		antHomeLocation = null;
52
	}
53
	
54
	/**
55
	 * Constructs an AntHome entry for the Ant installed at the specified
56
	 * root directory.
57
	 * 
58
	 * @param antHome path in the local file system to an Ant installation
59
	 */
60
	public AntHomeClasspathEntry(String antHome) {
61
		antHomeLocation = antHome;
62
	}
63
		
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
66
	 */
67
	protected void buildMemento(Document document, Element memento) throws CoreException {
68
		if (antHomeLocation == null) {
69
			memento.setAttribute("default", "true");  //$NON-NLS-1$//$NON-NLS-2$
70
		} else {
71
			memento.setAttribute("antHome", new Path(antHomeLocation).toString()); //$NON-NLS-1$
72
		}
73
	}
74
	/* (non-Javadoc)
75
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
76
	 */
77
	public void initializeFrom(Element memento) throws CoreException {
78
		String antHome = memento.getAttribute("antHome"); //$NON-NLS-1$
79
		if (antHome != null && (antHome.length() > 0)) {
80
			IPath path = new Path(antHome);
81
			antHomeLocation = path.toOSString();
82
		} else {
83
			antHomeLocation = null;
84
		}
85
	}
86
	/* (non-Javadoc)
87
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
88
	 */
89
	public String getTypeId() {
90
		return TYPE_ID;
91
	}
92
	/* (non-Javadoc)
93
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
94
	 */
95
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
96
		List libs = new ArrayList(40);
97
		AntCorePreferences preferences = AntCorePlugin.getPlugin().getPreferences();
98
		if (antHomeLocation == null) {
99
			IAntClasspathEntry[] entries = preferences.getAntHomeClasspathEntries();
100
			for (int i = 0; i < entries.length; i++) {
101
				IAntClasspathEntry entry = entries[i];
102
				libs.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
103
			}
104
		} else {
105
			File lib= resolveAntHome();
106
			IPath libDir = new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
107
			String[] fileNames = lib.list();
108
			for (int i = 0; i < fileNames.length; i++) {
109
				String name = fileNames[i];
110
				IPath path = new Path(name);
111
				String fileExtension = path.getFileExtension();
112
				if ("jar".equalsIgnoreCase(fileExtension)) { //$NON-NLS-1$
113
					libs.add(JavaRuntime.newArchiveRuntimeClasspathEntry(libDir.append(path)));
114
				}
115
			}
116
		}
117
		return (IRuntimeClasspathEntry[]) libs.toArray(new IRuntimeClasspathEntry[libs.size()]);
118
	}
119
	
120
	public File resolveAntHome() throws CoreException {
121
		if (antHomeLocation == null) { //using the default ant home
122
			return null;
123
		}
124
		IPath libDir= new Path(antHomeLocation).append("lib"); //$NON-NLS-1$
125
		File lib= libDir.toFile();
126
		File parentDir= lib.getParentFile();
127
		if (parentDir == null || !parentDir.exists()) {
128
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_10, new String[] {antHomeLocation}), null);
129
		}
130
		if (!lib.exists() || !lib.isDirectory()) {
131
			abort(MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_11, new String[] {antHomeLocation}), null);
132
		}
133
		return lib;
134
	}
135
	
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
138
	 */
139
	public String getName() {
140
		if (antHomeLocation == null) {
141
			return AntLaunchConfigurationMessages.AntHomeClasspathEntry_8;
142
		}
143
		return MessageFormat.format(AntLaunchConfigurationMessages.AntHomeClasspathEntry_9, new String[]{antHomeLocation});
144
	}
145
	
146
	/* (non-Javadoc)
147
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
148
	 */
149
	public int getType() {
150
		return IRuntimeClasspathEntry.OTHER;
151
	}
152
	
153
	/* (non-Javadoc)
154
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
155
	 */
156
	public boolean isComposite() {
157
		return true;
158
	}
159
	
160
	/* (non-Javadoc)
161
	 * @see java.lang.Object#equals(java.lang.Object)
162
	 */
163
	public boolean equals(Object obj) {
164
		return obj instanceof AntHomeClasspathEntry &&
165
		  equalsOrNull(antHomeLocation, ((AntHomeClasspathEntry)obj).antHomeLocation);
166
	}
167
	
168
	/**
169
	 * Return whether s1 is equivalent to s2.
170
	 * 
171
	 * @param s1
172
	 * @param s2
173
	 * @return whether s1 is equivalent to s2
174
	 */
175
	private boolean equalsOrNull(String s1, String s2) {
176
		if (s1 == null || s2 == null) {
177
			return s1 == s2;
178
		} 
179
		return s1.equalsIgnoreCase(s2);
180
	}
181
182
	/* (non-Javadoc)
183
	 * @see java.lang.Object#hashCode()
184
	 */
185
	public int hashCode() {
186
		return getClass().hashCode();
187
	}	
188
	
189
	/**
190
	 * Sets the ant home to use.
191
	 * 
192
	 * @param path path to toor of an ant home installation
193
	 */
194
	protected void setAntHome(String path) {
195
		antHomeLocation = path;
196
	}
197
	
198
	/**
199
	 * Returns the ant home location
200
	 * 
201
	 * @return path to root ant installation directory
202
	 */
203
	public String getAntHome() {
204
		if (antHomeLocation == null) {
205
			return AntCorePlugin.getPlugin().getPreferences().getAntHome();
206
		}
207
		return antHomeLocation;
208
	}
209
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntJRETab.java (-8 / +8 lines)
Lines 16-22 Link Here
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
17
import org.eclipse.ant.internal.ui.IAntUIConstants;
17
import org.eclipse.ant.internal.ui.IAntUIConstants;
18
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
18
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
19
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
19
import org.eclipse.ant.launching.IAntLaunchConstants;
20
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.variables.IStringVariableManager;
22
import org.eclipse.core.variables.IStringVariableManager;
22
import org.eclipse.core.variables.VariablesPlugin;
23
import org.eclipse.core.variables.VariablesPlugin;
Lines 35-45 Link Here
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
38
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
38
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
39
39
40
public class AntJRETab extends JavaJRETab {
40
public class AntJRETab extends JavaJRETab {
41
41
42
	private static final String MAIN_TYPE_NAME= "org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"; //$NON-NLS-1$
42
	private static final String MAIN_TYPE_NAME= "org.eclipse.ant.internal.launching.remote.InternalAntRunner"; //$NON-NLS-1$
43
	
43
	
44
	private VMArgumentsBlock fVMArgumentsBlock=  new VMArgumentsBlock();
44
	private VMArgumentsBlock fVMArgumentsBlock=  new VMArgumentsBlock();
45
	private AntWorkingDirectoryBlock fWorkingDirectoryBlock= new AntWorkingDirectoryBlock();
45
	private AntWorkingDirectoryBlock fWorkingDirectoryBlock= new AntWorkingDirectoryBlock();
Lines 102-115 Link Here
102
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null);
102
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null);
103
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null);
103
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String)null);
104
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
104
			configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String)null);
105
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false);
105
			configuration.setAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, false);
106
		} else {
106
		} else {
107
			super.performApply(configuration);
107
			super.performApply(configuration);
108
			
108
			
109
			if (useDefaultSeparateJRE(configuration)) {
109
			if (useDefaultSeparateJRE(configuration)) {
110
				configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, true);
110
				configuration.setAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, true);
111
			} else {
111
			} else {
112
				configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false);
112
				configuration.setAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, false);
113
			}
113
			}
114
			
114
			
115
			applySeparateVMAttributes(configuration);
115
			applySeparateVMAttributes(configuration);
Lines 190-196 Link Here
190
	 */
190
	 */
191
	public void initializeFrom(ILaunchConfiguration configuration) {
191
	public void initializeFrom(ILaunchConfiguration configuration) {
192
		try {
192
		try {
193
			 boolean isDefaultVMInstall= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false);
193
			 boolean isDefaultVMInstall= configuration.getAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, false);
194
			 if (isDefaultVMInstall) {
194
			 if (isDefaultVMInstall) {
195
			 	ILaunchConfigurationWorkingCopy copy = null;
195
			 	ILaunchConfigurationWorkingCopy copy = null;
196
			 	if (configuration instanceof ILaunchConfigurationWorkingCopy) {
196
			 	if (configuration instanceof ILaunchConfigurationWorkingCopy) {
Lines 275-281 Link Here
275
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
275
		config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$
276
		IVMInstall defaultVMInstall= getDefaultVMInstall(config);
276
		IVMInstall defaultVMInstall= getDefaultVMInstall(config);
277
		if (defaultVMInstall != null) {
277
		if (defaultVMInstall != null) {
278
			config.setAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, true);
278
			config.setAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, true);
279
			setDefaultVMInstallAttributes(defaultVMInstall, config);
279
			setDefaultVMInstallAttributes(defaultVMInstall, config);
280
			applySeparateVMAttributes(config);
280
			applySeparateVMAttributes(config);
281
		}
281
		}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.java (-16 / +2 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 20-33 Link Here
20
	public static String AddVariableStringAction_3;
20
	public static String AddVariableStringAction_3;
21
	public static String AddVariableStringAction_4;
21
	public static String AddVariableStringAction_4;
22
22
23
	public static String AntLaunchDelegate_Launching__0__1;
24
	public static String AntLaunchDelegate_Running__0__2;
25
	public static String AntLaunchDelegate_Build_In_Progress;
26
	public static String AntLaunchDelegate_Failure;
27
	public static String AntLaunchDelegate_22;
28
	public static String AntLaunchDelegate_23;
29
	public static String AntLaunchDelegate_28;
30
31
	public static String AntLaunchShortcut_Unable;
23
	public static String AntLaunchShortcut_Unable;
32
	public static String AntLaunchShortcut_2;
24
	public static String AntLaunchShortcut_2;
33
	public static String AntLaunchShortcut_3;
25
	public static String AntLaunchShortcut_3;
Lines 45-53 Link Here
45
37
46
	public static String AntJRETab_2;
38
	public static String AntJRETab_2;
47
	public static String AntJRETab_3;
39
	public static String AntJRETab_3;
48
40
	
49
	public static String AntHomeClasspathEntry_8;
50
	public static String AntHomeClasspathEntry_9;
51
	public static String AntBuilderTargetsTab_0;
41
	public static String AntBuilderTargetsTab_0;
52
	public static String AntBuilderTargetsTab_1;
42
	public static String AntBuilderTargetsTab_1;
53
	public static String AntBuilderTargetsTab_2;
43
	public static String AntBuilderTargetsTab_2;
Lines 58-65 Link Here
58
	public static String AntBuilderTargetsTab_7;
48
	public static String AntBuilderTargetsTab_7;
59
	public static String AntBuilderTargetsTab_8;
49
	public static String AntBuilderTargetsTab_8;
60
	public static String AntBuilderTargetsTab_10;
50
	public static String AntBuilderTargetsTab_10;
61
	public static String AntHomeClasspathEntry_10;
62
	public static String AntHomeClasspathEntry_11;
63
51
64
	public static String AntMainTab__Select_a_build_file__1;
52
	public static String AntMainTab__Select_a_build_file__1;
65
	public static String AntMainTab_3;
53
	public static String AntMainTab_3;
Lines 86-93 Link Here
86
	public static String AntTargetsTab_1;
74
	public static String AntTargetsTab_1;
87
	public static String AntClasspathTab_0;
75
	public static String AntClasspathTab_0;
88
76
89
	public static String ContributedClasspathEntriesEntry_1;
90
91
	public static String EditAntHomeEntryAction_1;
77
	public static String EditAntHomeEntryAction_1;
92
78
93
	public static String TargetOrderDialog_Order_Targets_1;
79
	public static String TargetOrderDialog_Order_Targets_1;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchConfigurationMessages.properties (-14 lines)
Lines 15-28 Link Here
15
AddVariableStringAction_3=&Variables...
15
AddVariableStringAction_3=&Variables...
16
AddVariableStringAction_4=Add Variable Classpath Entry
16
AddVariableStringAction_4=Add Variable Classpath Entry
17
17
18
AntLaunchDelegate_Launching__0__1=Launching {0}
19
AntLaunchDelegate_Running__0__2=Running {0}
20
AntLaunchDelegate_Build_In_Progress=Ant build {0} already in progress. Concurrent Ant builds are possible if you specify to build in a separate JRE.
21
AntLaunchDelegate_Failure=Failure of Background Ant Build
22
AntLaunchDelegate_22=&Do not show error dialog when Ant build fails
23
AntLaunchDelegate_23=Ant Build Failed
24
AntLaunchDelegate_28=Waiting for virtual machine to exit...
25
26
AntLaunchShortcut_Unable=Unable to find an Ant file to run.
18
AntLaunchShortcut_Unable=Unable to find an Ant file to run.
27
AntLaunchShortcut_2=An exception occurred while creating a default Ant launch configuration for {0}
19
AntLaunchShortcut_2=An exception occurred while creating a default Ant launch configuration for {0}
28
AntLaunchShortcut_3=An exception occurred while retrieving Ant launch configurations.
20
AntLaunchShortcut_3=An exception occurred while retrieving Ant launch configurations.
Lines 41-48 Link Here
41
AntJRETab_2=Run in the same &JRE as the workspace
33
AntJRETab_2=Run in the same &JRE as the workspace
42
AntJRETab_3=Se&parate JRE:
34
AntJRETab_3=Se&parate JRE:
43
35
44
AntHomeClasspathEntry_8=Ant Home (Default)
45
AntHomeClasspathEntry_9=Ant Home ({0})
46
AntBuilderTargetsTab_0=<Builder is not set to run for this build kind>
36
AntBuilderTargetsTab_0=<Builder is not set to run for this build kind>
47
AntBuilderTargetsTab_1=After a "Clean":
37
AntBuilderTargetsTab_1=After a "Clean":
48
AntBuilderTargetsTab_2=&Set Targets...
38
AntBuilderTargetsTab_2=&Set Targets...
Lines 53-60 Link Here
53
AntBuilderTargetsTab_7=During a "Clean":
43
AntBuilderTargetsTab_7=During a "Clean":
54
AntBuilderTargetsTab_8=Set Tar&gets...
44
AntBuilderTargetsTab_8=Set Tar&gets...
55
AntBuilderTargetsTab_10=<default target selected>
45
AntBuilderTargetsTab_10=<default target selected>
56
AntHomeClasspathEntry_10=Ant Home {0} does not exist
57
AntHomeClasspathEntry_11=Ant Home {0} does not contain a "lib" directory
58
46
59
AntMainTab__Select_a_build_file__1=&Select a buildfile:
47
AntMainTab__Select_a_build_file__1=&Select a buildfile:
60
AntMainTab_3=Base Direct&ory:
48
AntMainTab_3=Base Direct&ory:
Lines 81-88 Link Here
81
AntTargetsTab_1=No targets could be determined for the buildfile
69
AntTargetsTab_1=No targets could be determined for the buildfile
82
AntClasspathTab_0=Add F&olders...
70
AntClasspathTab_0=Add F&olders...
83
71
84
ContributedClasspathEntriesEntry_1=Additional Tasks & Support
85
86
EditAntHomeEntryAction_1=Ant &Home...
72
EditAntHomeEntryAction_1=Ant &Home...
87
73
88
TargetOrderDialog_Order_Targets_1=Order Targets
74
TargetOrderDialog_Order_Targets_1=Order Targets
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchDelegate.java (-761 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Juan A. Hernandez - bug 89926
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.ant.internal.ui.launchConfigurations;
14
15
import java.io.File;
16
import java.io.IOException;
17
import java.net.URL;
18
import java.util.HashMap;
19
import java.util.Iterator;
20
import java.util.List;
21
import java.util.Map;
22
23
import org.apache.tools.ant.ProjectHelper;
24
import org.eclipse.ant.core.AntCorePlugin;
25
import org.eclipse.ant.core.AntCorePreferences;
26
import org.eclipse.ant.core.AntRunner;
27
import org.eclipse.ant.core.Property;
28
import org.eclipse.ant.core.Task;
29
import org.eclipse.ant.core.Type;
30
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
31
import org.eclipse.ant.internal.ui.AntUIPlugin;
32
import org.eclipse.ant.internal.ui.AntUtil;
33
import org.eclipse.ant.internal.ui.IAntUIConstants;
34
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
35
import org.eclipse.ant.internal.ui.debug.IAntDebugConstants;
36
import org.eclipse.ant.internal.ui.debug.model.RemoteAntDebugBuildListener;
37
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
38
import org.eclipse.core.resources.IProject;
39
import org.eclipse.core.runtime.CoreException;
40
import org.eclipse.core.runtime.FileLocator;
41
import org.eclipse.core.runtime.IPath;
42
import org.eclipse.core.runtime.IProgressMonitor;
43
import org.eclipse.core.runtime.IStatus;
44
import org.eclipse.core.runtime.Path;
45
import org.eclipse.core.runtime.Platform;
46
import org.eclipse.core.runtime.Status;
47
import org.eclipse.core.runtime.SubProgressMonitor;
48
import org.eclipse.core.variables.VariablesPlugin;
49
import org.eclipse.debug.core.DebugEvent;
50
import org.eclipse.debug.core.DebugPlugin;
51
import org.eclipse.debug.core.IBreakpointManager;
52
import org.eclipse.debug.core.IDebugEventSetListener;
53
import org.eclipse.debug.core.ILaunch;
54
import org.eclipse.debug.core.ILaunchConfiguration;
55
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
56
import org.eclipse.debug.core.ILaunchManager;
57
import org.eclipse.debug.core.model.IBreakpoint;
58
import org.eclipse.debug.core.model.IProcess;
59
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
60
import org.eclipse.debug.ui.CommonTab;
61
import org.eclipse.debug.ui.IDebugUIConstants;
62
import org.eclipse.debug.ui.RefreshTab;
63
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
64
import org.eclipse.jdt.launching.IVMInstall;
65
import org.eclipse.jdt.launching.JavaRuntime;
66
import org.eclipse.jdt.launching.SocketUtil;
67
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
68
import org.eclipse.jface.preference.IPreferenceStore;
69
import org.eclipse.osgi.service.resolver.BundleDescription;
70
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
71
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
72
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
73
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher;
74
import org.osgi.framework.Bundle;
75
76
import com.ibm.icu.text.MessageFormat;
77
78
/**
79
 * Launch delegate for Ant builds
80
 */
81
public class AntLaunchDelegate extends LaunchConfigurationDelegate  {
82
	
83
	private static final String ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessBuildLogger"; //$NON-NLS-1$
84
	private static final String ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.AntProcessDebugBuildLogger"; //$NON-NLS-1$
85
	private static final String NULL_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.NullBuildLogger"; //$NON-NLS-1$
86
	private static final String REMOTE_ANT_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger"; //$NON-NLS-1$
87
	private static final String REMOTE_ANT_DEBUG_LOGGER_CLASS = "org.eclipse.ant.internal.ui.antsupport.logger.debug.RemoteAntDebugBuildLogger"; //$NON-NLS-1$
88
	private static final String BASE_DIR_PREFIX = "-Dbasedir="; //$NON-NLS-1$
89
	private static final String INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.AntInputHandler"; //$NON-NLS-1$
90
	private static final String REMOTE_INPUT_HANDLER_CLASS = "org.eclipse.ant.internal.ui.antsupport.inputhandler.ProxyInputHandler"; //$NON-NLS-1$
91
	
92
	private static final IProject[] NO_PROJECTS = new IProject[0];
93
    
94
	/**
95
	 * String attribute identifying the build scope for a launch configuration.
96
	 * <code>null</code> indicates the default workspace build.
97
	 */
98
	private static final String ATTR_BUILD_SCOPE = AntUIPlugin.getUniqueIdentifier() + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
99
100
	/**
101
	 * Attribute identifier specifying whether referenced projects should be 
102
	 * considered when computing the projects to build. Default value is
103
	 * <code>true</code>.
104
	 */
105
	private static final String ATTR_INCLUDE_REFERENCED_PROJECTS = AntUIPlugin.getUniqueIdentifier() + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
106
107
	
108
    private static String fgSWTLibraryLocation;
109
	
110
	private String fMode;
111
    private boolean fUserSpecifiedLogger= false;
112
    
113
    private String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
114
		String arguments = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, ""); //$NON-NLS-1$
115
		return VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(arguments);
116
	}
117
	
118
	/**
119
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
120
	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
121
	 *      org.eclipse.core.runtime.IProgressMonitor)
122
	 */
123
	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
124
		if (monitor.isCanceled()) {
125
			return;
126
		}
127
		fUserSpecifiedLogger= false;
128
		fMode= mode;
129
		
130
		// migrate the config to the new classpath format if required
131
		AntUtil.migrateToNewClasspathFormat(configuration);
132
		
133
		boolean isSeparateJRE= AntUtil.isSeparateJREAntBuild(configuration);
134
		
135
		if (CommonTab.isLaunchInBackground(configuration)) {
136
			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10);
137
		} else {
138
			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Running__0__2, new String[] {configuration.getName()}), 100);
139
		}
140
		
141
		// resolve location
142
		IPath location = ExternalToolsUtil.getLocation(configuration);
143
		monitor.worked(1);
144
		
145
		if (monitor.isCanceled()) {
146
			return;
147
		}
148
		
149
		if (!isSeparateJRE && AntRunner.isBuildRunning()) {
150
			IStatus status= new Status(IStatus.ERROR, IAntUIConstants.PLUGIN_ID, 1, MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Build_In_Progress, new String[]{location.toOSString()}), null);
151
			throw new CoreException(status);
152
		}		
153
		
154
		// resolve working directory
155
		IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration);
156
		String basedir = null;
157
		if (workingDirectory != null) {
158
			basedir= workingDirectory.toOSString();
159
		}
160
		monitor.worked(1);
161
		
162
		if (monitor.isCanceled()) {
163
			return;
164
		}
165
166
		// link the process to its build logger via a timestamp
167
		long timeStamp = System.currentTimeMillis();
168
		String idStamp = Long.toString(timeStamp);
169
		StringBuffer idProperty = new StringBuffer("-D"); //$NON-NLS-1$
170
		idProperty.append(AbstractEclipseBuildLogger.ANT_PROCESS_ID);
171
		idProperty.append('=');
172
		idProperty.append(idStamp);
173
		
174
		// resolve arguments	
175
		String[] arguments = null;
176
		if (isSeparateJRE) {
177
			arguments = new String[] {getProgramArguments(configuration)};
178
        } else { 
179
			arguments = ExternalToolsUtil.getArguments(configuration);
180
        }
181
		
182
		Map userProperties= AntUtil.getProperties(configuration);
183
		if (userProperties != null) {//create a copy so as to not affect the configuration with transient properties
184
			userProperties= new HashMap(userProperties);
185
		}
186
		String[] propertyFiles= AntUtil.getPropertyFiles(configuration);
187
		String[] targets = AntUtil.getTargetNames(configuration);
188
		URL[] customClasspath= AntUtil.getCustomClasspath(configuration);
189
		String antHome= AntUtil.getAntHome(configuration);
190
		
191
		boolean setInputHandler= true;
192
		try {
193
			//check if set specify inputhandler
194
			setInputHandler = configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
195
		} catch (CoreException ce) {
196
			AntUIPlugin.log(ce);			
197
		}
198
		
199
		AntRunner runner= null;
200
		if (!isSeparateJRE) {
201
			runner = configureAntRunner(configuration, location, basedir, idProperty, arguments, userProperties, propertyFiles, targets, customClasspath, antHome, setInputHandler);
202
		}
203
		 
204
		monitor.worked(1);
205
								
206
		if (monitor.isCanceled()) {
207
			return;
208
		}
209
		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
210
		int port= -1;
211
		int requestPort= -1;
212
		if (isSeparateJRE && captureOutput) {
213
			if (userProperties == null) {
214
				userProperties= new HashMap();
215
			}
216
			port= SocketUtil.findFreePort();
217
			userProperties.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
218
			userProperties.put("eclipse.connect.port", Integer.toString(port)); //$NON-NLS-1$
219
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
220
				requestPort= SocketUtil.findFreePort();
221
				userProperties.put("eclipse.connect.request_port", Integer.toString(requestPort)); //$NON-NLS-1$
222
			}
223
		}
224
		
225
		StringBuffer commandLine= generateCommandLine(location, arguments, userProperties, propertyFiles, targets, antHome, basedir, isSeparateJRE, captureOutput, setInputHandler);
226
		
227
		if (isSeparateJRE) {
228
			monitor.beginTask(MessageFormat.format(AntLaunchConfigurationMessages.AntLaunchDelegate_Launching__0__1, new String[] {configuration.getName()}), 10);
229
			runInSeparateVM(configuration, launch, monitor, idStamp, antHome, port, requestPort, commandLine, captureOutput, setInputHandler);
230
		} else {
231
			runInSameVM(configuration, launch, monitor, location, idStamp, runner, commandLine, captureOutput);
232
		}
233
		
234
		monitor.done();	
235
	}
236
	
237
	private void runInSameVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, IPath location, String idStamp, AntRunner runner, StringBuffer commandLine, boolean captureOutput) throws CoreException {
238
		Map attributes= new HashMap(2);
239
		attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE);
240
		attributes.put(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
241
				
242
		final AntProcess process = new AntProcess(location.toOSString(), launch, attributes);
243
		setProcessAttributes(process, idStamp, commandLine, captureOutput);
244
		boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
245
		if (debug || CommonTab.isLaunchInBackground(configuration)) {
246
			final AntRunner finalRunner= runner;
247
			Runnable r = new Runnable() {
248
				public void run() {
249
					try {
250
						finalRunner.run(process);
251
					} catch (CoreException e) {
252
						handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_Failure);
253
					}
254
					process.terminated();
255
				}
256
			};
257
			Thread background = new Thread(r);
258
            background.setDaemon(true);
259
			background.start();
260
			monitor.worked(1);
261
			//refresh resources after process finishes
262
			if (RefreshTab.getRefreshScope(configuration) != null) {
263
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process);
264
				refresher.startBackgroundRefresh();
265
			}	
266
		} else {
267
			// execute the build 
268
			try {
269
				runner.run(monitor);
270
			} catch (CoreException e) {
271
				process.terminated();
272
				monitor.done();
273
				handleException(e, AntLaunchConfigurationMessages.AntLaunchDelegate_23);
274
				return;
275
			}
276
			process.terminated();
277
			
278
			// refresh resources
279
			RefreshTab.refreshResources(configuration, monitor);
280
		}
281
	}
282
283
	private AntRunner configureAntRunner(ILaunchConfiguration configuration, IPath location, String baseDir, StringBuffer idProperty, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, URL[] customClasspath, String antHome, boolean setInputHandler) throws CoreException {
284
		int argLength = 1; // at least one user property - timestamp
285
		if (arguments != null) {
286
			argLength += arguments.length;
287
		}		
288
		if (baseDir != null && baseDir.length() > 0) {
289
			argLength++;
290
		}
291
		String[] runnerArgs = new String[argLength];
292
		if (arguments != null) {
293
			System.arraycopy(arguments, 0, runnerArgs, 0, arguments.length);
294
		}
295
		if (baseDir != null && baseDir.length() > 0) {
296
			runnerArgs[runnerArgs.length - 2] = BASE_DIR_PREFIX + baseDir;
297
		}
298
		runnerArgs[runnerArgs.length -1] = idProperty.toString();
299
		
300
		AntRunner runner= new AntRunner();
301
		runner.setBuildFileLocation(location.toOSString());
302
		boolean captureOutput= ExternalToolsUtil.getCaptureOutput(configuration);
303
		if (captureOutput) {
304
			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
305
				runner.addBuildLogger(ANT_DEBUG_LOGGER_CLASS);
306
			} else {
307
				runner.addBuildLogger(ANT_LOGGER_CLASS);
308
			}
309
		} else {
310
			runner.addBuildLogger(NULL_LOGGER_CLASS);
311
		}
312
		if (setInputHandler) {
313
			runner.setInputHandler(INPUT_HANDLER_CLASS);
314
		} else {
315
			runner.setInputHandler(""); //$NON-NLS-1$
316
		}
317
		runner.setArguments(runnerArgs);
318
		if (userProperties != null) {
319
			runner.addUserProperties(userProperties);
320
		}
321
322
		if (propertyFiles != null) {
323
			runner.setPropertyFiles(propertyFiles);
324
		}
325
326
		if (targets != null) {
327
			runner.setExecutionTargets(targets);
328
		}
329
330
		if (customClasspath != null) {
331
			runner.setCustomClasspath(customClasspath);
332
		}
333
334
		if (antHome != null) {
335
			runner.setAntHome(antHome);
336
		}
337
		return runner;
338
	}
339
340
	private void handleException(final CoreException e, final String title) {
341
		IPreferenceStore store= AntUIPlugin.getDefault().getPreferenceStore();
342
		if (store.getBoolean(IAntUIPreferenceConstants.ANT_ERROR_DIALOG)) {
343
			AntUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
344
				public void run() {
345
					MessageDialogWithToggle.openError(null, title, e.getMessage(), AntLaunchConfigurationMessages.AntLaunchDelegate_22, false, AntUIPlugin.getDefault().getPreferenceStore(), IAntUIPreferenceConstants.ANT_ERROR_DIALOG);
346
				}
347
			});
348
		}
349
	}
350
351
	private void setProcessAttributes(IProcess process, String idStamp, StringBuffer commandLine, boolean captureOutput) {
352
		// link the process to the Eclipse build logger via a timestamp
353
        if (!fUserSpecifiedLogger) {
354
            process.setAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID, idStamp);
355
        }
356
		
357
		// create "fake" command line for the process
358
		if (commandLine != null) {
359
			process.setAttribute(IProcess.ATTR_CMDLINE, commandLine.toString());
360
		}
361
		if (captureOutput && !fUserSpecifiedLogger) {
362
			TaskLinkManager.registerAntBuild(process);
363
		}
364
	}
365
366
	private StringBuffer generateCommandLine(IPath location, String[] arguments, Map userProperties, String[] propertyFiles, String[] targets, String antHome, String basedir, boolean separateVM, boolean captureOutput, boolean setInputHandler) {
367
		StringBuffer commandLine= new StringBuffer();
368
369
		if (!separateVM) {
370
			commandLine.append("ant"); //$NON-NLS-1$
371
		}
372
		
373
		if (arguments != null) {
374
			for (int i = 0; i < arguments.length; i++) {
375
				commandLine.append(' ');
376
				commandLine.append(arguments[i]);
377
			}
378
		}
379
		
380
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
381
		if (propertyFiles == null) { //global
382
			String[] files= prefs.getCustomPropertyFiles();
383
			for (int i = 0; i < files.length; i++) {
384
				String path = files[i];
385
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
386
				commandLine.append(path);
387
				commandLine.append('\"');
388
			}
389
		} else {//"local" configuration
390
			for (int i = 0; i < propertyFiles.length; i++) {
391
				String path = propertyFiles[i];
392
				commandLine.append(" -propertyfile \""); //$NON-NLS-1$
393
				commandLine.append(path);
394
				commandLine.append('\"');
395
			}
396
		}
397
		//"local" configuration
398
		if (userProperties != null) {
399
			Iterator keys = userProperties.keySet().iterator();
400
			String key;
401
			while (keys.hasNext()) {
402
				key= (String)keys.next();
403
				appendProperty(commandLine, key, (String)userProperties.get(key));
404
			}
405
		}
406
		
407
		//global
408
		List properties= null;
409
		if (!separateVM) {
410
			properties= prefs.getProperties();
411
		} else {
412
			properties= prefs.getRemoteAntProperties();
413
		}
414
		
415
		//if we have user properties this means that the user has chosen to override the global properties
416
		//if in a separate VM and have only two (or three if debug) user properties these are really only Eclipse generated properties
417
		//and the user is still using the global properties
418
		int numberOfEclipseProperties= 2;
419
		if (userProperties != null && userProperties.get("eclipse.connect.request_port") != null){ //$NON-NLS-1$
420
			numberOfEclipseProperties= 3; //debug mode
421
		}
422
		boolean useGlobalProperties = userProperties == null || (separateVM && userProperties.size() == numberOfEclipseProperties);
423
		if (useGlobalProperties) {
424
			for (Iterator iter = properties.iterator(); iter.hasNext();) {
425
				Property property = (Property) iter.next();
426
				String key= property.getName();
427
				String value= property.getValue(false);
428
				if (value != null) {
429
					appendProperty(commandLine, key, value);
430
				}
431
			}
432
		}
433
		
434
		if (basedir != null && basedir.length() > 0) {
435
			appendProperty(commandLine, "basedir", basedir); //$NON-NLS-1$
436
		}
437
		
438
		if (antHome != null) {
439
			commandLine.append(" \"-Dant.home="); //$NON-NLS-1$
440
			commandLine.append(antHome);
441
			commandLine.append('\"');
442
		}
443
		
444
		if (separateVM) { 
445
			if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
446
				if (captureOutput) {
447
				commandLine.append(" -logger "); //$NON-NLS-1$
448
				if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
449
					commandLine.append(REMOTE_ANT_DEBUG_LOGGER_CLASS);
450
					} else {
451
					commandLine.append(REMOTE_ANT_LOGGER_CLASS);
452
				}
453
				}
454
			} else {
455
			    fUserSpecifiedLogger= true;
456
            }
457
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
458
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
459
				commandLine.append(REMOTE_INPUT_HANDLER_CLASS);
460
			}
461
		} else {
462
			if (commandLine.indexOf("-inputhandler") == -1 && setInputHandler) { //$NON-NLS-1$
463
				commandLine.append(" -inputhandler "); //$NON-NLS-1$
464
				commandLine.append(INPUT_HANDLER_CLASS);
465
			}
466
            if (commandLine.indexOf("-logger") == -1) { //$NON-NLS-1$
467
    			commandLine.append(" -logger "); //$NON-NLS-1$
468
    			if (fMode.equals(ILaunchManager.DEBUG_MODE)) {
469
    				commandLine.append(ANT_DEBUG_LOGGER_CLASS);
470
    			} else if (captureOutput) {
471
    				commandLine.append(ANT_LOGGER_CLASS);
472
    			} else {
473
    				commandLine.append(NULL_LOGGER_CLASS);
474
    			}
475
            }
476
		}
477
		
478
		if (separateVM) {
479
			appendTaskAndTypes(prefs, commandLine);
480
		}
481
		commandLine.append(" -buildfile \""); //$NON-NLS-1$
482
		commandLine.append(location.toOSString());
483
		commandLine.append('\"');
484
		
485
		if (targets != null) {
486
			for (int i = 0; i < targets.length; i++) {
487
				commandLine.append(" \""); //$NON-NLS-1$
488
				commandLine.append(targets[i]);
489
				commandLine.append('\"');
490
			}
491
		}
492
		return commandLine;
493
	}
494
	
495
	private void appendTaskAndTypes(AntCorePreferences prefs, StringBuffer commandLine) {
496
		List tasks= prefs.getRemoteTasks();
497
		Iterator itr= tasks.iterator();
498
		while (itr.hasNext()) {
499
			Task task = (Task) itr.next();
500
			commandLine.append(" -eclipseTask "); //$NON-NLS-1$
501
			String name= ProjectHelper.genComponentName(task.getURI(), task.getTaskName());
502
			commandLine.append(name);
503
			commandLine.append(',');
504
			commandLine.append(task.getClassName());
505
		}
506
		
507
		List types= prefs.getRemoteTypes();
508
		itr= types.iterator();
509
		while (itr.hasNext()) {
510
			Type type = (Type) itr.next();
511
			commandLine.append(" -eclipseType "); //$NON-NLS-1$
512
			String name= ProjectHelper.genComponentName(type.getURI(), type.getTypeName());
513
			commandLine.append(name);
514
			commandLine.append(',');
515
			commandLine.append(type.getClassName());
516
		}
517
	}
518
519
	private void appendProperty(StringBuffer commandLine, String name, String value) {
520
		commandLine.append(" \"-D"); //$NON-NLS-1$
521
		commandLine.append(name);
522
		commandLine.append('=');
523
		commandLine.append(value);
524
        if (value.length() > 0 && value.charAt(value.length() - 1) == File.separatorChar) {
525
            commandLine.append(File.separatorChar);
526
        }
527
		commandLine.append("\""); //$NON-NLS-1$
528
	}
529
	
530
	private void runInSeparateVM(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor, String idStamp, String antHome, int port, int requestPort, StringBuffer commandLine, boolean captureOutput, boolean setInputHandler) throws CoreException {
531
        boolean debug= fMode.equals(ILaunchManager.DEBUG_MODE);
532
		if (captureOutput) {
533
			if (debug) {
534
				RemoteAntDebugBuildListener listener= new RemoteAntDebugBuildListener(launch);
535
				if (requestPort != -1) {
536
					listener.startListening(port, requestPort);
537
				}
538
			} else if (!fUserSpecifiedLogger) {
539
				RemoteAntBuildListener client= new RemoteAntBuildListener(launch);
540
				if (port != -1) {
541
					client.startListening(port);
542
				}
543
			}
544
		}
545
		
546
		ILaunchConfigurationWorkingCopy copy= configuration.getWorkingCopy();
547
		setDefaultWorkingDirectory(copy);
548
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, commandLine.toString());
549
		StringBuffer vmArgs= generateVMArguments(copy, setInputHandler, antHome);
550
		copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmArgs.toString());
551
        copy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
552
        if (copy.getAttribute(IAntLaunchConfigurationConstants.ATTR_DEFAULT_VM_INSTALL, false)) {
553
        	setDefaultVM(configuration, copy);
554
        }
555
        if (debug) { //do not allow launch in foreground bug 83254
556
            copy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
557
        }
558
        
559
        //set the ANT_HOME environment variable
560
        if (antHome != null) {
561
            Map vars = copy.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, new HashMap(1));
562
            vars.put("ANT_HOME", antHome); //$NON-NLS-1$
563
            copy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, vars);
564
        }
565
566
		//copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000");
567
		IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 10);
568
		AntJavaLaunchDelegate delegate= new AntJavaLaunchDelegate();
569
		delegate.preLaunchCheck(copy, ILaunchManager.RUN_MODE, subMonitor);
570
		delegate.launch(copy, ILaunchManager.RUN_MODE, launch, subMonitor);
571
		final IProcess[] processes= launch.getProcesses();
572
		for (int i = 0; i < processes.length; i++) {
573
			setProcessAttributes(processes[i], idStamp, null, captureOutput);
574
		}
575
576
		if (CommonTab.isLaunchInBackground(copy)) {
577
			// refresh resources after process finishes
578
			if (RefreshTab.getRefreshScope(configuration) != null) {
579
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, processes[0]);
580
				refresher.startBackgroundRefresh();
581
			}
582
		} else {
583
			final boolean[] terminated= new boolean[1];
584
			terminated[0]= launch.isTerminated();
585
			IDebugEventSetListener listener= new IDebugEventSetListener() {
586
				public void handleDebugEvents(DebugEvent[] events) {
587
					for (int i = 0; i < events.length; i++) {
588
						DebugEvent event = events[i];
589
						for (int j= 0, numProcesses= processes.length; j < numProcesses; j++) {
590
							if (event.getSource() == processes[j] && event.getKind() == DebugEvent.TERMINATE) {
591
								terminated[0]= true;
592
								break;
593
							}
594
						}
595
					}
596
				}
597
			};
598
			DebugPlugin.getDefault().addDebugEventListener(listener);
599
			monitor.subTask(AntLaunchConfigurationMessages.AntLaunchDelegate_28);
600
			while (!monitor.isCanceled() && !terminated[0]) {
601
				try {
602
					Thread.sleep(50);
603
				} catch (InterruptedException e) {
604
				}
605
			}
606
			DebugPlugin.getDefault().removeDebugEventListener(listener);
607
			if (!monitor.isCanceled()) {
608
				// refresh resources
609
				RefreshTab.refreshResources(configuration, monitor);
610
			}
611
		}
612
	}
613
614
	private void setDefaultVM(ILaunchConfiguration configuration, ILaunchConfigurationWorkingCopy copy) {
615
		try {
616
			JavaRuntime.getJavaProject(configuration);
617
			//remove the vm name, install type and jre container path for the Java launching concept of default VM
618
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, (String)null);
619
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, (String)null);
620
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String)null);
621
		} catch (CoreException ce) {
622
			//not in a Java project
623
			IVMInstall defaultVMInstall= JavaRuntime.getDefaultVMInstall();
624
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_NAME, defaultVMInstall.getName());
625
			copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_INSTALL_TYPE, defaultVMInstall.getVMInstallType().getId());
626
		}
627
	}
628
	
629
	private StringBuffer generateVMArguments(ILaunchConfiguration config, boolean setInputHandler, String antHome) {
630
		StringBuffer vmArgs= new StringBuffer();
631
		try {
632
			String configArgs= config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String)null);
633
			if (configArgs != null) {
634
				vmArgs.append(configArgs);
635
				vmArgs.append(' ');
636
			}
637
		} catch (CoreException e) {
638
		}
639
	
640
        if (antHome != null) {
641
            vmArgs.append("-Dant.home=\""); //$NON-NLS-1$
642
            vmArgs.append(antHome);
643
            vmArgs.append("\" "); //$NON-NLS-1$
644
        
645
            File antLibDir= new File(antHome, "lib"); //$NON-NLS-1$
646
            vmArgs.append("-Dant.library.dir=\""); //$NON-NLS-1$
647
            vmArgs.append(antLibDir.getAbsolutePath());
648
            vmArgs.append('\"');
649
        }
650
		if (setInputHandler) {
651
			String swtLocation= getSWTLibraryLocation();
652
			if (swtLocation != null) {
653
				vmArgs.append(" -Djava.library.path=\""); //$NON-NLS-1$
654
				String javaLibPath= System.getProperty("java.library.path"); //$NON-NLS-1$
655
                javaLibPath= stripUnescapedQuotes(javaLibPath);
656
				if (javaLibPath != null) {
657
					vmArgs.append(javaLibPath);
658
					if (vmArgs.charAt(vmArgs.length() - 1) != File.pathSeparatorChar) {
659
						vmArgs.append(File.pathSeparatorChar);
660
					}
661
				}
662
				vmArgs.append(swtLocation);
663
				vmArgs.append('"');
664
			}
665
		}
666
		return vmArgs;
667
    }
668
669
    private String stripUnescapedQuotes(String javaLibPath) {
670
        StringBuffer buf = new StringBuffer(javaLibPath.length());
671
        for (int i = 0; i < javaLibPath.length(); i++) {
672
            char c = javaLibPath.charAt(i);
673
            switch (c) {
674
                case '"':
675
                    if (i != 0 && javaLibPath.charAt(i-1) == '\\') {
676
                        buf.append(c);
677
                    }
678
                    break;
679
                default:
680
                    buf.append(c);
681
                    break;
682
            }
683
        }
684
        return buf.toString();
685
    }
686
687
    /* (non-Javadoc)
688
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
689
	 */
690
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
691
		IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, ATTR_BUILD_SCOPE);
692
		if (projects == null) {
693
			return NO_PROJECTS;
694
		}
695
		boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, ATTR_INCLUDE_REFERENCED_PROJECTS);
696
		if (isRef) {
697
			return computeReferencedBuildOrder(projects);
698
		}
699
		return computeBuildOrder(projects);
700
	}
701
702
	private String getSWTLibraryLocation() {
703
       if (fgSWTLibraryLocation == null) {
704
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
705
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
706
            BundleDescription[] fragments= description.getFragments();
707
            if (fragments == null || fragments.length == 0) {
708
                return null;
709
            }
710
            Bundle fragBundle= Platform.getBundle(fragments[0].getSymbolicName());
711
            try {
712
                URL url= FileLocator.toFileURL(fragBundle.getEntry("/")); //$NON-NLS-1$
713
                IPath path= new Path(url.getPath());
714
                path= path.removeTrailingSeparator();
715
                fgSWTLibraryLocation= path.toOSString();
716
            } catch (IOException e) {
717
            }
718
		}
719
        return fgSWTLibraryLocation;
720
	}
721
    
722
     /* (non-Javadoc)
723
     * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBreakpoints(org.eclipse.debug.core.ILaunchConfiguration)
724
     */
725
    protected IBreakpoint[] getBreakpoints(ILaunchConfiguration configuration) {
726
         IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
727
         if (!breakpointManager.isEnabled()) {
728
             // no need to check breakpoints individually.
729
             return null;
730
         }
731
         return breakpointManager.getBreakpoints(IAntDebugConstants.ID_ANT_DEBUG_MODEL);
732
     }
733
734
	/* (non-Javadoc)
735
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#saveBeforeLaunch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
736
	 */
737
	protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
738
		if (IExternalToolConstants.ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY.equals(
739
				configuration.getType().getCategory())) {
740
					// don't prompt for builders
741
					return true;
742
		}
743
		return super.saveBeforeLaunch(configuration, mode, monitor);
744
	}
745
	
746
	/**
747
	 * Sets the default working directory to be the parent folder of the buildfile if
748
	 * the user has not explicitly set the working directory.
749
	 */
750
	private void setDefaultWorkingDirectory(ILaunchConfigurationWorkingCopy copy) {
751
		try {
752
			String wd = copy.getAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
753
			if (wd == null) {
754
				wd= ExternalToolsUtil.getLocation(copy).removeLastSegments(1).toOSString();
755
				copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, wd);
756
			}
757
		} catch (CoreException e) {
758
			AntUIPlugin.log(e.getStatus());
759
		}
760
	}
761
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntLaunchShortcut.java (-6 / +7 lines)
Lines 22-27 Link Here
22
import org.eclipse.ant.internal.ui.model.AntProjectNode;
22
import org.eclipse.ant.internal.ui.model.AntProjectNode;
23
import org.eclipse.ant.internal.ui.model.AntTargetNode;
23
import org.eclipse.ant.internal.ui.model.AntTargetNode;
24
import org.eclipse.ant.internal.ui.model.AntTaskNode;
24
import org.eclipse.ant.internal.ui.model.AntTaskNode;
25
import org.eclipse.ant.launching.IAntLaunchConstants;
26
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
25
import org.eclipse.core.resources.IContainer;
27
import org.eclipse.core.resources.IContainer;
26
import org.eclipse.core.resources.IFile;
28
import org.eclipse.core.resources.IFile;
27
import org.eclipse.core.resources.IProject;
29
import org.eclipse.core.resources.IProject;
Lines 55-61 Link Here
55
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
57
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
56
import org.eclipse.ui.editors.text.ILocationProvider;
58
import org.eclipse.ui.editors.text.ILocationProvider;
57
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
59
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
58
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
59
60
60
import com.ibm.icu.text.MessageFormat;
61
import com.ibm.icu.text.MessageFormat;
61
62
Lines 166-172 Link Here
166
	 */
167
	 */
167
	protected List collectConfigurations(IPath filepath) {
168
	protected List collectConfigurations(IPath filepath) {
168
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
169
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
169
		ILaunchConfigurationType type = manager.getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
170
		ILaunchConfigurationType type = manager.getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
170
		if(type != null) {
171
		if(type != null) {
171
			try {
172
			try {
172
				ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
173
				ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
Lines 260-272 Link Here
260
		// set the target to run, if applicable
261
		// set the target to run, if applicable
261
		if (configuration != null) {
262
		if (configuration != null) {
262
			try {
263
			try {
263
				if (targetAttribute != null && !targetAttribute.equals(configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, DEFAULT_TARGET))) {
264
				if (targetAttribute != null && !targetAttribute.equals(configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, DEFAULT_TARGET))) {
264
					ILaunchConfigurationWorkingCopy copy = configuration.getWorkingCopy();
265
					ILaunchConfigurationWorkingCopy copy = configuration.getWorkingCopy();
265
					String attrValue = null;
266
					String attrValue = null;
266
					if (!DEFAULT_TARGET.equals(targetAttribute)) {
267
					if (!DEFAULT_TARGET.equals(targetAttribute)) {
267
						attrValue = targetAttribute;
268
						attrValue = targetAttribute;
268
					}
269
					}
269
					copy.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, attrValue);
270
					copy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, attrValue);
270
					configuration = copy.doSave();
271
					configuration = copy.doSave();
271
				}
272
				}
272
			} catch (CoreException exception) {
273
			} catch (CoreException exception) {
Lines 367-373 Link Here
367
	 */
368
	 */
368
	public static ILaunchConfiguration createDefaultLaunchConfiguration(IPath filePath, IProject project) {
369
	public static ILaunchConfiguration createDefaultLaunchConfiguration(IPath filePath, IProject project) {
369
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
370
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
370
		ILaunchConfigurationType type = manager.getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
371
		ILaunchConfigurationType type = manager.getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
371
				
372
				
372
		String projectName= project != null ? project.getName() : null;
373
		String projectName= project != null ? project.getName() : null;
373
		String name = getNewLaunchConfigurationName(filePath, projectName, null);
374
		String name = getNewLaunchConfigurationName(filePath, projectName, null);
Lines 415-421 Link Here
415
			IPath filePath = file.getLocation();
416
			IPath filePath = file.getLocation();
416
			if(filePath != null) {
417
			if(filePath != null) {
417
				ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
418
				ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
418
				ILaunchConfigurationType type = manager.getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
419
				ILaunchConfigurationType type = manager.getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
419
				if (type != null) {
420
				if (type != null) {
420
					try {
421
					try {
421
						ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
422
						ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMainTab.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import org.eclipse.ant.internal.ui.AntUtil;
14
import org.eclipse.ant.internal.ui.AntUtil;
15
import org.eclipse.ant.internal.ui.IAntUIConstants;
15
import org.eclipse.ant.internal.ui.IAntUIConstants;
16
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
16
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
17
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.resources.ResourcesPlugin;
Lines 35-41 Link Here
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
38
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab;
38
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
39
import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog;
39
import org.eclipse.ui.externaltools.internal.ui.FileSelectionDialog;
40
40
41
public class AntMainTab extends ExternalToolsMainTab {
41
public class AntMainTab extends ExternalToolsMainTab {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntMigrationDelegate.java (-77 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
import org.eclipse.ant.internal.ui.AntUtil;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.variables.IStringVariableManager;
18
import org.eclipse.core.variables.VariablesPlugin;
19
import org.eclipse.debug.core.ILaunchConfiguration;
20
import org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate;
21
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
22
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
23
24
/**
25
 * Delegate for migrating Ant launch configurations.
26
 * The migration process involves a resource mapping being created such that launch configurations
27
 * can be filtered from the launch configuration dialog based on resource availability.
28
 * 
29
 * @since 3.2
30
 */
31
public class AntMigrationDelegate implements ILaunchConfigurationMigrationDelegate {
32
	
33
	/**
34
	 * Method to get the file for the specified launch configuration that should be mapped to the launch configuration  
35
	 * 
36
	 * @param candidate the launch configuration that the file will be mapped to.
37
	 * @return the buildfile or <code>null</code> if not in the workspace
38
	 */
39
	protected IFile getFileForCandidate(ILaunchConfiguration candidate) {
40
		IFile file= null;
41
		String expandedLocation= null;
42
		String location= null;
43
		IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
44
		try {
45
			location= candidate.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null);
46
			if (location != null) {
47
				expandedLocation= manager.performStringSubstitution(location);
48
				if (expandedLocation != null) {
49
					file= AntUtil.getFileForLocation(expandedLocation, null);
50
				}
51
			}
52
		} catch (CoreException e) {
53
		}
54
		return file;
55
	}
56
	
57
	/* (non-Javadoc)
58
	 * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#isCandidate()
59
	 */
60
	public boolean isCandidate(ILaunchConfiguration candidate) throws CoreException {
61
		IResource[] mappedResources = candidate.getMappedResources();
62
		if (mappedResources != null && mappedResources.length > 0) {
63
			return false;
64
		}
65
		return getFileForCandidate(candidate) != null;
66
	}
67
68
	/* (non-Javadoc)
69
	 * @see org.eclipse.debug.core.ILaunchConfigurationMigrationDelegate#migrate(org.eclipse.debug.core.ILaunchConfiguration)
70
	 */
71
	public void migrate(ILaunchConfiguration candidate) throws CoreException {
72
		IFile file = getFileForCandidate(candidate);
73
		ILaunchConfigurationWorkingCopy wc = candidate.getWorkingCopy();
74
		wc.setMappedResources(new IResource[] {file});
75
		wc.doSave();
76
	}
77
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntProcess.java (-193 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.PlatformObject;
19
import org.eclipse.debug.core.DebugEvent;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.ILaunch;
22
import org.eclipse.debug.core.model.IProcess;
23
import org.eclipse.debug.core.model.IStreamsProxy;
24
import org.eclipse.debug.ui.console.IConsole;
25
26
public class AntProcess extends PlatformObject implements IProcess, IProgressMonitor {
27
	
28
	private AntStreamsProxy fProxy;
29
	private String fLabel = null;
30
	private ILaunch fLaunch = null;
31
	private Map fAttributes = null;
32
	private boolean fTerminated = false;
33
	private boolean fCancelled = false;
34
	private IConsole fConsole = null;
35
	
36
	public AntProcess(String label, ILaunch launch, Map attributes) {
37
		fLabel = label;
38
		fLaunch = launch;
39
		if (attributes == null) {
40
			fAttributes = new HashMap();
41
		} else {
42
			fAttributes = attributes;
43
		}
44
		String captureOutput= launch.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT);
45
		if(!("false".equals(captureOutput))) { //$NON-NLS-1$
46
			fProxy= new AntStreamsProxy();
47
		}
48
		launch.addProcess(this);
49
	}
50
51
	/**
52
	 * @see org.eclipse.debug.core.model.IProcess#getLabel()
53
	 */
54
	public String getLabel() {
55
		return fLabel;
56
	}
57
58
	/**
59
	 * @see org.eclipse.debug.core.model.IProcess#getLaunch()
60
	 */
61
	public ILaunch getLaunch() {
62
		return fLaunch;
63
	}
64
65
	/**
66
	 * @see org.eclipse.debug.core.model.IProcess#getStreamsProxy()
67
	 */
68
	public IStreamsProxy getStreamsProxy() {
69
		return fProxy;
70
	}
71
72
	/**
73
	 * @see org.eclipse.debug.core.model.IProcess#setAttribute(java.lang.String, java.lang.String)
74
	 */
75
	public void setAttribute(String key, String value) {
76
		fAttributes.put(key, value);
77
	}
78
79
	/**
80
	 * @see org.eclipse.debug.core.model.IProcess#getAttribute(java.lang.String)
81
	 */
82
	public String getAttribute(String key) {
83
		return (String)fAttributes.get(key);
84
	}
85
86
	/**
87
	 * @see org.eclipse.debug.core.model.IProcess#getExitValue()
88
	 */
89
	public int getExitValue() {
90
		return 0;
91
	}
92
93
	/**
94
	 * @see org.eclipse.debug.core.model.ITerminate#canTerminate()
95
	 */
96
	public boolean canTerminate() {
97
		return !isCanceled() && !isTerminated();
98
	}
99
100
	/**
101
	 * @see org.eclipse.debug.core.model.ITerminate#isTerminated()
102
	 */
103
	public boolean isTerminated() {
104
		return fTerminated;
105
	}
106
	
107
	protected void terminated() {
108
		if (!fTerminated) {
109
			fTerminated = true;
110
			if (DebugPlugin.getDefault() != null) {
111
				DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
112
			}
113
		}
114
	}
115
116
	/**
117
	 * @see org.eclipse.debug.core.model.ITerminate#terminate()
118
	 */
119
	public void terminate() {
120
		setCanceled(true);
121
	}
122
123
	/**
124
	 * Returns the console associated with this process, or <code>null</code> if
125
	 * none.
126
	 * 
127
	 * @return console, or <code>null</code>
128
	 */
129
	public IConsole getConsole() {
130
		return fConsole;
131
	}
132
	
133
	/**
134
	 * Sets the console associated with this process.
135
	 * 
136
	 * @param console
137
	 */
138
	public void setConsole(IConsole console) {
139
		fConsole = console;
140
	}
141
	
142
	// IProgressMonitor implemented to support termination.
143
	
144
	/**
145
	 * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
146
	 */
147
	public void beginTask(String name, int totalWork) {
148
	}
149
150
	/**
151
	 * @see org.eclipse.core.runtime.IProgressMonitor#done()
152
	 */
153
	public void done() {
154
	}
155
156
	/**
157
	 * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
158
	 */
159
	public void internalWorked(double work) {
160
	}
161
162
	/**
163
	 * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
164
	 */
165
	public boolean isCanceled() {
166
		return fCancelled;
167
	}
168
169
	/**
170
	 * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
171
	 */
172
	public void setCanceled(boolean value) {
173
		fCancelled = value;
174
	}
175
176
	/**
177
	 * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
178
	 */
179
	public void setTaskName(String name) {
180
	}
181
182
	/**
183
	 * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String)
184
	 */
185
	public void subTask(String name) {
186
	}
187
188
	/**
189
	 * @see org.eclipse.core.runtime.IProgressMonitor#worked(int)
190
	 */
191
	public void worked(int work) {
192
	}
193
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntPropertiesTab.java (-7 / +7 lines)
Lines 24-30 Link Here
24
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
24
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
25
import org.eclipse.ant.internal.ui.preferences.AntPropertiesBlock;
25
import org.eclipse.ant.internal.ui.preferences.AntPropertiesBlock;
26
import org.eclipse.ant.internal.ui.preferences.IAntBlockContainer;
26
import org.eclipse.ant.internal.ui.preferences.IAntBlockContainer;
27
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
27
import org.eclipse.ant.launching.IAntLaunchConstants;
28
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.CoreException;
29
import org.eclipse.debug.core.ILaunchConfiguration;
29
import org.eclipse.debug.core.ILaunchConfiguration;
30
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
Lines 116-129 Link Here
116
		setMessage(null);
116
		setMessage(null);
117
		Map properties= null;
117
		Map properties= null;
118
		try {
118
		try {
119
			properties= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, (Map)null);
119
			properties= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, (Map)null);
120
		} catch (CoreException ce) {
120
		} catch (CoreException ce) {
121
			AntUIPlugin.log(AntLaunchConfigurationMessages.AntPropertiesTab_Error_reading_configuration_9, ce);
121
			AntUIPlugin.log(AntLaunchConfigurationMessages.AntPropertiesTab_Error_reading_configuration_9, ce);
122
		}
122
		}
123
		
123
		
124
		String propertyFiles= null;
124
		String propertyFiles= null;
125
		try {
125
		try {
126
			propertyFiles= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, (String)null);
126
			propertyFiles= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES, (String)null);
127
		} catch (CoreException ce) {
127
		} catch (CoreException ce) {
128
			AntUIPlugin.log(AntLaunchConfigurationMessages.AntPropertiesTab_Error_reading_configuration_9, ce);
128
			AntUIPlugin.log(AntLaunchConfigurationMessages.AntPropertiesTab_Error_reading_configuration_9, ce);
129
		}
129
		}
Lines 160-167 Link Here
160
	 */
160
	 */
161
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
161
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
162
		if (fUseDefaultButton.getSelection()) {
162
		if (fUseDefaultButton.getSelection()) {
163
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, (Map)null);
163
			configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, (Map)null);
164
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, (String)null);
164
			configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES, (String)null);
165
			return;
165
			return;
166
		}
166
		}
167
				
167
				
Lines 175-181 Link Here
175
			}
175
			}
176
		}
176
		}
177
		
177
		
178
		configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES, properties);
178
		configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
179
		
179
		
180
		items= fAntPropertiesBlock.getPropertyFiles();
180
		items= fAntPropertiesBlock.getPropertyFiles();
181
		String files= null;
181
		String files= null;
Lines 189-195 Link Here
189
			files= buff.toString();
189
			files= buff.toString();
190
		}
190
		}
191
		
191
		
192
		configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES, files);
192
		configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES, files);
193
		
193
		
194
		fAntPropertiesBlock.saveSettings();
194
		fAntPropertiesBlock.saveSettings();
195
	}
195
	}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntStreamMonitor.java (-83 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
import org.eclipse.core.runtime.ListenerList;
14
import org.eclipse.debug.core.IStreamListener;
15
import org.eclipse.debug.core.model.IFlushableStreamMonitor;
16
17
/**
18
 * Stream monitor implementation for an Ant build process.
19
 */
20
public class AntStreamMonitor implements IFlushableStreamMonitor {
21
22
	private StringBuffer fContents = new StringBuffer();
23
	private ListenerList fListeners = new ListenerList(1);
24
	private boolean fBuffered = true;
25
	
26
	/**
27
	 * @see org.eclipse.debug.core.model.IStreamMonitor#addListener(org.eclipse.debug.core.IStreamListener)
28
	 */
29
	public void addListener(IStreamListener listener) {
30
		fListeners.add(listener);
31
	}
32
33
	/**
34
	 * @see org.eclipse.debug.core.model.IStreamMonitor#getContents()
35
	 */
36
	public String getContents() {
37
		return fContents.toString();
38
	}
39
40
	/**
41
	 * @see org.eclipse.debug.core.model.IStreamMonitor#removeListener(org.eclipse.debug.core.IStreamListener)
42
	 */
43
	public void removeListener(IStreamListener listener) {
44
		fListeners.remove(listener);
45
	}
46
47
	/**
48
	 * Appends the given message to this stream, and notifies listeners.
49
	 * 
50
	 * @param message
51
	 */
52
	public void append(String message) {
53
		if (isBuffered()) {
54
			fContents.append(message);
55
		}
56
		Object[] listeners = fListeners.getListeners();
57
		for (int i = 0; i < listeners.length; i++) {
58
			IStreamListener listener = (IStreamListener)listeners[i];
59
			listener.streamAppended(message, this);
60
		}
61
	}
62
	/**
63
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#flushContents()
64
	 */
65
	public void flushContents() {
66
		fContents.setLength(0);
67
	}
68
69
	/**
70
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#isBuffered()
71
	 */
72
	public boolean isBuffered() {
73
		return fBuffered;
74
	}
75
76
	/**
77
	 * @see org.eclipse.debug.core.model.IFlushableStreamMonitor#setBuffered(boolean)
78
	 */
79
	public void setBuffered(boolean buffer) {
80
		fBuffered = buffer;
81
	}
82
}
83
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntStreamsProxy.java (-65 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
14
import org.eclipse.ant.internal.ui.IAntUIConstants;
15
import org.eclipse.debug.core.model.IStreamMonitor;
16
import org.eclipse.debug.core.model.IStreamsProxy;
17
18
/**
19
 * 
20
 */
21
public class AntStreamsProxy implements IStreamsProxy {
22
	
23
	private AntStreamMonitor fErrorMonitor = new AntStreamMonitor();
24
	private AntStreamMonitor fOutputMonitor = new AntStreamMonitor();
25
	
26
	public static final String ANT_DEBUG_STREAM = IAntUIConstants.PLUGIN_ID + ".ANT_DEBUG_STREAM"; //$NON-NLS-1$
27
	public static final String ANT_VERBOSE_STREAM = IAntUIConstants.PLUGIN_ID + ".ANT_VERBOSE_STREAM"; //$NON-NLS-1$
28
	public static final String ANT_WARNING_STREAM = IAntUIConstants.PLUGIN_ID + ".ANT_WARNING_STREAM"; //$NON-NLS-1$
29
	
30
	private AntStreamMonitor fDebugMonitor = new AntStreamMonitor();
31
	private AntStreamMonitor fVerboseMonitor = new AntStreamMonitor();
32
	private AntStreamMonitor fWarningMonitor = new AntStreamMonitor();
33
34
	/**
35
	 * @see org.eclipse.debug.core.model.IStreamsProxy#getErrorStreamMonitor()
36
	 */
37
	public IStreamMonitor getErrorStreamMonitor() {
38
		return fErrorMonitor;
39
	}
40
41
	/**
42
	 * @see org.eclipse.debug.core.model.IStreamsProxy#getOutputStreamMonitor()
43
	 */
44
	public IStreamMonitor getOutputStreamMonitor() {
45
		return fOutputMonitor;
46
	}
47
48
	/**
49
	 * @see org.eclipse.debug.core.model.IStreamsProxy#write(java.lang.String)
50
	 */
51
	public void write(String input) {
52
	}
53
54
	public IStreamMonitor getWarningStreamMonitor() {
55
		return fWarningMonitor;
56
	}
57
	
58
	public IStreamMonitor getDebugStreamMonitor() {
59
		return fDebugMonitor;
60
	}	
61
	
62
	public IStreamMonitor getVerboseStreamMonitor() {
63
		return fVerboseMonitor;
64
	}	
65
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTabGroup.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.ant.internal.ui.launchConfigurations;
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
13
14
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
Lines 27-33 Link Here
27
import org.eclipse.debug.ui.RefreshTab;
28
import org.eclipse.debug.ui.RefreshTab;
28
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
29
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
29
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
30
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
30
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
31
31
32
public class AntTabGroup extends AbstractLaunchConfigurationTabGroup {
32
public class AntTabGroup extends AbstractLaunchConfigurationTabGroup {
33
33
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntTargetsTab.java (-13 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 28-34 Link Here
28
import org.eclipse.ant.internal.ui.model.AntProjectNode;
28
import org.eclipse.ant.internal.ui.model.AntProjectNode;
29
import org.eclipse.ant.internal.ui.model.AntTargetNode;
29
import org.eclipse.ant.internal.ui.model.AntTargetNode;
30
import org.eclipse.ant.internal.ui.model.InternalTargetFilter;
30
import org.eclipse.ant.internal.ui.model.InternalTargetFilter;
31
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
31
import org.eclipse.ant.launching.IAntLaunchConstants;
32
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
32
import org.eclipse.core.resources.ResourcesPlugin;
33
import org.eclipse.core.resources.ResourcesPlugin;
33
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.IProgressMonitor;
35
import org.eclipse.core.runtime.IProgressMonitor;
Lines 72-78 Link Here
72
import org.eclipse.swt.widgets.TableColumn;
73
import org.eclipse.swt.widgets.TableColumn;
73
import org.eclipse.swt.widgets.Text;
74
import org.eclipse.swt.widgets.Text;
74
import org.eclipse.ui.PlatformUI;
75
import org.eclipse.ui.PlatformUI;
75
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
76
76
77
import com.ibm.icu.text.MessageFormat;
77
import com.ibm.icu.text.MessageFormat;
78
78
Lines 613-619 Link Here
613
		setDirty(true);
613
		setDirty(true);
614
		boolean hideInternal= false;
614
		boolean hideInternal= false;
615
		try {
615
		try {
616
			hideInternal = fLaunchConfiguration.getAttribute(IAntLaunchConfigurationConstants.ATTR_HIDE_INTERNAL_TARGETS, false);
616
			hideInternal = fLaunchConfiguration.getAttribute(IAntLaunchConstants.ATTR_HIDE_INTERNAL_TARGETS, false);
617
		} catch (CoreException e) {
617
		} catch (CoreException e) {
618
			AntUIPlugin.log(e);
618
			AntUIPlugin.log(e);
619
		}
619
		}
Lines 621-627 Link Here
621
		handleFilterTargetsSelected();
621
		handleFilterTargetsSelected();
622
		int sort= SORT_NONE;
622
		int sort= SORT_NONE;
623
		try {
623
		try {
624
			sort = fLaunchConfiguration.getAttribute(IAntLaunchConfigurationConstants.ATTR_SORT_TARGETS, sort);
624
			sort = fLaunchConfiguration.getAttribute(IAntLaunchConstants.ATTR_SORT_TARGETS, sort);
625
		} catch (CoreException e) {
625
		} catch (CoreException e) {
626
			AntUIPlugin.log(e);
626
			AntUIPlugin.log(e);
627
		}
627
		}
Lines 631-637 Link Here
631
		String newLocation= null;
631
		String newLocation= null;
632
		
632
		
633
		try {
633
		try {
634
			configTargets= configuration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String)null);
634
			configTargets= configuration.getAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String)null);
635
			newLocation= configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null);
635
			newLocation= configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String)null);
636
		} catch (CoreException ce) {
636
		} catch (CoreException ce) {
637
			AntUIPlugin.log(AntLaunchConfigurationMessages.AntTargetsTab_Error_reading_configuration_12, ce);
637
			AntUIPlugin.log(AntLaunchConfigurationMessages.AntTargetsTab_Error_reading_configuration_12, ce);
Lines 697-721 Link Here
697
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
697
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
698
		//	attribute added in 3.0, so null must be used instead of false for backwards compatibility
698
		//	attribute added in 3.0, so null must be used instead of false for backwards compatibility
699
		if (fFilterInternalTargets.getSelection()) {
699
		if (fFilterInternalTargets.getSelection()) {
700
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_HIDE_INTERNAL_TARGETS, true);
700
			configuration.setAttribute(IAntLaunchConstants.ATTR_HIDE_INTERNAL_TARGETS, true);
701
		} else {
701
		} else {
702
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_HIDE_INTERNAL_TARGETS, (String)null);
702
			configuration.setAttribute(IAntLaunchConstants.ATTR_HIDE_INTERNAL_TARGETS, (String)null);
703
		}
703
		}
704
		//attribute added in 3.0, so null must be used instead of 0 for backwards compatibility
704
		//attribute added in 3.0, so null must be used instead of 0 for backwards compatibility
705
		if (fSortDirection != SORT_NONE) {
705
		if (fSortDirection != SORT_NONE) {
706
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_SORT_TARGETS, fSortDirection);
706
			configuration.setAttribute(IAntLaunchConstants.ATTR_SORT_TARGETS, fSortDirection);
707
		} else {
707
		} else {
708
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_SORT_TARGETS, (String)null);
708
			configuration.setAttribute(IAntLaunchConstants.ATTR_SORT_TARGETS, (String)null);
709
		}
709
		}
710
		
710
		
711
		if (fOrderedTargets.size() == 1) {
711
		if (fOrderedTargets.size() == 1) {
712
			AntTargetNode item = (AntTargetNode)fOrderedTargets.get(0);
712
			AntTargetNode item = (AntTargetNode)fOrderedTargets.get(0);
713
			if (item.isDefaultTarget()) {
713
			if (item.isDefaultTarget()) {
714
				configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String)null);
714
				configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String)null);
715
				return;
715
				return;
716
			}
716
			}
717
		} else if (fOrderedTargets.size() == 0) {
717
		} else if (fOrderedTargets.size() == 0) {
718
			configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, (String)null);
718
			configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, (String)null);
719
			return;
719
			return;
720
		}
720
		}
721
		
721
		
Lines 731-737 Link Here
731
			targets= buff.toString();
731
			targets= buff.toString();
732
		}  
732
		}  
733
733
734
		configuration.setAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, targets);
734
		configuration.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, targets);
735
	}
735
	}
736
736
737
	/* (non-Javadoc)
737
	/* (non-Javadoc)
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/AntWorkingDirectoryBlock.java (-1 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/ContributedClasspathEntriesEntry.java (-246 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
13
import java.io.File;
14
import java.io.FilenameFilter;
15
import java.io.IOException;
16
import java.net.MalformedURLException;
17
import java.net.URL;
18
import java.util.ArrayList;
19
import java.util.List;
20
21
import org.eclipse.ant.core.AntCorePlugin;
22
import org.eclipse.ant.core.AntCorePreferences;
23
import org.eclipse.ant.core.IAntClasspathEntry;
24
import org.eclipse.ant.internal.ui.AntUIPlugin;
25
import org.eclipse.ant.internal.ui.AntUtil;
26
import org.eclipse.ant.internal.ui.IAntUIConstants;
27
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.FileLocator;
29
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.Path;
31
import org.eclipse.core.runtime.Platform;
32
import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry;
34
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
35
import org.eclipse.jdt.launching.IVMInstall;
36
import org.eclipse.jdt.launching.JavaRuntime;
37
import org.eclipse.osgi.service.resolver.BundleDescription;
38
import org.osgi.framework.Bundle;
39
import org.w3c.dom.Document;
40
import org.w3c.dom.Element;
41
42
/**
43
 * A classpath entry that contains a contributed classpath entries
44
 * via the <code>extraClasspathEntries</code> extension point.
45
 * 
46
 * @since 3.0 
47
 */
48
public class ContributedClasspathEntriesEntry extends AbstractRuntimeClasspathEntry {
49
	
50
	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"; //$NON-NLS-1$
51
    
52
    public static List fgSWTEntries= null;
53
		
54
	/**
55
	 * Default contructor required to instantiate persisted extensions.
56
	 */
57
	public ContributedClasspathEntriesEntry() {
58
	}
59
	
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
62
	 */
63
	protected void buildMemento(Document document, Element memento) throws CoreException {
64
	}
65
	
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
68
	 */
69
	public void initializeFrom(Element memento) throws CoreException {
70
	}
71
	
72
	/* (non-Javadoc)
73
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
74
	 */
75
	public String getTypeId() {
76
		return TYPE_ID;
77
	}
78
	
79
	/* (non-Javadoc)
80
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
81
	 */
82
	public IRuntimeClasspathEntry[] getRuntimeClasspathEntries(ILaunchConfiguration configuration) throws CoreException {
83
		boolean separateVM= AntUtil.isSeparateJREAntBuild(configuration);
84
		boolean setInputHandler= configuration.getAttribute(IAntUIConstants.SET_INPUTHANDLER, true);
85
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
86
		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
87
		IAntClasspathEntry[] userEntries = prefs.getAdditionalClasspathEntries();
88
		List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
89
		IAntClasspathEntry entry;
90
		for (int i = 0; i < antClasspathEntries.length; i++) {
91
			 entry= antClasspathEntries[i];
92
			if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
93
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
94
			}
95
		}
96
		boolean haveToolsEntry= false;
97
		String path;
98
		for (int i = 0; i < userEntries.length; i++) {
99
			entry = userEntries[i];
100
			path= entry.getLabel();
101
            IPath toolsPath= new Path(path);
102
			if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
103
				haveToolsEntry= true;
104
				// replace with dynamically resolved tools.jar based on
105
				// the JRE being used
106
				addToolsJar(configuration, rtes, path);
107
			} else {
108
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
109
			}
110
		}
111
		if (!haveToolsEntry) {
112
			addToolsJar(configuration, rtes, null);
113
		}
114
		
115
		if (setInputHandler && separateVM) {
116
			addSWTJars(rtes);
117
		}
118
		
119
		return (IRuntimeClasspathEntry[]) rtes.toArray(new IRuntimeClasspathEntry[rtes.size()]);
120
	}
121
	
122
	private void addToolsJar(ILaunchConfiguration configuration, List rtes, String path) {
123
		IRuntimeClasspathEntry tools = getToolsJar(configuration);
124
		if (tools == null) {
125
			if (path != null) {
126
				//use the global entry
127
				rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
128
			} else {
129
				//use the default vm install to try to find a tools.jar
130
				IVMInstall install= JavaRuntime.getDefaultVMInstall();
131
				if (install != null) {
132
					IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
133
					if (entry != null) {
134
						rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())));
135
					}
136
				}
137
			}
138
		} else {
139
			rtes.add(tools);
140
		}
141
	}
142
	
143
	private void addSWTJars(List rtes) {
144
        if (fgSWTEntries == null) {
145
            fgSWTEntries= new ArrayList();
146
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
147
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
148
            BundleDescription[] fragments= description.getFragments();
149
            for (int i = 0; i < fragments.length; i++) {
150
                Bundle fragmentBundle= Platform.getBundle(fragments[i].getName());
151
                URL bundleURL;
152
                try {
153
                    bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$
154
                } catch (IOException e) {
155
                    AntUIPlugin.log(e);
156
                   continue;
157
                }
158
                String urlFileName= bundleURL.getFile();
159
                if (urlFileName.startsWith("file:")) { //$NON-NLS-1$
160
                    try {
161
                        urlFileName= new URL(urlFileName).getFile();
162
                        if (urlFileName.endsWith("!/")) { //$NON-NLS-1$
163
                            urlFileName= urlFileName.substring(0, urlFileName.length() - 2);
164
                        }
165
                    } catch (MalformedURLException e) {
166
                        AntUIPlugin.log(e);
167
                       continue;
168
                    }
169
                }
170
                IPath fragmentPath= new Path(urlFileName);
171
                if (fragmentPath.getFileExtension() != null) { //JAR file
172
                    fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
173
                } else { // folder
174
                    File bundleFolder= fragmentPath.toFile();
175
                    if (!bundleFolder.isDirectory()) {
176
                        continue;
177
                    }
178
                    String[] names= bundleFolder.list(new FilenameFilter() {
179
                        public boolean accept(File dir, String name) {
180
                            return name.endsWith(".jar"); //$NON-NLS-1$
181
                        }
182
                    });
183
                    for (int j = 0; j < names.length; j++) {
184
                        String jarName = names[j];
185
                        fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
186
                    }
187
                }
188
            }
189
        }
190
        rtes.addAll(fgSWTEntries);
191
	}
192
    
193
	/**
194
	 * Returns the tools.jar to use for this launch configuration, or <code>null</code>
195
	 * if none.
196
	 * 
197
	 * @param configuration configuration to resolve a tools.jar for
198
	 * @return associated tools.jar archive, or <code>null</code>
199
	 */
200
	private IRuntimeClasspathEntry getToolsJar(ILaunchConfiguration configuration) {
201
		try {
202
			IVMInstall install = JavaRuntime.computeVMInstall(configuration);
203
			if (install != null) {
204
				IAntClasspathEntry entry = AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry(new Path(install.getInstallLocation().getAbsolutePath()));
205
				if (entry != null) {
206
					return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()));
207
				}
208
			}
209
		} catch (CoreException ce) {
210
			//likely dealing with a non-Java project
211
		}
212
			
213
		return null;
214
	}
215
	
216
	/* (non-Javadoc)
217
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
218
	 */
219
	public String getName() {
220
		return AntLaunchConfigurationMessages.ContributedClasspathEntriesEntry_1;
221
	}
222
	/* (non-Javadoc)
223
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
224
	 */
225
	public int getType() {
226
		return IRuntimeClasspathEntry.OTHER;
227
	}
228
	/* (non-Javadoc)
229
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
230
	 */
231
	public boolean isComposite() {
232
		return true;
233
	}
234
	/* (non-Javadoc)
235
	 * @see java.lang.Object#equals(java.lang.Object)
236
	 */
237
	public boolean equals(Object obj) {
238
		return obj instanceof ContributedClasspathEntriesEntry;
239
	}
240
	/* (non-Javadoc)
241
	 * @see java.lang.Object#hashCode()
242
	 */
243
	public int hashCode() {
244
		return getClass().hashCode();
245
	}
246
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/EditAntHomeEntryAction.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
import org.eclipse.ant.core.AntCorePlugin;
13
import org.eclipse.ant.core.AntCorePlugin;
14
import org.eclipse.ant.core.AntCorePreferences;
14
import org.eclipse.ant.core.AntCorePreferences;
15
import org.eclipse.ant.internal.launching.launchConfigurations.AntHomeClasspathEntry;
15
import org.eclipse.ant.internal.ui.AntUIPlugin;
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
16
import org.eclipse.ant.internal.ui.IAntUIConstants;
17
import org.eclipse.ant.internal.ui.IAntUIConstants;
17
import org.eclipse.ant.internal.ui.preferences.AntPreferencesMessages;
18
import org.eclipse.ant.internal.ui.preferences.AntPreferencesMessages;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/IAntLaunchConfigurationConstants.java (-156 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
14
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
15
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
16
17
/**
18
 * Constant definitions for Ant launch configurations.
19
 * <p>
20
 * Constant definitions only; not to be implemented.
21
 * </p>
22
 * @since 3.0
23
 * @noimplement This interface is not intended to be implemented by clients.
24
 */
25
public interface IAntLaunchConfigurationConstants {
26
27
	/**
28
	* String attribute indicating the custom runtime classpath to use for an Ant
29
	* build. Default value is <code>null</code> which indicates that the global
30
	* classpath is to be used. Format is a comma separated listing of URLs.
31
	* @deprecated no longer supported: use {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER}
32
	* @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH
33
	*/
34
	public static final String ATTR_ANT_CUSTOM_CLASSPATH = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_CUSTOM_CLASSPATH"; //$NON-NLS-1$
35
	/**
36
	 * String attribute indicating the custom Ant home to use for an Ant build.
37
	 * Default value is <code>null</code> which indicates that no Ant home is to
38
	 * be set 
39
	 * @deprecated no longer supported: use {@link IJavaLaunchConfigurationConstants#ATTR_CLASSPATH_PROVIDER}
40
	 * @see IJavaLaunchConfigurationConstants#ATTR_DEFAULT_CLASSPATH
41
	 */
42
	public static final String ATTR_ANT_HOME = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_HOME"; //$NON-NLS-1$
43
	
44
	
45
	/**
46
	 * String attribute indicating the Ant targets to execute. Default value is
47
	 * <code>null</code> which indicates that the default target is to be
48
	 * executed. Format is a comma separated listing of targets.
49
	 * 
50
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants}
51
	 */
52
	public static final String ATTR_ANT_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS;
53
	/**
54
	 * String attribute indicating the Ant targets to execute after a clean (full build) for an Ant builder. Default value is
55
	 * <code>null</code> which indicates that the default target is to be
56
	 * executed. Format is a comma separated listing of targets.
57
	 * @since 3.1
58
	 * 
59
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants}
60
	 */
61
	public static final String ATTR_ANT_AFTER_CLEAN_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AFTER_CLEAN_TARGETS;
62
	/**
63
	 * String attribute indicating the Ant targets to execute during a manual build for an Ant builder. Default value is
64
	 * <code>null</code> which indicates that the default target is to be
65
	 * executed. Format is a comma separated listing of targets.
66
	 * @since 3.1
67
	 * 
68
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
69
	 */
70
	public static final String ATTR_ANT_MANUAL_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_MANUAL_TARGETS;
71
	/**
72
	 * String attribute indicating the Ant targets to execute during an auto build for an Ant builder. Default value is
73
	 * <code>null</code> which indicates that the default target is to be
74
	 * executed. Format is a comma separated listing of targets.
75
	 * @since 3.1
76
	 * 
77
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
78
	 */
79
	public static final String ATTR_ANT_AUTO_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_AUTO_TARGETS;
80
	/**
81
	 * String attribute indicating the Ant targets to execute during a clean for an Ant builder. Default value is
82
	 * <code>null</code> which indicates that the default target is to be
83
	 * executed. Format is a comma separated listing of targets.
84
	 * @since 3.1
85
	 * 
86
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
87
	 */
88
	public static final String ATTR_ANT_CLEAN_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_CLEAN_TARGETS;
89
	/**
90
	 * Boolean attribute indicating whether or not target specification for an Ant builder has been updated for
91
	 * 3.1 
92
	 * 
93
	 * @since 3.1
94
	 * 
95
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants}
96
	 */
97
	public static final String ATTR_TARGETS_UPDATED = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_TARGETS_UPDATED;
98
	/**
99
	 * Map attribute indicating the Ant properties to be defined during the
100
	 * build. Default value is <code>null</code> which indicates no additional
101
	 * properties will be defined.
102
	 * 
103
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants}
104
	 */
105
	public static final String ATTR_ANT_PROPERTIES = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTIES;				
106
	/**
107
	 * String attribute indicating the Ant targets to execute. Default value is
108
	 * <code>null</code> which indicates that no additional property files
109
	 * will be defined. Format is a comma separated listing of property files.
110
	 * 
111
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
112
	 */
113
	public static final String ATTR_ANT_PROPERTY_FILES = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_ANT_PROPERTY_FILES;
114
	/**
115
	 * Boolean attribute indicating whether or not internal targets (targets with no
116
	 * description) should be hidden from the user in the launch configuration dialog.
117
	 * Default value is <code>false</code> which indicates that all targets will be
118
	 * displayed.
119
	 * 
120
	 * @since 3.0
121
	 * 
122
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants}
123
	 */
124
	public static final String ATTR_HIDE_INTERNAL_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_HIDE_INTERNAL_TARGETS;
125
	/**
126
	 * Integer attribute indicating which column targets should be sorted on. A
127
	 * value of 0 indicates target name, 1 indicates target description, and -1
128
	 * indicates no sort. Default value is -1.
129
	 * 
130
	 * @since 3.0
131
	 * 
132
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants}
133
	 */
134
	public static final String ATTR_SORT_TARGETS = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ATTR_SORT_TARGETS;
135
	/**
136
	 * Ant launch configuration type identifier.
137
	 * 
138
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
139
	 */
140
	public static final String ID_ANT_LAUNCH_CONFIGURATION_TYPE = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE;
141
	/**
142
	 * Ant builder launch configuration type identifier. Ant project builders
143
	 * are of this type.
144
	 * 
145
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
146
	 */
147
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE;
148
	/**
149
	 * Identifier for Ant processes (value <code>org.eclipse.ant.ui.antProcess</code>). This identifier is
150
	 * set as the value for the <code>IProcess.ATTR_PROCESS_TYPE</code>
151
	 * attribute in processes created by the Ant launch delegate.
152
	 * 
153
	 * @deprecated This constant has been migrated to {@link org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants} 
154
	 */
155
	public static final String ID_ANT_PROCESS_TYPE = org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE;
156
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/MessageIds.java (-21 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
14
public class MessageIds {
15
16
	public final static String PROCESS_ID=   "processID"; //$NON-NLS-1$
17
	public final static String BUILD_CANCELLED= "cancelled"; //$NON-NLS-1$
18
	//constants need to start greater than the Project.MSG_* constants
19
    public final static String TASK= "6"; //$NON-NLS-1$
20
    public final static String TARGET= "7"; //$NON-NLS-1$
21
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntBuildListener.java (-396 lines)
Removed Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2003, 2008 IBM Corporation and others.
3
 *  All rights reserved. This program and the accompanying materials
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 *  which accompanies this distribution, and is available at
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
14
import java.io.BufferedReader;
15
import java.io.File;
16
import java.io.IOException;
17
import java.io.InputStreamReader;
18
import java.net.ServerSocket;
19
import java.net.Socket;
20
import java.net.SocketException;
21
import java.net.SocketTimeoutException;
22
import java.util.ArrayList;
23
import java.util.HashMap;
24
import java.util.Iterator;
25
import java.util.List;
26
import java.util.Map;
27
import java.util.StringTokenizer;
28
29
import org.apache.tools.ant.Project;
30
import org.apache.tools.ant.util.FileUtils;
31
import org.eclipse.ant.internal.core.AbstractEclipseBuildLogger;
32
import org.eclipse.ant.internal.ui.AntUIPlugin;
33
import org.eclipse.ant.internal.ui.AntUtil;
34
import org.eclipse.ant.internal.ui.ExternalHyperlink;
35
import org.eclipse.ant.internal.ui.IAntUIConstants;
36
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
37
import org.eclipse.core.resources.IFile;
38
import org.eclipse.core.runtime.ISafeRunnable;
39
import org.eclipse.debug.core.DebugPlugin;
40
import org.eclipse.debug.core.ILaunch;
41
import org.eclipse.debug.core.ILaunchesListener;
42
import org.eclipse.debug.core.model.IProcess;
43
import org.eclipse.debug.ui.console.FileLink;
44
import org.eclipse.jface.preference.IPreferenceStore;
45
import org.eclipse.jface.text.Region;
46
import org.eclipse.ui.console.IHyperlink;
47
48
/**
49
 * Parts adapted from org.eclipse.jdt.internal.junit.ui.RemoteTestRunnerClient
50
 * The client side of the RemoteAntBuildLogger. Handles the
51
 * marshalling of the different messages.
52
 */
53
public class RemoteAntBuildListener implements ILaunchesListener {
54
    public abstract class ListenerSafeRunnable implements ISafeRunnable {
55
        public void handleException(Throwable exception) {
56
            AntUIPlugin.log(exception);
57
        }
58
    }
59
60
    /**
61
     * The server socket
62
     */
63
    private ServerSocket fServerSocket;
64
    private Socket fSocket;
65
    private BufferedReader fBufferedReader;
66
    private IProcess fProcess;
67
    private String fProcessId;
68
    private File fBuildFileParent= null;
69
    private List fMessageQueue;
70
    protected ILaunch fLaunch;
71
    private Map fFileNameToIFile= new HashMap();
72
    private String fLastFileName= null;
73
    private String fLastTaskName= null;
74
    private boolean fBuildFailed= false;
75
    
76
    /**
77
     * Reads the message stream from the RemoteAntBuildLogger
78
     */
79
    private class ServerConnection extends Thread {
80
        private int fServerPort;
81
        
82
        public ServerConnection(int port) {
83
            super("Ant Build Server Connection"); //$NON-NLS-1$
84
            setDaemon(true);
85
            fServerPort= port;
86
        }
87
        
88
        public void run() {
89
            Exception exception= null;
90
            try {
91
                fServerSocket= new ServerSocket(fServerPort);
92
                IPreferenceStore prefs = AntUIPlugin.getDefault().getPreferenceStore();
93
                int socketTimeout= prefs.getInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT);
94
                fServerSocket.setSoTimeout(socketTimeout);
95
                fSocket= fServerSocket.accept();
96
                fBufferedReader= new BufferedReader(new InputStreamReader(fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
97
                String message;
98
                while(fBufferedReader != null && (message= fBufferedReader.readLine()) != null) {
99
                    receiveMessage(message);
100
                }
101
            } catch (SocketException e) {
102
            } catch (SocketTimeoutException e) {
103
                exception= e;
104
            } catch (IOException e) {
105
                // fall through
106
                exception= e;
107
            }
108
            if (exception != null) {
109
                AntUIPlugin.log(exception);
110
            }
111
            shutDown();
112
        }
113
    }
114
    
115
    public RemoteAntBuildListener(ILaunch launch) {
116
        super();
117
        fLaunch= launch;
118
        DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
119
    }
120
121
    /**
122
     * Start listening to an Ant build. Start a server connection that
123
     * the RemoteAntBuildLogger can connect to.
124
     * 
125
     * @param eventPort The port number to create the server connection on
126
     */
127
    public synchronized void startListening(int eventPort){
128
        ServerConnection connection = new ServerConnection(eventPort);
129
        connection.start();
130
    }
131
132
    protected synchronized void shutDown() {
133
        fLaunch= null;
134
        fFileNameToIFile= null;
135
        if (DebugPlugin.getDefault() != null) {
136
        	DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
137
        }
138
        try {
139
            if (fBufferedReader != null) {
140
                fBufferedReader.close();
141
                fBufferedReader= null;
142
            }
143
        } catch(IOException e) {
144
        }   
145
        try{
146
            if(fSocket != null) {
147
                fSocket.close();
148
                fSocket= null;
149
            }
150
        } catch(IOException e) {
151
        }
152
        try{
153
            if(fServerSocket != null) {
154
                fServerSocket.close();
155
                fServerSocket= null;
156
            }
157
        } catch(IOException e) {
158
        }
159
    }
160
        
161
    protected void receiveMessage(String message) {
162
        if (message.startsWith(MessageIds.TASK)) {
163
            receiveTaskMessage(message);
164
        } else if (message.startsWith(MessageIds.TARGET)) {
165
            receiveTargetMessage(message);
166
        } else if (message.startsWith(MessageIds.PROCESS_ID)) {
167
            message= message.substring(MessageIds.PROCESS_ID.length());
168
            fProcessId= message;
169
        } else {
170
            int index= message.indexOf(',');
171
            if (index > 0) {
172
                int priority= Integer.parseInt(message.substring(0, index));
173
                message= message.substring(index + 1);
174
                
175
                writeMessage(message + System.getProperty("line.separator"), priority); //$NON-NLS-1$
176
                if (message.startsWith("BUILD FAILED")) { //$NON-NLS-1$
177
                    fBuildFailed= true;
178
                } else if (fBuildFailed) {
179
                	if (message.startsWith("Total time:")) { //$NON-NLS-1$
180
                		fBuildFailed= false;
181
                	} else {
182
                		AntUtil.linkBuildFailedMessage(message, getProcess());
183
                	}
184
				}
185
            }
186
        }
187
    }
188
189
    private void receiveTargetMessage(String message) {
190
        message= message.substring(MessageIds.TARGET.length());
191
        StringTokenizer tokenizer= new StringTokenizer(message, ","); //$NON-NLS-1$
192
        message= tokenizer.nextToken();
193
        if (tokenizer.hasMoreTokens()) {
194
        	int locationLength= Integer.parseInt(tokenizer.nextToken());
195
        	String location= tokenizer.nextToken(); 
196
        	while (location.length() < locationLength) { //path with a comma in it
197
        		location+=","; //$NON-NLS-1$
198
        		location+= tokenizer.nextToken();
199
        	}
200
            int lineNumber= Integer.parseInt(tokenizer.nextToken());
201
            generateLink(message, location, lineNumber, 0, message.length() - 1);
202
        }
203
        writeMessage(message + System.getProperty("line.separator"), Project.MSG_INFO); //$NON-NLS-1$
204
    }
205
206
    private void receiveTaskMessage(String message) {
207
        message= message.substring(MessageIds.TASK.length());
208
        
209
        int index= message.indexOf(',');
210
        int priority= Integer.parseInt(message.substring(0, index));
211
        int index2= message.indexOf(',', index + 1);
212
        String taskName= message.substring(index + 1, index2);
213
        if (taskName.length() == 0) {
214
            taskName= fLastTaskName;
215
        }
216
        int index3= message.indexOf(',', index2 + 1);
217
        int lineLength= Integer.parseInt(message.substring(index2 + 1, index3));
218
        int index4= index3 + 1 + lineLength;
219
        
220
        String line= message.substring(index3 + 1, index4);
221
        StringBuffer labelBuff= new StringBuffer();
222
        labelBuff.append('[');
223
        labelBuff.append(taskName);
224
        labelBuff.append("] "); //$NON-NLS-1$
225
        labelBuff.append(line);
226
        line= labelBuff.toString();
227
        
228
        fLastTaskName= taskName;
229
        
230
        int locationIndex= message.indexOf(',', index4 + 1);
231
        int finalIndex= locationIndex + 1;
232
        String fileName= message.substring(index4 + 1, locationIndex);
233
        int locationLength= 0;
234
        if (fileName.length() == 0) {
235
            fileName= fLastFileName;
236
        } else {
237
        	finalIndex= message.indexOf(',', locationIndex) + 1;
238
        	locationLength= Integer.parseInt(fileName);
239
        	fileName= message.substring(finalIndex, finalIndex + locationLength);
240
        	locationLength+=1; //set past delimiter
241
        }
242
        fLastFileName= fileName;
243
        int lineNumber= Integer.parseInt(message.substring(finalIndex + locationLength));
244
245
        int size = IAntUIConstants.LEFT_COLUMN_SIZE - (taskName.length() + 3);
246
        int offset = Math.max(size - 2, 1);
247
        int length = IAntUIConstants.LEFT_COLUMN_SIZE - size - 3;
248
        if (fileName != null) {
249
            generateLink(line, fileName, lineNumber, offset, length);
250
        }
251
        
252
        StringBuffer fullMessage= new StringBuffer();
253
        adornMessage(taskName, line, fullMessage);
254
        writeMessage(fullMessage.append(System.getProperty("line.separator")).toString(), priority); //$NON-NLS-1$
255
    }
256
257
    private void generateLink(String line, String fileName, int lineNumber, int offset, int length) {
258
        IHyperlink taskLink= null;
259
        if (lineNumber == -1) {
260
            //fileName will actually be the String representation of Location
261
           taskLink = AntUtil.getLocationLink(fileName, fBuildFileParent);
262
        } else {
263
            IFile file= (IFile) fFileNameToIFile.get(fileName);
264
            if (file == null) {
265
                file= AntUtil.getFileForLocation(fileName, fBuildFileParent);
266
                if (file != null) {
267
                    fFileNameToIFile.put(fileName, file);
268
                    taskLink= new FileLink(file, null, -1, -1, lineNumber);
269
                } else {
270
                    File javaIOFile= FileUtils.getFileUtils().resolveFile(fBuildFileParent, fileName);
271
                    if (javaIOFile.exists()) {
272
                        taskLink= new ExternalHyperlink(javaIOFile, lineNumber);
273
                    }
274
                }
275
            } else {
276
                taskLink= new FileLink(file, null, -1, -1, lineNumber);
277
            }
278
        }
279
        if (taskLink != null) {
280
            TaskLinkManager.addTaskHyperlink(getProcess(), taskLink, new Region(offset, length), line);
281
        }
282
    }
283
    
284
    /**
285
     * Returns the associated process, finding it if necessary.
286
     */
287
    protected IProcess getProcess() {
288
        if (fProcess == null) {
289
            if (fProcessId != null) {
290
                IProcess[] all = DebugPlugin.getDefault().getLaunchManager().getProcesses();
291
                for (int i = 0; i < all.length; i++) {
292
                    IProcess process = all[i];
293
                    if (fProcessId.equals(process.getAttribute(AbstractEclipseBuildLogger.ANT_PROCESS_ID))) {
294
                        fProcess = process;
295
                        break;
296
                    }
297
                }
298
            }
299
        }
300
        return fProcess;
301
    }
302
    
303
    private AntStreamMonitor getMonitor(int priority) {
304
        IProcess process= getProcess();
305
        if (process == null) {
306
            return null;
307
        }
308
        AntStreamsProxy proxy = (AntStreamsProxy)process.getStreamsProxy();
309
        if (proxy == null) {
310
            return null;
311
        }
312
        AntStreamMonitor monitor = null;
313
        switch (priority) {
314
            case Project.MSG_INFO:
315
                monitor = (AntStreamMonitor)proxy.getOutputStreamMonitor();
316
                break;
317
            case Project.MSG_ERR:
318
                monitor = (AntStreamMonitor)proxy.getErrorStreamMonitor();
319
                break;
320
            case Project.MSG_DEBUG:
321
                monitor = (AntStreamMonitor)proxy.getDebugStreamMonitor();
322
                break;
323
            case Project.MSG_WARN:
324
                monitor = (AntStreamMonitor)proxy.getWarningStreamMonitor();
325
                break;
326
            case Project.MSG_VERBOSE:
327
                monitor = (AntStreamMonitor)proxy.getVerboseStreamMonitor();
328
                break;
329
        }
330
        return monitor;
331
    }
332
    
333
    /**
334
     * Builds a right justified task prefix for the given build event, placing it
335
     * in the given string buffer.
336
     *  
337
     * @param event build event
338
     * @param fullMessage buffer to place task prefix in
339
     */
340
    private void adornMessage(String taskName, String line, StringBuffer fullMessage) {
341
        if (taskName == null) {
342
            taskName = "null"; //$NON-NLS-1$
343
        }
344
        
345
        int size = IAntUIConstants.LEFT_COLUMN_SIZE - (taskName.length() + 6);
346
        for (int i = 0; i < size; i++) {
347
            fullMessage.append(' ');
348
        }
349
        
350
        fullMessage.append(line);
351
    }
352
    
353
    protected void writeMessage(String message, int priority) {
354
        AntStreamMonitor monitor= getMonitor(priority);
355
        if (monitor == null) {
356
            if (fMessageQueue == null) {
357
                fMessageQueue= new ArrayList();
358
            }
359
            fMessageQueue.add(message);
360
            return;
361
        }
362
        if (fMessageQueue != null) {
363
            for (Iterator iter = fMessageQueue.iterator(); iter.hasNext();) {
364
                String oldMessage = (String) iter.next();
365
                monitor.append(oldMessage);
366
            }
367
            fMessageQueue= null;
368
        }
369
        monitor.append(message);
370
    }
371
    
372
    /* (non-Javadoc)
373
     * @see org.eclipse.debug.core.ILaunchesListener#launchesAdded(org.eclipse.debug.core.ILaunch[])
374
     */
375
    public void launchesAdded(ILaunch[] launches) {
376
    }
377
378
    /* (non-Javadoc)
379
     * @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
380
     */
381
    public void launchesChanged(ILaunch[] launches) {
382
    }
383
384
    /* (non-Javadoc)
385
     * @see org.eclipse.debug.core.ILaunchesListener#launchesRemoved(org.eclipse.debug.core.ILaunch[])
386
     */
387
    public void launchesRemoved(ILaunch[] launches) {
388
        for (int i = 0; i < launches.length; i++) {
389
            ILaunch launch = launches[i];
390
            if (launch.equals(fLaunch)) {
391
                shutDown();
392
                return;
393
            }
394
        }
395
    }
396
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntProcessFactory.java (-34 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
18
import org.eclipse.debug.core.ILaunch;
19
import org.eclipse.debug.core.IProcessFactory;
20
import org.eclipse.debug.core.model.IProcess;
21
22
public class RemoteAntProcessFactory implements IProcessFactory {
23
24
	/* (non-Javadoc)
25
	 * @see org.eclipse.debug.core.IProcessFactory#newProcess(org.eclipse.debug.core.ILaunch, java.lang.Process, java.lang.String, java.util.Map)
26
	 */
27
	public IProcess newProcess(ILaunch launch, Process process, String label, Map attributes) {
28
		if (attributes == null) {
29
			attributes= new HashMap(1);
30
		}
31
		attributes.put(IProcess.ATTR_PROCESS_TYPE, IAntLaunchConfigurationConstants.ID_ANT_PROCESS_TYPE);
32
		return new RemoteAntRuntimeProcess(launch, process, label, attributes);
33
	}
34
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/RemoteAntRuntimeProcess.java (-37 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.launchConfigurations;
13
14
import java.util.Map;
15
import org.eclipse.debug.core.ILaunch;
16
import org.eclipse.debug.core.model.IStreamsProxy;
17
import org.eclipse.debug.core.model.RuntimeProcess;
18
19
public class RemoteAntRuntimeProcess extends RuntimeProcess {
20
21
	/**
22
	 * Constructs a RuntimeProcess on the given system process
23
	 * with the given name, adding this process to the given
24
	 * launch.
25
	 * Sets the streams proxy to an AntStreamsProxy if output is captured.
26
	 */
27
	public RemoteAntRuntimeProcess(ILaunch launch, Process process, String name, Map attributes) {
28
		super(launch, process, name, attributes);
29
	}
30
	
31
	/* (non-Javadoc)
32
	 * @see org.eclipse.debug.core.model.RuntimeProcess#createStreamsProxy()
33
	 */
34
	protected IStreamsProxy createStreamsProxy() {
35
		return new AntStreamsProxy();
36
	}
37
}
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/SetTargetsDialog.java (-2 / +2 lines)
Lines 11-17 Link Here
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
import org.eclipse.ant.internal.ui.AntUIPlugin;
13
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
14
import org.eclipse.ant.launching.IAntLaunchConstants;
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
17
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.dialogs.Dialog;
Lines 64-70 Link Here
64
			defaultValue= ""; //$NON-NLS-1$
64
			defaultValue= ""; //$NON-NLS-1$
65
		}
65
		}
66
        try {
66
        try {
67
            return fConfiguration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, defaultValue);
67
            return fConfiguration.getAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, defaultValue);
68
        } catch (CoreException e) {
68
        } catch (CoreException e) {
69
            return defaultValue;
69
            return defaultValue;
70
        }
70
        }
(-)Ant Tools Support/org/eclipse/ant/internal/ui/launchConfigurations/TaskLinkManager.java (-168 / +57 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-23 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.launchConfigurations;
11
package org.eclipse.ant.internal.ui.launchConfigurations;
12
12
13
13
import java.io.File;
14
import java.util.ArrayList;
15
import java.util.HashMap;
14
import java.util.HashMap;
16
import java.util.Iterator;
15
import java.util.Iterator;
17
import java.util.List;
16
import java.util.List;
18
import java.util.Map;
17
import java.util.Map;
19
18
19
import org.apache.tools.ant.util.FileUtils;
20
import org.eclipse.ant.internal.launching.AntLaunch;
21
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
22
import org.eclipse.ant.internal.launching.LinkDescriptor;
20
import org.eclipse.ant.internal.ui.AntUtil;
23
import org.eclipse.ant.internal.ui.AntUtil;
24
import org.eclipse.ant.internal.ui.ExternalHyperlink;
21
import org.eclipse.core.resources.IFile;
25
import org.eclipse.core.resources.IFile;
22
import org.eclipse.debug.core.model.IProcess;
26
import org.eclipse.debug.core.model.IProcess;
23
import org.eclipse.debug.ui.console.FileLink;
27
import org.eclipse.debug.ui.console.FileLink;
Lines 38-158 Link Here
38
 * may be stored to process future incoming tasks hyperlinks.
42
 * may be stored to process future incoming tasks hyperlinks.
39
 */
43
 */
40
public class TaskLinkManager {
44
public class TaskLinkManager {
41
	
42
	/**
43
	 * A map of processes to lists of queued task hyperlink entries
44
	 */
45
	private static Map fgProcessToLinks;
46
	
47
	/**
48
	 * A map of processes to lists of queued new line regions
49
	 */
50
	private static Map fgProcessToNewLines;
51
	
52
	private static List fgAntBuilds;
53
	
54
	private static class HyperlinkEntry {
55
		private IHyperlink fLink;
56
		private IRegion fRegion;
57
		private String fMessage;
58
		
59
		public HyperlinkEntry(IHyperlink link, IRegion region, String message) {
60
			fLink = link;
61
			fRegion = region;	
62
			fMessage = message;
63
		}
64
		
65
		public IRegion getRegion() {
66
			return fRegion;
67
		}
68
		
69
		public IHyperlink getLink() {
70
			return fLink;
71
		}
72
		
73
		public String getMessage() {
74
			return fMessage;
75
		}
76
	}
77
	
78
	private static class LineEntry {
79
		private IConsole fConsole;
80
		private IRegion fRegion;
81
	
82
		public LineEntry(IConsole console, IRegion region) {
83
			fConsole = console;
84
			fRegion = region;	
85
		}
86
	
87
		public IRegion getRegion() {
88
			return fRegion;
89
		}
90
	
91
		public IConsole getConsole() {
92
			return fConsole;
93
		}
94
	}
95
45
46
	private static Map fFileNameToIFile = new HashMap();
47
	
96
	/**
48
	/**
97
	 * Not to be called.
49
	 * Not to be called.
98
	 */
50
	 */
99
	private TaskLinkManager() {
51
	private TaskLinkManager() {
100
		super();
52
		super();
101
	}
53
	}
102
	
54
103
	/**
55
	private static IHyperlink createHyperlink(LinkDescriptor linkDescriptor) {
104
	 * Registers a hyperlink for the given process and task name. The given
56
		String fileName = linkDescriptor.getFileName();
105
	 * region is relative to the beginning of the line (not the document).
57
		int lineNumber = linkDescriptor.getLineNumber();
106
	 * 
58
107
	 * @param process the process associated with the link
59
		IHyperlink taskLink = null;
108
	 * @param link the link for the process
60
		if (lineNumber == -1) {
109
	 * @param region The region within the line
61
			// fileName will actually be the String representation of Location
110
	 * @param message The message related to the link
62
			taskLink = AntUtil.getLocationLink(fileName, null);
111
	 */
63
		} else {
112
	public static synchronized void addTaskHyperlink(IProcess process, IHyperlink link, IRegion region, String message) {
64
			IFile file = (IFile) fFileNameToIFile.get(fileName);
113
		if (fgProcessToNewLines != null) {
65
			if (file == null) {
114
			List newLines = (List)fgProcessToNewLines.get(process);
66
				file = AntLaunchingUtil.getFileForLocation(fileName, null);
115
			if (newLines != null) {
67
				if (file != null) {
116
				for (int index= 0; index < newLines.size(); index++) {
68
					fFileNameToIFile.put(fileName, file);
117
					LineEntry newLine = (LineEntry) newLines.get(index);
69
					taskLink = new FileLink(file, null, -1, -1, lineNumber);
118
					if (addLink(newLine.getConsole(), link, newLine.getRegion(), region, message)) {
70
				} else if(fileName!=null){
119
						newLines.subList(0, index + 1).clear();
71
					File javaIOFile = FileUtils.getFileUtils().resolveFile(null, fileName);
120
						return;
72
					if (javaIOFile.exists()) {
73
						taskLink = new ExternalHyperlink(javaIOFile, lineNumber);
121
					}
74
					}
122
				}
75
				}
76
			} else {
77
				taskLink = new FileLink(file, null, -1, -1, lineNumber);
123
			}
78
			}
124
		}
79
		}
125
				
80
		return taskLink;
126
		if (fgProcessToLinks == null) {
127
			fgProcessToLinks = new HashMap();
128
			
129
		}
130
		List links = (List)fgProcessToLinks.get(process);
131
		if (links == null) {
132
			links = new ArrayList(10);
133
			fgProcessToLinks.put(process, links);
134
		}
135
		
136
		links.add(new HyperlinkEntry(link, region, message));
137
	}
81
	}
138
	
82
	
139
	private static boolean addLink(IConsole console, IHyperlink link, IRegion lineRegion, IRegion region, String message) {
83
	private static boolean addLink(IConsole console, IRegion lineRegion, LinkDescriptor descriptor) {
140
		
141
		int length = region.getLength();
142
		
143
		String text;
144
		try {
84
		try {
145
			text = console.getDocument().get(lineRegion.getOffset(), lineRegion.getLength());
85
			String text = console.getDocument().get(lineRegion.getOffset(), lineRegion.getLength());
86
			if (text.trim().equals(descriptor.getLine())) {
87
				int offset = lineRegion.getOffset() + descriptor.getOffset();
88
				IHyperlink link = createHyperlink(descriptor);
89
				if (link != null) {
90
					console.addLink(link, offset, descriptor.getLength());
91
				}
92
				return true;
93
			}
146
		} catch (BadLocationException e) {
94
		} catch (BadLocationException e) {
147
			return false;
148
		}
149
		if (text.trim().equals(message)) {
150
			int offset = lineRegion.getOffset() + region.getOffset();
151
			console.addLink(link, offset, length);
152
			return true;
153
		}
95
		}
154
		return false;
96
		return false;
155
	}
97
	}	
156
98
157
	/**
99
	/**
158
	 * A new line has been added to the given console. Adds any task hyperlink
100
	 * A new line has been added to the given console. Adds any task hyperlink
Lines 163-207 Link Here
163
	 * @param newLine
105
	 * @param newLine
164
	 */
106
	 */
165
	public static synchronized void processNewLine(IConsole console, IRegion newLine) {
107
	public static synchronized void processNewLine(IConsole console, IRegion newLine) {
166
		IProcess process = console.getProcess();
108
		AntLaunch launch = (AntLaunch) console.getProcess().getLaunch();
167
		if (fgAntBuilds != null && fgAntBuilds.contains(process)) {
109
		List links = launch.getLinkDescriptors();
168
			if (linkBuildFileMessage(console, newLine)) {
110
169
				fgAntBuilds.remove(process);
111
		if (linkBuildFileMessage(console, newLine)) {
170
				return;
171
			}
172
		}
173
		if (fgProcessToLinks == null) {
174
			addNewLine(console, newLine, process);
175
			return;
112
			return;
176
		}
113
		}
177
		
114
178
		List links = (List)fgProcessToLinks.get(process);
115
		if (links == null || links.isEmpty()) {
179
		if (links == null) {
180
			addNewLine(console, newLine, process);
181
			return;
116
			return;
182
		}
117
		}
183
		
118
184
		for (int index= 0; index < links.size(); index++) {
119
		for (Iterator i = links.iterator(); i.hasNext();) {
185
			HyperlinkEntry link = (HyperlinkEntry) links.get(index);
120
			LinkDescriptor descriptor = (LinkDescriptor) i.next();
186
			if (addLink(console, link.getLink(), newLine, link.getRegion(), link.getMessage())) {
121
			if (addLink(console, newLine, descriptor)) {
187
				links.subList(0, index + 1).clear();
122
				launch.removeLinkDescriptor(descriptor);
188
				return;
123
				return;
189
			}
124
			}
190
		}
125
		}
191
	}
126
	}
192
	
193
	private static void addNewLine(IConsole console, IRegion newLine, IProcess process) {
194
		if (fgProcessToNewLines == null) {
195
			fgProcessToNewLines = new HashMap();
196
		}
197
		List newLines = (List)fgProcessToNewLines.get(process);
198
		if (newLines == null) {
199
			newLines= new ArrayList();
200
		}
201
	
202
		newLines.add(new LineEntry(console, newLine));
203
		fgProcessToNewLines.put(process, newLines);
204
	}
205
127
206
	/**
128
	/**
207
	 * Disposes any information stored for the given process.
129
	 * Disposes any information stored for the given process.
Lines 209-251 Link Here
209
	 * @param process
131
	 * @param process
210
	 */
132
	 */
211
	public static void dispose(IProcess process) {
133
	public static void dispose(IProcess process) {
212
		if (fgProcessToLinks != null) {
134
		AntLaunch launch = (AntLaunch) process.getLaunch();
213
			fgProcessToLinks.remove(process);
135
		launch.clearLinkDescriptors();
214
		}
215
		if (fgProcessToNewLines != null) {
216
			fgProcessToNewLines.remove(process);
217
		}
218
		if (fgAntBuilds != null) {
219
			fgAntBuilds.remove(process);
220
		}
221
	}
136
	}
222
	
137
223
	/**
224
	 * Registers the specified process as an Ant build process.
225
	 * Allows for the generation of the "Buildfile: somefile" link in the 
226
	 * Ant output.
227
	 * 
228
	 * @param process
229
	 */
230
	public static synchronized void registerAntBuild(IProcess process) {
231
		if (fgProcessToNewLines != null) {
232
			List newLines = (List)fgProcessToNewLines.get(process);
233
			if (newLines != null) {
234
				for (Iterator iter = newLines.iterator(); iter.hasNext();) {
235
					LineEntry newLine = (LineEntry) iter.next();
236
					if (linkBuildFileMessage(newLine.getConsole(), newLine.getRegion())){
237
						iter.remove();
238
						return;
239
					}
240
				}
241
			}
242
		}
243
		if (fgAntBuilds == null) {
244
			fgAntBuilds= new ArrayList();
245
		}
246
		fgAntBuilds.add(process);
247
	}
248
	
249
	private static boolean linkBuildFileMessage(IConsole console, IRegion region) {
138
	private static boolean linkBuildFileMessage(IConsole console, IRegion region) {
250
		
139
		
251
		String message= ""; //$NON-NLS-1$
140
		String message= ""; //$NON-NLS-1$
(-)Ant Tools Support/org/eclipse/ant/internal/ui/model/AntModelCore.java (-4 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-23 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.model;
11
package org.eclipse.ant.internal.ui.model;
12
12
13
import com.ibm.icu.text.MessageFormat;
14
import java.util.ArrayList;
13
import java.util.ArrayList;
15
import java.util.Iterator;
14
import java.util.Iterator;
16
import java.util.List;
15
import java.util.List;
17
16
17
import org.eclipse.ant.internal.launching.debug.model.AntLineBreakpoint;
18
import org.eclipse.ant.internal.launching.debug.model.DebugModelMessages;
18
import org.eclipse.ant.internal.ui.AntUIPlugin;
19
import org.eclipse.ant.internal.ui.AntUIPlugin;
19
import org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint;
20
import org.eclipse.ant.internal.ui.debug.model.DebugModelMessages;
21
import org.eclipse.core.resources.IMarker;
20
import org.eclipse.core.resources.IMarker;
22
import org.eclipse.core.resources.IMarkerDelta;
21
import org.eclipse.core.resources.IMarkerDelta;
23
import org.eclipse.core.resources.IWorkspaceRunnable;
22
import org.eclipse.core.resources.IWorkspaceRunnable;
Lines 28-33 Link Here
28
import org.eclipse.debug.core.IBreakpointsListener;
27
import org.eclipse.debug.core.IBreakpointsListener;
29
import org.eclipse.debug.core.model.IBreakpoint;
28
import org.eclipse.debug.core.model.IBreakpoint;
30
29
30
import com.ibm.icu.text.MessageFormat;
31
31
public class AntModelCore implements IBreakpointsListener {
32
public class AntModelCore implements IBreakpointsListener {
32
	
33
	
33
	private static AntModelCore inst;
34
	private static AntModelCore inst;
(-)Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntPreferencePage.java (-8 / +26 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.preferences;
11
package org.eclipse.ant.internal.ui.preferences;
12
12
13
13
import org.eclipse.ant.internal.launching.AntLaunching;
14
import com.ibm.icu.text.MessageFormat;
14
import org.eclipse.ant.internal.launching.IAntLaunchingPreferenceConstants;
15
16
import org.eclipse.ant.internal.ui.AntUIPlugin;
15
import org.eclipse.ant.internal.ui.AntUIPlugin;
17
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
16
import org.eclipse.ant.internal.ui.IAntUIHelpContextIds;
18
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
17
import org.eclipse.ant.internal.ui.IAntUIPreferenceConstants;
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
20
import org.eclipse.core.runtime.preferences.InstanceScope;
19
import org.eclipse.jface.preference.BooleanFieldEditor;
21
import org.eclipse.jface.preference.BooleanFieldEditor;
20
import org.eclipse.jface.preference.FieldEditorPreferencePage;
22
import org.eclipse.jface.preference.FieldEditorPreferencePage;
21
import org.eclipse.jface.preference.IPreferenceStore;
23
import org.eclipse.jface.preference.IPreferenceStore;
Lines 40-50 Link Here
40
import org.eclipse.ui.IWorkbenchPreferencePage;
42
import org.eclipse.ui.IWorkbenchPreferencePage;
41
import org.eclipse.ui.PlatformUI;
43
import org.eclipse.ui.PlatformUI;
42
44
45
import com.ibm.icu.text.MessageFormat;
46
43
public class AntPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
47
public class AntPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
44
	
48
	
45
	private List fConsoleColorList;
49
	private List fConsoleColorList;
46
	private ColorEditor fConsoleColorEditor;
50
	private ColorEditor fConsoleColorEditor;
47
	
51
	private IntegerFieldEditor timeout;
52
48
	private BooleanFieldEditor fToolsWarningEditor= null;
53
	private BooleanFieldEditor fToolsWarningEditor= null;
49
	
54
	
50
	// Array containing the message to display, the preference key, and the 
55
	// Array containing the message to display, the preference key, and the 
Lines 84-92 Link Here
84
		
89
		
85
		StringFieldEditor editor = new StringFieldEditor(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, AntPreferencesMessages.AntPreferencePage__Names__3, getFieldEditorParent());
90
		StringFieldEditor editor = new StringFieldEditor(IAntUIPreferenceConstants.ANT_FIND_BUILD_FILE_NAMES, AntPreferencesMessages.AntPreferencePage__Names__3, getFieldEditorParent());
86
		addField(editor);
91
		addField(editor);
87
		
92
88
		IntegerFieldEditor timeout = new IntegerFieldEditor(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, AntPreferencesMessages.AntPreferencePage_13, getFieldEditorParent());
93
		timeout = new IntegerFieldEditor(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, AntPreferencesMessages.AntPreferencePage_13, getFieldEditorParent());
89
        int minValue= AntUIPlugin.getDefault().getPreferenceStore().getDefaultInt(IAntUIPreferenceConstants.ANT_COMMUNICATION_TIMEOUT);
94
        int minValue= Platform.getPreferencesService().getInt(
95
				AntLaunching.getUniqueIdentifier(),
96
				IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
97
				20000, null);
90
        int maxValue = 1200000;
98
        int maxValue = 1200000;
91
        timeout.setValidRange(minValue, maxValue);
99
        timeout.setValidRange(minValue, maxValue);
92
        timeout.setErrorMessage(MessageFormat.format(AntPreferencesMessages.AntPreferencePage_14, new Object[] {new Integer(minValue), new Integer(maxValue)})); 
100
        timeout.setErrorMessage(MessageFormat.format(AntPreferencesMessages.AntPreferencePage_14, new Object[] {new Integer(minValue), new Integer(maxValue)})); 
Lines 147-152 Link Here
147
			String preference = fAppearanceColorListModel[i][1];
155
			String preference = fAppearanceColorListModel[i][1];
148
			fAppearanceColorListModel[i][2]= store.getString(preference);
156
			fAppearanceColorListModel[i][2]= store.getString(preference);
149
		}
157
		}
158
159
		IEclipsePreferences node = new InstanceScope()
160
				.getNode(AntLaunching.getUniqueIdentifier());
161
		String t = node.get(
162
				IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT,
163
				"2000"); //$NON-NLS-1$
164
		if (timeout != null) {
165
			t = new Integer(timeout.getIntValue()).toString();
166
		}
167
		node.put(IAntLaunchingPreferenceConstants.ANT_COMMUNICATION_TIMEOUT, t);
150
	}
168
	}
151
	
169
	
152
	private void createColorComposite() {
170
	private void createColorComposite() {
(-)Ant Tools Support/org/eclipse/ant/internal/ui/refactoring/LaunchConfigurationBuildfileChange.java (-4 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2008 IBM Corporation and others.
2
 * Copyright (c) 2003, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-21 Link Here
15
15
16
import org.eclipse.ant.core.AntCorePlugin;
16
import org.eclipse.ant.core.AntCorePlugin;
17
import org.eclipse.ant.internal.ui.AntUtil;
17
import org.eclipse.ant.internal.ui.AntUtil;
18
import org.eclipse.ant.ui.launching.IAntLaunchConfigurationConstants;
18
import org.eclipse.ant.launching.IAntLaunchConstants;
19
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
19
import org.eclipse.core.resources.IContainer;
20
import org.eclipse.core.resources.IContainer;
20
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.IProject;
Lines 39-45 Link Here
39
import org.eclipse.ltk.core.refactoring.Change;
40
import org.eclipse.ltk.core.refactoring.Change;
40
import org.eclipse.ltk.core.refactoring.CompositeChange;
41
import org.eclipse.ltk.core.refactoring.CompositeChange;
41
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
42
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
42
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
43
43
44
import com.ibm.icu.text.MessageFormat;
44
import com.ibm.icu.text.MessageFormat;
45
45
Lines 91-97 Link Here
91
    private static ILaunchConfiguration[] getAntLaunchConfigurations() throws CoreException {
91
    private static ILaunchConfiguration[] getAntLaunchConfigurations() throws CoreException {
92
        ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
92
        ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
93
        // Ant launch configurations
93
        // Ant launch configurations
94
        ILaunchConfigurationType configurationType= manager.getLaunchConfigurationType(IAntLaunchConfigurationConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
94
        ILaunchConfigurationType configurationType= manager.getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE);
95
        ILaunchConfiguration[] configs= manager.getLaunchConfigurations(configurationType);
95
        ILaunchConfiguration[] configs= manager.getLaunchConfigurations(configurationType);
96
        return configs;
96
        return configs;
97
    }
97
    }
(-)Ant Tools Support/org/eclipse/ant/ui/launching/IAntLaunchConfigurationConstants.java (-17 / +44 lines)
Lines 11-119 Link Here
11
11
12
package org.eclipse.ant.ui.launching;
12
package org.eclipse.ant.ui.launching;
13
13
14
import org.eclipse.ant.internal.ui.AntUIPlugin;
14
import org.eclipse.ant.launching.IAntLaunchConstants;
15
import org.eclipse.ant.internal.ui.IAntUIConstants;
16
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
17
15
18
/**
16
/**
19
 * Constant definitions for Ant launch configurations.
17
 * Constant definitions for Ant launch configurations.
20
 * 
18
 * 
21
 * @since 3.4
19
 * @since 3.4
22
 * @noimplement This interface is not intended to be implemented by clients.
20
 * @noimplement This interface is not intended to be implemented by clients.
21
 * @deprecated use {@link IAntLaunchConstants}
23
 */
22
 */
24
public interface IAntLaunchConfigurationConstants {
23
public interface IAntLaunchConfigurationConstants {
25
24
26
	/**
25
	/**
27
	 * Ant launch configuration type identifier.
26
	 * Ant launch configuration type identifier.
27
	 * 
28
	 * @deprecated use {@link IAntLaunchConstants#ID_ANT_LAUNCH_CONFIGURATION_TYPE}
28
	 */
29
	 */
29
	public static final String ID_ANT_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntLaunchConfigurationType"; //$NON-NLS-1$
30
	public static final String ID_ANT_LAUNCH_CONFIGURATION_TYPE = IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE;
30
31
31
	/**
32
	/**
32
	 * Ant builder launch configuration type identifier. Ant project builders
33
	 * Ant builder launch configuration type identifier. Ant project builders
33
	 * are of this type.
34
	 * are of this type.
35
	 * 
36
	 * @deprecated use {@link IAntLaunchConstants#ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE}
34
	 */
37
	 */
35
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$
38
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE;
36
	
39
	
37
	/**
40
	/**
38
	 * String attribute indicating the Ant targets to execute. Default value is
41
	 * String attribute indicating the Ant targets to execute. Default value is
39
	 * <code>null</code> which indicates that the default target is to be
42
	 * <code>null</code> which indicates that the default target is to be
40
	 * executed. Format is a comma separated listing of targets.
43
	 * executed. Format is a comma separated listing of targets.
44
	 * 
45
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_TARGETS}
41
	 */
46
	 */
42
	public static final String ATTR_ANT_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$
47
	public static final String ATTR_ANT_TARGETS = IAntLaunchConstants.ATTR_ANT_TARGETS;
43
	
48
	
44
	/**
49
	/**
45
	 * String attribute indicating the Ant targets to execute after a clean (full build) for an Ant builder. Default value is
50
	 * String attribute indicating the Ant targets to execute after a clean (full build) for an Ant builder. Default value is
46
	 * <code>null</code> which indicates that the default target is to be
51
	 * <code>null</code> which indicates that the default target is to be
47
	 * executed. Format is a comma separated listing of targets.
52
	 * executed. Format is a comma separated listing of targets.
53
	 * 
54
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_AFTER_CLEAN_TARGETS}
48
	 */
55
	 */
49
	public static final String ATTR_ANT_AFTER_CLEAN_TARGETS = IAntUIConstants.PLUGIN_ID + ".ATTR_ANT_AFTER_CLEAN_TARGETS"; //$NON-NLS-1$
56
	public static final String ATTR_ANT_AFTER_CLEAN_TARGETS = IAntLaunchConstants.ATTR_ANT_AFTER_CLEAN_TARGETS;
50
	
57
	
51
	/**
58
	/**
52
	 * String attribute indicating the Ant targets to execute during a manual build for an Ant builder. Default value is
59
	 * String attribute indicating the Ant targets to execute during a manual build for an Ant builder. Default value is
53
	 * <code>null</code> which indicates that the default target is to be
60
	 * <code>null</code> which indicates that the default target is to be
54
	 * executed. Format is a comma separated listing of targets.
61
	 * executed. Format is a comma separated listing of targets.
62
	 * 
63
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_MANUAL_TARGETS}
55
	 */
64
	 */
56
	public static final String ATTR_ANT_MANUAL_TARGETS = IAntUIConstants.PLUGIN_ID + ".ATTR_ANT_MANUAL_TARGETS"; //$NON-NLS-1$
65
	public static final String ATTR_ANT_MANUAL_TARGETS = IAntLaunchConstants.ATTR_ANT_MANUAL_TARGETS;
57
	
66
	
58
	/**
67
	/**
59
	 * String attribute indicating the Ant targets to execute during an auto build for an Ant builder. Default value is
68
	 * String attribute indicating the Ant targets to execute during an auto build for an Ant builder. Default value is
60
	 * <code>null</code> which indicates that the default target is to be
69
	 * <code>null</code> which indicates that the default target is to be
61
	 * executed. Format is a comma separated listing of targets.
70
	 * executed. Format is a comma separated listing of targets.
71
	 * 
72
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_AUTO_TARGETS}
62
	 */
73
	 */
63
	public static final String ATTR_ANT_AUTO_TARGETS = IAntUIConstants.PLUGIN_ID + ".ATTR_ANT_AUTO_TARGETS"; //$NON-NLS-1$
74
	public static final String ATTR_ANT_AUTO_TARGETS = IAntLaunchConstants.ATTR_ANT_AUTO_TARGETS;
64
	
75
	
65
	/**
76
	/**
66
	 * String attribute indicating the Ant targets to execute during a clean for an Ant builder. Default value is
77
	 * String attribute indicating the Ant targets to execute during a clean for an Ant builder. Default value is
67
	 * <code>null</code> which indicates that the default target is to be
78
	 * <code>null</code> which indicates that the default target is to be
68
	 * executed. Format is a comma separated listing of targets.
79
	 * executed. Format is a comma separated listing of targets.
80
	 * 
81
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_CLEAN_TARGETS}
69
	 */
82
	 */
70
	public static final String ATTR_ANT_CLEAN_TARGETS = IAntUIConstants.PLUGIN_ID + ".ATTR_ANT_CLEAN_TARGETS"; //$NON-NLS-1$
83
	public static final String ATTR_ANT_CLEAN_TARGETS = IAntLaunchConstants.ATTR_ANT_CLEAN_TARGETS;
71
	
84
	
72
	/**
85
	/**
73
	 * Boolean attribute indicating whether or not target specification for an Ant builder 
86
	 * Boolean attribute indicating whether or not target specification for an Ant builder 
74
	 * has been updated for 3.1 
87
	 * has been updated for 3.1 
88
	 * 
89
	 * @deprecated use {@link IAntLaunchConstants#ATTR_TARGETS_UPDATED}
75
	 */
90
	 */
76
	public static final String ATTR_TARGETS_UPDATED = IAntUIConstants.PLUGIN_ID + ".ATTR_TARGETS_UPDATED"; //$NON-NLS-1$
91
	public static final String ATTR_TARGETS_UPDATED = IAntLaunchConstants.ATTR_TARGETS_UPDATED;
77
	
92
	
78
	/**
93
	/**
79
	 * Map attribute indicating the Ant properties to be defined during the
94
	 * Map attribute indicating the Ant properties to be defined during the
80
	 * build. Default value is <code>null</code> which indicates no additional
95
	 * build. Default value is <code>null</code> which indicates no additional
81
	 * properties will be defined.
96
	 * properties will be defined.
97
	 * 
98
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_PROPERTIES}
82
	 */
99
	 */
83
	public static final String ATTR_ANT_PROPERTIES = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_PROPERTIES"; //$NON-NLS-1$					
100
	public static final String ATTR_ANT_PROPERTIES = IAntLaunchConstants.ATTR_ANT_PROPERTIES;					
84
	
101
	
85
	/**
102
	/**
86
	 * String attribute indicating the Ant targets to execute. Default value is
103
	 * String attribute indicating the Ant targets to execute. Default value is
87
	 * <code>null</code> which indicates that no additional property files
104
	 * <code>null</code> which indicates that no additional property files
88
	 * will be defined. Format is a comma separated listing of property files.
105
	 * will be defined. Format is a comma separated listing of property files.
106
	 * 
107
	 * @deprecated use {@link IAntLaunchConstants#ATTR_ANT_PROPERTY_FILES}
89
	 */
108
	 */
90
	public static final String ATTR_ANT_PROPERTY_FILES = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_PROPERTY_FILES"; //$NON-NLS-1$
109
	public static final String ATTR_ANT_PROPERTY_FILES = IAntLaunchConstants.ATTR_ANT_PROPERTY_FILES;
91
	
110
	
92
	/**
111
	/**
93
	 * Boolean attribute indicating whether or not internal targets (targets with no
112
	 * Boolean attribute indicating whether or not internal targets (targets with no
94
	 * description) should be hidden from the user in the launch configuration dialog.
113
	 * description) should be hidden from the user in the launch configuration dialog.
95
	 * Default value is <code>false</code> which indicates that all targets will be
114
	 * Default value is <code>false</code> which indicates that all targets will be
96
	 * displayed.
115
	 * displayed.
116
	 * 
117
	 * @deprecated use {@link IAntLaunchConstants#ATTR_HIDE_INTERNAL_TARGETS}
97
	 */
118
	 */
98
	public static final String ATTR_HIDE_INTERNAL_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_HIDE_INTERNAL_TARGETS"; //$NON-NLS-1$
119
	public static final String ATTR_HIDE_INTERNAL_TARGETS = IAntLaunchConstants.ATTR_HIDE_INTERNAL_TARGETS;
99
	
120
	
100
	/**
121
	/**
101
	 * Integer attribute indicating which column targets should be sorted on. A
122
	 * Integer attribute indicating which column targets should be sorted on. A
102
	 * value of 0 indicates target name, 1 indicates target description, and -1
123
	 * value of 0 indicates target name, 1 indicates target description, and -1
103
	 * indicates no sort. Default value is -1.
124
	 * indicates no sort. Default value is -1.
125
	 * 
126
	 * @deprecated use {@link IAntLaunchConstants#ATTR_SORT_TARGETS}
104
	 */
127
	 */
105
	public static final String ATTR_SORT_TARGETS = IExternalToolConstants.PLUGIN_ID + "ATTR_SORT_TARGETS"; //$NON-NLS-1$
128
	public static final String ATTR_SORT_TARGETS = IAntLaunchConstants.ATTR_SORT_TARGETS;
106
129
107
	/**
130
	/**
108
	 * Boolean attribute indicating if the default VM install should be used for the separate JRE build
131
	 * Boolean attribute indicating if the default VM install should be used for the separate JRE build
109
	 * Default value is <code>false</code> for backwards compatibility
132
	 * Default value is <code>false</code> for backwards compatibility
133
	 * 
134
	 * @deprecated use {@link IAntLaunchConstants#ATTR_DEFAULT_VM_INSTALL}
110
	 */
135
	 */
111
	public static final String ATTR_DEFAULT_VM_INSTALL = AntUIPlugin.PI_ANTUI + ".DEFAULT_VM_INSTALL"; //$NON-NLS-1$
136
	public static final String ATTR_DEFAULT_VM_INSTALL = IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL;
112
137
113
	/**
138
	/**
114
	 * Identifier for Ant processes (value <code>org.eclipse.ant.ui.antProcess</code>). This identifier is
139
	 * Identifier for Ant processes (value <code>org.eclipse.ant.ui.antProcess</code>). This identifier is
115
	 * set as the value for the <code>IProcess.ATTR_PROCESS_TYPE</code>
140
	 * set as the value for the <code>IProcess.ATTR_PROCESS_TYPE</code>
116
	 * attribute in processes created by the Ant launch delegate.
141
	 * attribute in processes created by the Ant launch delegate.
142
	 * 
143
	 * @deprecated use {@link IAntLaunchConstants#ID_ANT_PROCESS_TYPE}
117
	 */
144
	 */
118
	public static final String ID_ANT_PROCESS_TYPE = "org.eclipse.ant.ui.antProcess"; //$NON-NLS-1$
145
	public static final String ID_ANT_PROCESS_TYPE = IAntLaunchConstants.ID_ANT_PROCESS_TYPE;
119
}
146
}
(-)Common Ant Support/META-INF/eclipse.inf (-1 lines)
Removed Link Here
1
jarprocessor.exclude.sign=true
(-)Common Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/util/AntDebugState.java (-529 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.antsupport.logger.util;
13
14
import java.util.HashMap;
15
import java.util.Hashtable;
16
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Stack;
19
import java.util.Vector;
20
21
import org.apache.tools.ant.BuildEvent;
22
import org.apache.tools.ant.Location;
23
import org.apache.tools.ant.Project;
24
import org.apache.tools.ant.Target;
25
import org.apache.tools.ant.Task;
26
import org.apache.tools.ant.taskdefs.MacroInstance;
27
28
public class AntDebugState {
29
    
30
    private static final String fgAntTaskName= "ant"; //$NON-NLS-1$
31
    private static final String fgAntCallTaskName= "antcall"; //$NON-NLS-1$
32
    
33
	private IDebugBuildLogger fLogger;
34
	private Stack fTasks= new Stack();
35
	private Map fTaskToProxies= new HashMap();
36
	private Task fCurrentTask;
37
	private Task fStepOverTask;
38
	private Task fStepIntoTask;
39
	private Task fLastTaskFinished;
40
    
41
	//properties set before execution
42
    private Map fInitialProperties= null;
43
	private Map fProperties= null;
44
    
45
    private Map fProjectToTargetNames= null;
46
    private Map fProjectToMapOfTargetToBuildSequence= null;
47
    private Stack fTargetsToExecute= new Stack();
48
    private Stack fTargetsExecuting= new Stack();
49
	
50
	private boolean fConsiderTargetBreakpoints= false;
51
	private boolean fShouldSuspend;
52
	private boolean fClientSuspend= false;
53
	private boolean fStepIntoSuspend= false;
54
	private boolean fIsAfterTaskEvent= false;
55
	
56
	
57
	public AntDebugState(IDebugBuildLogger logger) {
58
		fLogger= logger;
59
	}
60
61
	public void waitIfSuspended() {
62
		fLogger.waitIfSuspended();
63
	}
64
65
	public Task getLastTaskFinished() {
66
		return fLastTaskFinished;
67
	}
68
69
	private void setLastTaskFinished(Task lastTaskFinished) {
70
		fLastTaskFinished= lastTaskFinished;
71
72
	}
73
74
	public Task getCurrentTask() {
75
		return fCurrentTask;
76
	}
77
78
	public void setCurrentTask(Task currentTask) {
79
		fCurrentTask= currentTask;
80
81
	}
82
83
	private Map getInitialProperties() {
84
		return fInitialProperties;
85
	}
86
87
	public Task getStepOverTask() {
88
		return fStepOverTask;
89
	}
90
91
	public void setStepOverTask(Task stepOverTask) {
92
		fStepOverTask= stepOverTask;
93
94
	}
95
96
	private boolean considerTargetBreakpoints() {
97
		return fConsiderTargetBreakpoints;
98
	}
99
100
	private void setConsiderTargetBreakpoints(boolean considerTargetBreakpoints) {
101
		fConsiderTargetBreakpoints= considerTargetBreakpoints;
102
	}
103
104
	private Stack getTasks() {
105
		return fTasks;
106
	}
107
	
108
	public void setShouldSuspend(boolean shouldSuspend) {
109
		fShouldSuspend= shouldSuspend;
110
	}
111
112
	public boolean shouldSuspend() {
113
		return fShouldSuspend;
114
	}
115
116
	private Map getTargetToBuildSequence(Project project) {
117
		return (Map) fProjectToMapOfTargetToBuildSequence.get(project);
118
	}
119
120
	public void setTargetToExecute(Target target) {
121
        if (target == null) {
122
            fTargetsToExecute.pop();
123
        } else {
124
            fTargetsToExecute.push(target);
125
        }
126
	}
127
128
	public void setTargetExecuting(Target target) {
129
        if (target == null) {
130
            fTargetsExecuting.pop();
131
        } else {
132
            fTargetsExecuting.push(target);
133
        }
134
	}
135
136
	private Target getTargetToExecute() {
137
	    if (fTargetsToExecute.isEmpty()) {
138
            return null;
139
        }
140
		return (Target) fTargetsToExecute.peek();
141
	}
142
	
143
	private Target getTargetExecuting() {
144
        if (fTargetsExecuting.isEmpty()) {
145
            return null;
146
        }
147
		return (Target) fTargetsExecuting.peek();
148
	}
149
150
	public boolean isStepIntoSuspend() {
151
		return isAfterTaskEvent() && fStepIntoSuspend;
152
	}
153
154
	public void setStepIntoSuspend(boolean stepIntoSuspend) {
155
		fStepIntoSuspend = stepIntoSuspend;
156
	}
157
158
	public boolean isClientSuspend() {
159
		return fClientSuspend;
160
	}
161
162
	public void setClientSuspend(boolean clientSuspend) {
163
		fClientSuspend = clientSuspend;
164
	}
165
166
	public Task getStepIntoTask() {
167
		return fStepIntoTask;
168
	}
169
170
	public void setStepIntoTask(Task stepIntoTask) {
171
		fStepIntoTask = stepIntoTask;
172
	}
173
	
174
	public void resume() {
175
		fLogger.notifyAll();
176
	}
177
178
	public Map getProperties() {
179
		return fProperties;
180
	}
181
	
182
	public Location getBreakpointLocation() {
183
		if (isAfterTaskEvent() && getCurrentTask() != null) {
184
			return getCurrentTask().getLocation();
185
		}
186
		if (considerTargetBreakpoints()) {
187
	        Target targetExecuting= getTargetExecuting();
188
	        if (targetExecuting != null) {
189
                return getLocation(targetExecuting);      
190
            }
191
		}
192
		return null;
193
	}
194
195
	private boolean isAfterTaskEvent() {
196
		return fIsAfterTaskEvent;
197
	}
198
199
	private void setAfterTaskEvent(boolean isAfterTaskEvent) {
200
		fIsAfterTaskEvent = isAfterTaskEvent;
201
	}
202
	
203
	public void taskStarted(BuildEvent event) {
204
		setAfterTaskEvent(true);
205
		if (getInitialProperties() == null) {//implicit or top level target does not fire targetStarted()
206
			fInitialProperties= event.getProject().getProperties();
207
		}
208
		
209
		setCurrentTask(event.getTask());
210
		setConsiderTargetBreakpoints(false);
211
		if (!getTasks().isEmpty()) {
212
			//cache the parent task proxy as when that task is started or finished the
213
			//proxy is not yet available or is nulled out
214
			Task parentTask = (Task) getTasks().peek();
215
			Object proxy = parentTask.getRuntimeConfigurableWrapper().getProxy();
216
			if (proxy != null) {
217
				fTaskToProxies.put(parentTask, proxy);
218
			}
219
		}
220
		getTasks().push(getCurrentTask());
221
		waitIfSuspended();
222
	}
223
	
224
225
    public void taskFinished() {
226
    	Task lastTask= (Task)getTasks().pop();
227
        setLastTaskFinished(lastTask);
228
        setCurrentTask(null);
229
        String taskName= lastTask.getTaskName();
230
       
231
        if (getStepOverTask() != null) {
232
        	if ((fgAntCallTaskName.equals(taskName) || fgAntTaskName.equals(taskName)) && (!fgAntCallTaskName.equals(getStepOverTask().getTaskName()) && !fgAntTaskName.equals(getStepOverTask().getTaskName()))) {
233
        		setShouldSuspend(true);
234
        	} else if (fTaskToProxies.remove(lastTask) instanceof MacroInstance) {
235
        		setShouldSuspend(true);
236
        	}
237
        }
238
        waitIfSuspended();
239
    }
240
241
    public void stepOver() {
242
       setStepOverTask(getCurrentTask());
243
        if (getCurrentTask() == null) {
244
            //stepping over target breakpoint
245
           setShouldSuspend(true);
246
        }
247
        resume();
248
    }
249
250
    public void targetStarted(BuildEvent event) {
251
		setAfterTaskEvent(false);
252
        Project eventProject = event.getProject();
253
        if (getInitialProperties() == null) {
254
            fInitialProperties= eventProject.getProperties();
255
        }
256
        if (fProjectToTargetNames.get(eventProject) == null) {
257
            Object ref= eventProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
258
            if (ref != null) {
259
                fProjectToTargetNames.put(eventProject, ref);
260
                Map targetToBuildSequence= new HashMap();
261
                setTargetToExecute(initializeBuildSequenceInformation(event, targetToBuildSequence));
262
                fProjectToMapOfTargetToBuildSequence.put(eventProject, targetToBuildSequence);
263
            }
264
        }
265
        
266
        setTargetExecuting(event.getTarget());
267
        if (event.getTarget().equals(getTargetToExecute())) {
268
            //the dependencies of the target to execute have been met
269
            //prepare for the next target
270
            Vector targets= (Vector) fProjectToTargetNames.get(eventProject);
271
            if (!targets.isEmpty()) {
272
                setTargetToExecute((Target) eventProject.getTargets().get(targets.remove(0)));
273
            } else {
274
                setTargetToExecute(null);
275
            }
276
        }
277
        setConsiderTargetBreakpoints(true);
278
    }
279
280
	public int getLineNumber(Location location) {
281
	    try { //succeeds with Ant newer than 1.6
282
	        return location.getLineNumber();
283
	    } catch (NoSuchMethodError e) {
284
	        //Ant before 1.6
285
	        String locationString= location.toString();
286
	        if (locationString.length() == 0) {
287
	            return 0;
288
	        }
289
	        //filename: lineNumber: ("c:\buildfile.xml: 12: ")
290
	        int lastIndex= locationString.lastIndexOf(':');
291
	        int index =locationString.lastIndexOf(':', lastIndex - 1);
292
	        if (index != -1) {
293
	            try {
294
	                return Integer.parseInt(locationString.substring(index+1, lastIndex));
295
	            } catch (NumberFormatException nfe) {
296
	                return 0;
297
	            }
298
	        }
299
	        return 0;
300
	    }
301
	}
302
303
	public static Location getLocation(Target target) {
304
	    try {//succeeds with Ant newer than 1.6.2
305
	        return target.getLocation();
306
	    } catch (NoSuchMethodError e) {
307
	        return Location.UNKNOWN_LOCATION;
308
	    }
309
	}
310
311
	public String getFileName(Location location) {
312
	    try {//succeeds with Ant newer than 1.6
313
	        return location.getFileName();
314
	    } catch (NoSuchMethodError e) {
315
	        //Ant before 1.6
316
	        String locationString= location.toString();
317
	        if (locationString.length() == 0) {
318
	            return null;
319
	        }
320
	        //filename: lineNumber: ("c:\buildfile.xml: 12: ")          
321
	        int lastIndex= locationString.lastIndexOf(':');
322
	        int index =locationString.lastIndexOf(':', lastIndex-1);
323
	        if (index == -1) {
324
	            index= lastIndex; //only the filename is known
325
	        }
326
	        if (index != -1) {
327
	        //bug 84403
328
	            //if (locationString.startsWith("file:")) {
329
	              //  return FileUtils.newFileUtils().fromURI(locationString);
330
	            //}
331
	            //remove file:
332
	            return locationString.substring(5, index);
333
	        }
334
	        return null;
335
	    }
336
	}
337
338
	private void appendToStack(StringBuffer stackRepresentation, String targetName, String taskName, Location location) {
339
	    stackRepresentation.append(targetName);
340
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
341
	    stackRepresentation.append(taskName);
342
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
343
	    
344
	    stackRepresentation.append(getFileName(location));
345
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
346
	    stackRepresentation.append(getLineNumber(location));
347
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
348
	}
349
350
	public void marshalStack(StringBuffer stackRepresentation) {
351
		Stack tasks= getTasks();
352
		
353
	    stackRepresentation.append(DebugMessageIds.STACK);
354
	    stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
355
	    
356
		Target targetToExecute= getTargetToExecute();
357
		Target targetExecuting= getTargetExecuting();
358
      
359
        Project projectExecuting= null;
360
        if (targetExecuting != null) {
361
            projectExecuting= targetExecuting.getProject();
362
        } else { //no target...must be a task
363
            Task task= (Task) tasks.peek();
364
            projectExecuting= task.getProject();
365
        }
366
        
367
		if (!isAfterTaskEvent()) {
368
			appendToStack(stackRepresentation, targetExecuting.getName(), "", getLocation(targetExecuting)); //$NON-NLS-1$
369
		}
370
		for (int i = tasks.size() - 1; i >= 0 ; i--) {
371
			Task task= (Task) tasks.get(i);
372
            if (task.getProject() == projectExecuting) {
373
                appendToStack(stackRepresentation, task.getOwningTarget().getName(), task.getTaskName(), task.getLocation());
374
            } else {
375
                //sub build target dependencies
376
                String targetName= task.getOwningTarget().getName();
377
                if (targetName != null && targetName.length() != 0) { //skip for implicit target
378
                    Iterator itr= fTargetsToExecute.iterator();
379
                    while (itr.hasNext()) {
380
                        Target target= (Target) itr.next();
381
                        if (target.getProject() != projectExecuting) {
382
                        	targetToExecute= target;
383
                            continue;
384
                        }
385
                        marshalTargetDependancyStack(stackRepresentation, target, targetExecuting);
386
                    }
387
                }
388
                projectExecuting= task.getProject();
389
                targetExecuting= task.getOwningTarget();
390
                appendToStack(stackRepresentation, targetExecuting.getName(), task.getTaskName(), task.getLocation());
391
            }
392
		}
393
394
		//target dependency stack 
395
		marshalTargetDependancyStack(stackRepresentation, targetToExecute, targetExecuting);
396
	}
397
398
    private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Target targetToExecute, Target targetExecuting) {
399
        if (targetToExecute != null) {
400
	     	Vector buildSequence= (Vector) getTargetToBuildSequence(targetToExecute.getProject()).get(targetToExecute);
401
	     	int startIndex= buildSequence.indexOf(targetExecuting) + 1;
402
	     	int dependancyStackDepth= buildSequence.indexOf(targetToExecute);
403
	     	
404
	     	Target stackTarget;
405
	     	for (int i = startIndex; i <= dependancyStackDepth; i++) {
406
	     		stackTarget= (Target) buildSequence.get(i);
407
	            if (stackTarget.dependsOn(targetExecuting.getName())) {
408
	     		    appendToStack(stackRepresentation, stackTarget.getName(), "", getLocation(stackTarget)); //$NON-NLS-1$
409
	            }
410
	     	}
411
	     }
412
    }
413
414
	public void marshallProperties(StringBuffer propertiesRepresentation, boolean escapeLineSep) {
415
		if (getTasks().isEmpty()) {
416
			return;
417
		}
418
	    propertiesRepresentation.append(DebugMessageIds.PROPERTIES);
419
	    propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
420
		
421
		Project project= ((Task)getTasks().peek()).getProject();
422
		Map lastProperties= getProperties(); 
423
		
424
	    Map currentProperties= project.getProperties();
425
	    if (lastProperties != null && currentProperties.size() == lastProperties.size()) {
426
	        //no new properties
427
	        return;
428
	    }
429
	    
430
		Map initialProperties= getInitialProperties();
431
	    Map currentUserProperties= project.getUserProperties();
432
	    Iterator iter= currentProperties.keySet().iterator();
433
	    String propertyName;
434
		String originalPropertyName;
435
	    String propertyValue;
436
	    while (iter.hasNext()) {
437
	        propertyName = (String) iter.next();
438
			originalPropertyName= propertyName;
439
	        if (lastProperties == null || lastProperties.get(propertyName) == null) { //new property
440
				if (escapeLineSep) {
441
					propertyName= escapeLineSeparator(propertyName);
442
				}
443
	            propertiesRepresentation.append(propertyName.length());
444
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
445
	            propertiesRepresentation.append(propertyName);
446
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
447
	            propertyValue= (String) currentProperties.get(originalPropertyName);
448
				if (escapeLineSep) {
449
					propertyValue= escapeLineSeparator(propertyValue);
450
				}
451
	            propertiesRepresentation.append(propertyValue.length());
452
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
453
				propertiesRepresentation.append(propertyValue);
454
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
455
	            propertiesRepresentation.append(getPropertyType(initialProperties, currentUserProperties, originalPropertyName));
456
	            propertiesRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
457
	        }
458
	    }
459
	    
460
	    propertiesRepresentation.deleteCharAt(propertiesRepresentation.length() - 1);
461
		fProperties= currentProperties;
462
	}
463
464
	private int getPropertyType(Map initialProperties, Map currentUserProperties, String propertyName) {
465
		if (initialProperties.get(propertyName) != null) { //properties set before the start of the build
466
		    if (currentUserProperties.get(propertyName) == null) {
467
		        return DebugMessageIds.PROPERTY_SYSTEM;
468
		    } 
469
			return DebugMessageIds.PROPERTY_USER;
470
		} else if (currentUserProperties.get(propertyName) == null){
471
		    return DebugMessageIds.PROPERTY_RUNTIME;
472
		} else {
473
		    return DebugMessageIds.PROPERTY_USER;
474
		}
475
	}
476
477
	private String escapeLineSeparator(String stringToEscape) {
478
		if (!(stringToEscape.indexOf('\r') != -1 || stringToEscape.indexOf('\n') != -1 || stringToEscape.indexOf("\\r") != -1 || stringToEscape.indexOf("\\n") != -1)) { //$NON-NLS-1$ //$NON-NLS-2$
479
			return stringToEscape;
480
		}
481
		StringBuffer escapedValue= new StringBuffer(stringToEscape);		
482
		for (int i= 0; i < escapedValue.length(); i++) {
483
			switch (escapedValue.charAt(i)) {
484
			case '\r':
485
				escapedValue.replace(i, i+1, "\\r"); //$NON-NLS-1$
486
				i++;
487
				break;
488
			case '\n':
489
				escapedValue.replace(i, i+1, "\\n"); //$NON-NLS-1$
490
				i++;
491
				break;
492
			case '\\':
493
				if (escapedValue.charAt(i + 1) == 'r' || escapedValue.charAt(i + 1) == 'n') {
494
					escapedValue.replace(i, i+1, "\\\\"); //$NON-NLS-1$
495
					i++;
496
				}
497
				break;
498
			default:
499
				break;
500
			}
501
		}
502
503
		return escapedValue.toString();
504
	}
505
506
	private Target initializeBuildSequenceInformation(BuildEvent event, Map targetToBuildSequence) {
507
	    Project antProject= event.getProject();
508
	    Vector targets= (Vector) antProject.getReference("eclipse.ant.targetVector"); //$NON-NLS-1$
509
        if (targets == null) {
510
            return null;
511
        }
512
	    Iterator itr= targets.iterator();
513
	    Hashtable allTargets= antProject.getTargets();
514
	    String targetName;
515
	    Vector sortedTargets;
516
	    while (itr.hasNext()) {
517
	        targetName= (String) itr.next();
518
	        sortedTargets= antProject.topoSort(targetName, allTargets);
519
	        targetToBuildSequence.put(allTargets.get(targetName), sortedTargets);
520
	    }
521
	    //the target to execute
522
	    return (Target) allTargets.get(targets.remove(0));
523
	}
524
    
525
    public void buildStarted() {
526
        fProjectToTargetNames= new HashMap();
527
        fProjectToMapOfTargetToBuildSequence= new HashMap();
528
    }
529
}
(-)Common Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/util/DebugMessageIds.java (-47 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger.util;
12
13
14
public class DebugMessageIds {
15
	
16
	public final static String MESSAGE_DELIMITER= ","; //$NON-NLS-1$
17
	
18
	public final static String BUILD_STARTED=   "build_started"; //$NON-NLS-1$
19
	public final static String TARGET_STARTED= "target_started"; //$NON-NLS-1$
20
	public final static String TARGET_FINISHED= "target_finished"; //$NON-NLS-1$
21
	public final static String TASK_STARTED= "task_started"; //$NON-NLS-1$
22
	public final static String TASK_FINISHED= "task_finished"; //$NON-NLS-1$
23
	
24
	public final static String STEP= "step"; //$NON-NLS-1$
25
	public final static String STEP_OVER= "step_over"; //$NON-NLS-1$
26
	public final static String STEP_INTO= "step_into"; //$NON-NLS-1$
27
	
28
	public final static String TERMINATE= "terminate"; //$NON-NLS-1$
29
	public final static String TERMINATED= "terminated"; //$NON-NLS-1$
30
	public final static String SUSPEND= "suspend"; //$NON-NLS-1$
31
	public final static String SUSPENDED= "suspended"; //$NON-NLS-1$
32
	public final static String RESUME= "resume"; //$NON-NLS-1$
33
	
34
	public final static String STACK= "stack"; //$NON-NLS-1$
35
	
36
	public final static String ADD_BREAKPOINT= "add"; //$NON-NLS-1$
37
	public final static String REMOVE_BREAKPOINT= "remove"; //$NON-NLS-1$
38
	
39
	public final static String CLIENT_REQUEST= "client"; //$NON-NLS-1$
40
	public final static String BREAKPOINT= "breakpoint"; //$NON-NLS-1$
41
	
42
	public final static String PROPERTIES= "prop"; //$NON-NLS-1$
43
	public final static String PROPERTY_VALUE= "value"; //$NON-NLS-1$
44
	public final static int PROPERTY_USER= 0;
45
	public final static int PROPERTY_SYSTEM= 1;
46
	public final static int PROPERTY_RUNTIME= 2;
47
}
(-)Common Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/util/IDebugBuildLogger.java (-21 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger.util;
12
13
14
public interface IDebugBuildLogger {
15
16
	/**
17
	 * Requests to suspend the build if the current debug state
18
	 * indicates that suspension is required.
19
	 */
20
    public abstract void waitIfSuspended();
21
}
(-)META-INF/MANIFEST.MF (-3 / +4 lines)
Lines 2-15 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.ant.ui; singleton:=true
4
Bundle-SymbolicName: org.eclipse.ant.ui; singleton:=true
5
Bundle-Version: 3.4.0.qualifier
5
Bundle-Version: 3.5.0.qualifier
6
Bundle-Activator: org.eclipse.ant.internal.ui.AntUIPlugin
6
Bundle-Activator: org.eclipse.ant.internal.ui.AntUIPlugin
7
Bundle-Vendor: %providerName
7
Bundle-Vendor: %providerName
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Export-Package: org.eclipse.ant.internal.ui;x-internal:=true,
9
Export-Package: org.eclipse.ant.internal.ui;x-internal:=true,
10
 org.eclipse.ant.internal.ui.console;x-internal:=true,
10
 org.eclipse.ant.internal.ui.console;x-internal:=true,
11
 org.eclipse.ant.internal.ui.datatransfer;x-internal:=true,
11
 org.eclipse.ant.internal.ui.datatransfer;x-internal:=true,
12
 org.eclipse.ant.internal.ui.debug;x-internal:=true,
13
 org.eclipse.ant.internal.ui.debug.model;x-internal:=true,
12
 org.eclipse.ant.internal.ui.debug.model;x-internal:=true,
14
 org.eclipse.ant.internal.ui.dtd;x-internal:=true,
13
 org.eclipse.ant.internal.ui.dtd;x-internal:=true,
15
 org.eclipse.ant.internal.ui.dtd.schema;x-internal:=true,
14
 org.eclipse.ant.internal.ui.dtd.schema;x-internal:=true,
Lines 51-57 Link Here
51
 org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)",
50
 org.eclipse.team.core;bundle-version="[3.2.0,4.0.0)",
52
 org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)",
51
 org.eclipse.ltk.core.refactoring;bundle-version="[3.2.0,4.0.0)",
53
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
52
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
54
 org.eclipse.jdt.junit;bundle-version="[3.5.0,4.0.0)"
53
 org.eclipse.jdt.junit;bundle-version="[3.5.0,4.0.0)",
54
 org.eclipse.ant.launching;bundle-version="1.0.0",
55
 org.eclipse.core.externaltools;bundle-version="1.0.0"
55
Bundle-ActivationPolicy: lazy
56
Bundle-ActivationPolicy: lazy
56
Import-Package: com.ibm.icu.text
57
Import-Package: com.ibm.icu.text
57
Bundle-RequiredExecutionEnvironment: J2SE-1.4
58
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/AntSecurityException.java (-23 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
/**
14
 * A security exception that is thrown by the AntSecurityManager if
15
 * an Ant task in some way attempts to halt or exit the Java Virtual Machine.
16
 * 
17
 * @since 2.1
18
 */
19
public class AntSecurityException extends SecurityException {
20
21
	private static final long serialVersionUID = 1L;
22
23
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/AntSecurityManager.java (-371 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
14
import java.io.FileDescriptor;
15
import java.net.InetAddress;
16
import java.net.SocketPermission;
17
import java.security.Permission;
18
import java.util.PropertyPermission;
19
20
/**
21
 * A security manager that always throws an <code>AntSecurityException</code>
22
 * if the calling thread attempts to cause the Java Virtual Machine to 
23
 * exit/halt or if the restricted thread attempts to set a System property.
24
 * Otherwise this manager just delegates to the pre-existing manager
25
 * passed in the constructor or mimics the default security manager behavior
26
 */
27
public class AntSecurityManager extends SecurityManager {
28
29
	private SecurityManager fSecurityManager= null;
30
	private Thread fRestrictedThread= null;
31
	//ensure that the PropertyPermission class is loaded before we 
32
	//start checking permissions: bug 85908
33
	private static final PropertyPermission fgPropertyPermission= new PropertyPermission("*", "write"); //$NON-NLS-1$ //$NON-NLS-2$
34
	
35
	private boolean fAllowSettingSystemProperties= true;
36
	
37
	public AntSecurityManager(SecurityManager securityManager, Thread restrictedThread, boolean allowSettingProperties) {
38
		fSecurityManager= securityManager;
39
		fRestrictedThread= restrictedThread;
40
		fAllowSettingSystemProperties= allowSettingProperties;
41
	}
42
	
43
	public AntSecurityManager(SecurityManager securityManager, Thread restrictedThread) {
44
		this(securityManager, restrictedThread, true);
45
	}
46
	
47
	/* (non-Javadoc)
48
	 * @see java.lang.SecurityManager#checkExit(int)
49
	 */
50
	public void checkExit(int status) {
51
		//no exit allowed from the restricted thread...System.exit is being called
52
		//by some ant task...disallow the exit
53
		if (Thread.currentThread() == fRestrictedThread) {
54
			throw new AntSecurityException();
55
		}
56
		if (fSecurityManager != null) {
57
			fSecurityManager.checkExit(status);
58
		}
59
	}
60
	/* (non-Javadoc)
61
	 * @see java.lang.SecurityManager#checkAccept(java.lang.String, int)
62
	 */
63
	public void checkAccept(String host, int port) {
64
		if (fSecurityManager != null) {
65
			fSecurityManager.checkAccept(host, port);
66
		}
67
	}
68
69
	/* (non-Javadoc)
70
	 * @see java.lang.SecurityManager#checkAccess(java.lang.Thread)
71
	 */
72
	public void checkAccess(Thread t) {
73
		if (fSecurityManager != null) {
74
			fSecurityManager.checkAccess(t);
75
		}
76
	}
77
78
	/* (non-Javadoc)
79
	 * @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup)
80
	 */
81
	public void checkAccess(ThreadGroup g) {
82
		if (fSecurityManager != null) {
83
			fSecurityManager.checkAccess(g);
84
		}
85
	}
86
87
	/* (non-Javadoc)
88
	 * @see java.lang.SecurityManager#checkAwtEventQueueAccess()
89
	 */
90
	public void checkAwtEventQueueAccess() {
91
		if (fSecurityManager != null) {
92
			fSecurityManager.checkAwtEventQueueAccess();
93
		}
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see java.lang.SecurityManager#checkConnect(java.lang.String, int, java.lang.Object)
98
	 */
99
	public void checkConnect(String host, int port, Object context) {
100
		if (fSecurityManager != null) {
101
			fSecurityManager.checkConnect(host, port, context);
102
		}
103
	}
104
105
	/* (non-Javadoc)
106
	 * @see java.lang.SecurityManager#checkConnect(java.lang.String, int)
107
	 */
108
	public void checkConnect(String host, int port) {
109
		if (fSecurityManager != null) {
110
			fSecurityManager.checkConnect(host, port);
111
		}
112
	}
113
114
	/* (non-Javadoc)
115
	 * @see java.lang.SecurityManager#checkCreateClassLoader()
116
	 */
117
	public void checkCreateClassLoader() {
118
		if (fSecurityManager != null) {
119
			fSecurityManager.checkCreateClassLoader();
120
		}
121
	}
122
123
	/* (non-Javadoc)
124
	 * @see java.lang.SecurityManager#checkDelete(java.lang.String)
125
	 */
126
	public void checkDelete(String file) {
127
		if (fSecurityManager != null) {
128
			fSecurityManager.checkDelete(file);
129
		}
130
	}
131
132
	/* (non-Javadoc)
133
	 * @see java.lang.SecurityManager#checkExec(java.lang.String)
134
	 */
135
	public void checkExec(String cmd) {
136
		if (fSecurityManager != null) {
137
			fSecurityManager.checkExec(cmd);
138
		}
139
	}
140
141
	/* (non-Javadoc)
142
	 * @see java.lang.SecurityManager#checkLink(java.lang.String)
143
	 */
144
	public void checkLink(String lib) {
145
		if (fSecurityManager != null) {
146
			fSecurityManager.checkLink(lib);
147
		}
148
	}
149
150
	/* (non-Javadoc)
151
	 * @see java.lang.SecurityManager#checkListen(int)
152
	 */
153
	public void checkListen(int port) {
154
		if (fSecurityManager != null) {
155
			fSecurityManager.checkListen(port);
156
		}
157
	}
158
159
	/* (non-Javadoc)
160
	 * @see java.lang.SecurityManager#checkMemberAccess(java.lang.Class, int)
161
	 */
162
	public void checkMemberAccess(Class clazz, int which) {
163
		if (fSecurityManager != null) {
164
			fSecurityManager.checkMemberAccess(clazz, which);
165
		}
166
	}
167
168
	/**
169
	 * @see java.lang.SecurityManager#checkMulticast(java.net.InetAddress, byte)
170
	 * @deprecated
171
	 */
172
	public void checkMulticast(InetAddress maddr, byte ttl) {
173
		if (fSecurityManager != null) {
174
			String host = maddr.getHostAddress();
175
			if (!host.startsWith("[") && host.indexOf(':') != -1) { //$NON-NLS-1$
176
	   			host = "[" + host + "]"; //$NON-NLS-1$ //$NON-NLS-2$
177
			}
178
	    	checkPermission(new SocketPermission(host, "accept,connect")); //$NON-NLS-1$
179
		}
180
	}
181
182
	/* (non-Javadoc)
183
	 * @see java.lang.SecurityManager#checkMulticast(java.net.InetAddress)
184
	 */
185
	public void checkMulticast(InetAddress maddr) {
186
		if (fSecurityManager != null) {
187
			fSecurityManager.checkMulticast(maddr);
188
		}
189
	}
190
191
	/* (non-Javadoc)
192
	 * @see java.lang.SecurityManager#checkPackageAccess(java.lang.String)
193
	 */
194
	public void checkPackageAccess(String pkg) {
195
		if (fSecurityManager != null) {
196
			fSecurityManager.checkPackageAccess(pkg);
197
		}
198
	}
199
200
	/* (non-Javadoc)
201
	 * @see java.lang.SecurityManager#checkPackageDefinition(java.lang.String)
202
	 */
203
	public void checkPackageDefinition(String pkg) {
204
		if (fSecurityManager != null) {
205
			fSecurityManager.checkPackageDefinition(pkg);
206
		}
207
	}
208
209
	/* (non-Javadoc)
210
	 * @see java.lang.SecurityManager#checkPermission(java.security.Permission, java.lang.Object)
211
	 */
212
	public void checkPermission(Permission perm, Object context) {
213
		if (fSecurityManager != null) {
214
			fSecurityManager.checkPermission(perm, context);
215
		}
216
	}
217
218
	/* (non-Javadoc)
219
	 * @see java.lang.SecurityManager#checkPermission(java.security.Permission)
220
	 */
221
	public void checkPermission(Permission perm) {
222
		if (!fAllowSettingSystemProperties && fgPropertyPermission.implies(perm) && fRestrictedThread == Thread.currentThread()) {
223
			//attempting to write a system property
224
			throw new AntSecurityException();
225
		}
226
		if (fSecurityManager != null) {
227
			fSecurityManager.checkPermission(perm);
228
		}
229
	}
230
231
	/* (non-Javadoc)
232
	 * @see java.lang.SecurityManager#checkPrintJobAccess()
233
	 */
234
	public void checkPrintJobAccess() {
235
		if (fSecurityManager != null) {
236
			fSecurityManager.checkPrintJobAccess();
237
		}
238
	}
239
240
	/* (non-Javadoc)
241
	 * @see java.lang.SecurityManager#checkPropertiesAccess()
242
	 */
243
	public void checkPropertiesAccess() {
244
		if (fSecurityManager != null) {
245
			fSecurityManager.checkPropertiesAccess();
246
		}
247
		super.checkPropertiesAccess();
248
	}
249
250
	/* (non-Javadoc)
251
	 * @see java.lang.SecurityManager#checkPropertyAccess(java.lang.String)
252
	 */
253
	public void checkPropertyAccess(String key) {
254
		if (fSecurityManager != null) {
255
			fSecurityManager.checkPropertyAccess(key);
256
		}
257
	}
258
259
	/* (non-Javadoc)
260
	 * @see java.lang.SecurityManager#checkRead(java.io.FileDescriptor)
261
	 */
262
	public void checkRead(FileDescriptor fd) {
263
		if (fSecurityManager != null) {
264
			fSecurityManager.checkRead(fd);
265
		}
266
	}
267
268
	/* (non-Javadoc)
269
	 * @see java.lang.SecurityManager#checkRead(java.lang.String, java.lang.Object)
270
	 */
271
	public void checkRead(String file, Object context) {
272
		if (fSecurityManager != null) {
273
			fSecurityManager.checkRead(file, context);
274
		}
275
	}
276
277
	/* (non-Javadoc)
278
	 * @see java.lang.SecurityManager#checkRead(java.lang.String)
279
	 */
280
	public void checkRead(String file) {
281
		if (fSecurityManager != null) {
282
			fSecurityManager.checkRead(file);
283
		}
284
	}
285
286
	/* (non-Javadoc)
287
	 * @see java.lang.SecurityManager#checkSecurityAccess(java.lang.String)
288
	 */
289
	public void checkSecurityAccess(String target) {
290
		if (fSecurityManager != null) {
291
			fSecurityManager.checkSecurityAccess(target);
292
		}
293
	}
294
295
	/* (non-Javadoc)
296
	 * @see java.lang.SecurityManager#checkSetFactory()
297
	 */
298
	public void checkSetFactory() {
299
		if (fSecurityManager != null) {
300
			fSecurityManager.checkSetFactory();
301
		}
302
	}
303
304
	/* (non-Javadoc)
305
	 * @see java.lang.SecurityManager#checkSystemClipboardAccess()
306
	 */
307
	public void checkSystemClipboardAccess() {
308
		if (fSecurityManager != null) {
309
			fSecurityManager.checkSystemClipboardAccess();
310
		}
311
	}
312
313
	/* (non-Javadoc)
314
	 * @see java.lang.SecurityManager#checkTopLevelWindow(java.lang.Object)
315
	 */
316
	public boolean checkTopLevelWindow(Object window) {
317
		if (fSecurityManager != null) {
318
			return fSecurityManager.checkTopLevelWindow(window);
319
		}
320
		return super.checkTopLevelWindow(window);
321
	}
322
323
	/* (non-Javadoc)
324
	 * @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
325
	 */
326
	public void checkWrite(FileDescriptor fd) {
327
		if (fSecurityManager != null) {
328
			fSecurityManager.checkWrite(fd);
329
		}
330
	}
331
332
	/* (non-Javadoc)
333
	 * @see java.lang.SecurityManager#checkWrite(java.lang.String)
334
	 */
335
	public void checkWrite(String file) {
336
		if (fSecurityManager != null) {
337
			fSecurityManager.checkWrite(file);
338
		}
339
	}
340
341
	/**
342
	 * @see java.lang.SecurityManager#getInCheck()
343
	 * @deprecated
344
	 */
345
	public boolean getInCheck() {
346
		if (fSecurityManager != null) {
347
			return fSecurityManager.getInCheck();
348
		}
349
		return super.getInCheck();
350
	}
351
352
	/* (non-Javadoc)
353
	 * @see java.lang.SecurityManager#getSecurityContext()
354
	 */
355
	public Object getSecurityContext() {
356
		if (fSecurityManager != null) {
357
			return fSecurityManager.getSecurityContext();
358
		}
359
		return super.getSecurityContext();
360
	}
361
362
	/* (non-Javadoc)
363
	 * @see java.lang.SecurityManager#getThreadGroup()
364
	 */
365
	public ThreadGroup getThreadGroup() {
366
		if (fSecurityManager != null) {
367
			fSecurityManager.getThreadGroup();
368
		}
369
		return super.getThreadGroup();
370
	}
371
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/DemuxInputStreamSetter.java (-26 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
14
import org.apache.tools.ant.DemuxInputStream;
15
import org.apache.tools.ant.Project;
16
17
/**
18
 * This class exists so that the Ant integration has backwards compatibility
19
 * with Ant releases previous to 1.6. DemuxInputStream is a new class to Ant 1.6.
20
 */
21
class DemuxInputStreamSetter {
22
23
	protected void remapSystemIn(Project project) {
24
		System.setIn(new DemuxInputStream(project));
25
	}
26
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/EclipseDefaultExecutor.java (-41 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
import java.util.Arrays;
14
import java.util.Vector;
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Executor;
18
import org.apache.tools.ant.Project;
19
import org.apache.tools.ant.helper.DefaultExecutor;
20
21
public class EclipseDefaultExecutor extends DefaultExecutor {
22
23
    private static final EclipseSingleCheckExecutor SUB_EXECUTOR = new EclipseSingleCheckExecutor();
24
    
25
    /* (non-Javadoc)
26
     * @see org.apache.tools.ant.Executor#executeTargets(org.apache.tools.ant.Project, java.lang.String[])
27
     */
28
    public void executeTargets(Project project, String[] targetNames) throws BuildException {
29
        Vector v= new Vector();
30
        v.addAll(Arrays.asList(targetNames));
31
        project.addReference("eclipse.ant.targetVector", v); //$NON-NLS-1$
32
        super.executeTargets(project, targetNames);
33
    }
34
    
35
    /* (non-Javadoc)
36
     * @see org.apache.tools.ant.Executor#getSubProjectExecutor()
37
     */
38
    public Executor getSubProjectExecutor() {
39
       return SUB_EXECUTOR;
40
    }
41
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/EclipseSingleCheckExecutor.java (-39 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
import java.util.Arrays;
14
import java.util.Vector;
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Executor;
18
import org.apache.tools.ant.Project;
19
import org.apache.tools.ant.helper.SingleCheckExecutor;
20
21
public class EclipseSingleCheckExecutor extends SingleCheckExecutor {
22
23
    /* (non-Javadoc)
24
     * @see org.apache.tools.ant.Executor#executeTargets(org.apache.tools.ant.Project, java.lang.String[])
25
     */
26
    public void executeTargets(Project project, String[] targetNames) throws BuildException {
27
        Vector v= new Vector();
28
        v.addAll(Arrays.asList(targetNames));
29
        project.addReference("eclipse.ant.targetVector", v); //$NON-NLS-1$
30
        super.executeTargets(project, targetNames);
31
    }
32
    
33
    /* (non-Javadoc)
34
     * @see org.apache.tools.ant.Executor#getSubProjectExecutor()
35
     */
36
    public Executor getSubProjectExecutor() {
37
        return this;
38
    }
39
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/ExecutorSetter.java (-26 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
import org.apache.tools.ant.Executor;
14
import org.apache.tools.ant.Project;
15
16
/**
17
 * This class exists so that the Ant integration has backwards compatibility
18
 * with Ant releases previous to 1.6.3. Executors are a new feature of Ant 1.6.3.
19
 */
20
public class ExecutorSetter {
21
22
    protected void setExecutor(Project project) {
23
        Executor executor= new EclipseDefaultExecutor();
24
        project.setExecutor(executor);
25
    }
26
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/InputHandlerSetter.java (-44 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
14
import java.text.MessageFormat; // can't use ICU, used by ant
15
16
import org.apache.tools.ant.BuildException;
17
import org.apache.tools.ant.Project;
18
import org.apache.tools.ant.input.DefaultInputHandler;
19
import org.apache.tools.ant.input.InputHandler;
20
21
/**
22
 * This class exists so that the Ant integration has backwards compatibility
23
 * with Ant releases previous to 1.5. InputHandlers are a new feature of Ant 1.5.
24
 */
25
class InputHandlerSetter {
26
27
	protected void setInputHandler(Project project, String inputHandlerClassname) {
28
		InputHandler handler = null;
29
		if (inputHandlerClassname == null) {
30
			handler = new DefaultInputHandler();
31
		} else {
32
			try {
33
				handler = (InputHandler)(Class.forName(inputHandlerClassname).newInstance());
34
			} catch (ClassCastException e) {
35
				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5"), new String[]{inputHandlerClassname}); //$NON-NLS-1$
36
				throw new BuildException(msg, e);
37
			} catch (Exception e) {
38
				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6"), new String[]{inputHandlerClassname, e.getClass().getName()}); //$NON-NLS-1$
39
				throw new BuildException(msg, e);
40
			}
41
		}
42
		project.setInputHandler(handler);
43
	}
44
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/InternalAntRunner.java (-1231 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * Portions Copyright  2000-2005 The Apache Software Foundation
4
 * All rights reserved. This program and the accompanying materials are made 
5
 * available under the terms of the Apache Software License v2.0 which 
6
 * accompanies this distribution and is available at 
7
 * http://www.apache.org/licenses/LICENSE-2.0.
8
 * 
9
 * Contributors:
10
 *     IBM Corporation - derived implementation
11
 *******************************************************************************/
12
13
package org.eclipse.ant.internal.ui.antsupport;
14
15
import java.io.File;
16
import java.io.FileInputStream;
17
import java.io.FileNotFoundException;
18
import java.io.FileOutputStream;
19
import java.io.IOException;
20
import java.io.InputStream;
21
import java.io.PrintStream;
22
import java.text.MessageFormat; // can't use ICU, used by ant build
23
import java.util.ArrayList;
24
import java.util.Collections;
25
import java.util.Enumeration;
26
import java.util.HashMap;
27
import java.util.Iterator;
28
import java.util.List;
29
import java.util.Map;
30
import java.util.Properties;
31
import java.util.Vector;
32
33
import org.apache.tools.ant.AntTypeDefinition;
34
import org.apache.tools.ant.BuildEvent;
35
import org.apache.tools.ant.BuildException;
36
import org.apache.tools.ant.BuildListener;
37
import org.apache.tools.ant.BuildLogger;
38
import org.apache.tools.ant.ComponentHelper;
39
import org.apache.tools.ant.DefaultLogger;
40
import org.apache.tools.ant.DemuxOutputStream;
41
import org.apache.tools.ant.Diagnostics;
42
import org.apache.tools.ant.Main;
43
import org.apache.tools.ant.Project;
44
import org.apache.tools.ant.ProjectHelper;
45
import org.apache.tools.ant.Target;
46
import org.apache.tools.ant.Task;
47
import org.apache.tools.ant.TaskAdapter;
48
import org.apache.tools.ant.util.FileUtils;
49
import org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger;
50
51
/**
52
 * Eclipse application entry point into Ant in a separate VM. Derived from the original Ant Main class
53
 * to ensure that the functionality is equivalent when running in the platform.
54
 */
55
public class InternalAntRunner {
56
57
	/**
58
	 *  Message priority for project help messages. 
59
	 */
60
	public static final int MSG_PROJECT_HELP= Project.MSG_DEBUG + 1;
61
	
62
	private List buildListeners;
63
64
	private String buildFileLocation;
65
66
	/** 
67
	 * Targets we want to run.
68
	 */
69
	private Vector targets;
70
71
	private Map userProperties;
72
	
73
	private Project currentProject;
74
	
75
	private BuildLogger buildLogger= null;
76
	
77
	private Map eclipseSpecifiedTasks;
78
	private Map eclipseSpecifiedTypes;
79
	
80
	/**
81
	 * Cache of the Ant version number when it has been loaded
82
	 */
83
	private String antVersionNumber= null;
84
85
	/** Our current message output status. Follows Project.MSG_XXX */
86
	private int messageOutputLevel = Project.MSG_INFO;
87
88
	/** Indicates whether output to the log is to be unadorned. */
89
	private boolean emacsMode = false;
90
91
	/** Indicates we should only parse and display the project help information */
92
	private boolean projectHelp = false;
93
94
	/** Stream that we are using for logging */
95
	private PrintStream out = System.out;
96
97
	/** Stream that we are using for logging error messages */
98
	private PrintStream err = System.err;
99
100
	/**
101
	 * The Ant logger class. There may be only one logger. It will have the
102
	 * right to use the 'out' PrintStream. The class must implement the BuildLogger
103
	 * interface.  An empty String indicates that no logger is to be used.  A <code>null</code>
104
	 * name indicates that the <code>org.apache.tools.ant.DefaultLogger</code> will be used.
105
	 */
106
	private String loggerClassname = null;
107
108
	/** Extra arguments to be parsed as command line arguments. */
109
	private String[] extraArguments = null;
110
	
111
	private boolean scriptExecuted= false;
112
	
113
	private List propertyFiles= new ArrayList();
114
	
115
	/**
116
     * The Ant InputHandler class. There may be only one input handler.
117
     */
118
    private String inputHandlerClassname = null;
119
    
120
    /** 
121
     * Indicates whether to execute all targets that 
122
     * do not depend on failed targets
123
     * @since Ant 1.6.0
124
     */
125
    private boolean keepGoing= false;
126
127
    /** 
128
     * Indicates whether this build is to support interactive input 
129
     * @since Ant 1.6.0
130
     */
131
    private boolean allowInput = true;
132
    
133
    private String fEarlyErrorMessage= null;
134
    
135
    public static void main(String[] args) {
136
    	try {
137
    		new InternalAntRunner().run(getArrayList(args));
138
    	} catch (Throwable t) {
139
    	    t.printStackTrace();
140
    		System.exit(1);
141
    	}
142
		System.exit(0);
143
	}
144
145
	private void addBuildListeners(Project project) {
146
		String className= null;
147
		try {
148
			BuildLogger logger= createLogger();
149
			if (logger != null) {
150
				project.addBuildListener(logger);
151
			}
152
			if (buildListeners != null) {
153
				for (Iterator iterator = buildListeners.iterator(); iterator.hasNext();) {
154
					className = (String) iterator.next();
155
					Class listener = Class.forName(className);
156
					project.addBuildListener((BuildListener) listener.newInstance());
157
				}
158
			}
159
		} catch (ClassCastException e) {
160
			String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_be_a_build_listener_is_not_an_instance_of_org.apache.tools.ant.BuildListener._1"), new String[]{className}); //$NON-NLS-1$
161
			logMessage(null, message, Project.MSG_ERR);
162
			throw new BuildException(message, e);
163
		} catch (BuildException e) {
164
			throw e;
165
		} catch (Exception e) {
166
			throw new BuildException(e);
167
		}
168
	}
169
170
	/**
171
	 * Parses the build file and adds necessary information into
172
	 * the given project.
173
	 * @param project The project to configure
174
	 */
175
	private void parseBuildFile(Project project) {
176
		File buildFile = new File(getBuildFileLocation());
177
		if (!buildFile.exists()) {
178
			throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Buildfile__{0}_does_not_exist_!_1"), //$NON-NLS-1$
179
						 new String[]{buildFile.getAbsolutePath()}));
180
		}
181
		if (!buildFile.isFile()) {
182
			throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Buildfile__{0}_is_not_a_file_1"), //$NON-NLS-1$
183
							new String[]{buildFile.getAbsolutePath()}));
184
		}
185
		
186
        if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
187
            parseBuildFile(project, buildFile);
188
        } else {
189
            ProjectHelper helper = ProjectHelper.getProjectHelper();
190
            project.addReference("ant.projectHelper", helper); //$NON-NLS-1$
191
            helper.parse(project, buildFile);
192
        }
193
    }
194
    
195
    /**
196
     * @deprecated support for Ant older than 1.5
197
     */
198
    private void parseBuildFile(Project project, File buildFile) {
199
        ProjectHelper.configureProject(project, buildFile);   
200
    }
201
202
	private void printArguments(Project project) {
203
		if ((messageOutputLevel != Project.MSG_DEBUG) && (messageOutputLevel != Project.MSG_VERBOSE)) {
204
			return;
205
		}
206
		StringBuffer sb = new StringBuffer();
207
		for (int i = 0; i < extraArguments.length; i++) {
208
			sb.append(extraArguments[i]);
209
			sb.append(' ');
210
		}
211
		project.log(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Arguments__{0}_2"), new String[]{sb.toString().trim()})); //$NON-NLS-1$
212
	}
213
214
215
	/**
216
	 * Logs a message with the client that lists the targets
217
	 * in a project
218
	 * 
219
	 * @param project the project to list targets from
220
	 */
221
	private void printTargets(Project project) {
222
		//notify the logger that project help message are coming
223
		//since there is no buildstarted or targetstarted to 
224
		//to be used to establish the connection
225
		logMessage(project, "", MSG_PROJECT_HELP); //$NON-NLS-1$
226
		// find the target with the longest name
227
		int maxLength = 0;
228
		Enumeration ptargets = project.getTargets().elements();
229
		String targetName;
230
		String targetDescription;
231
		Target currentTarget;
232
		// split the targets in top-level and sub-targets depending
233
		// on the presence of a description
234
		List topNames = new ArrayList();
235
		List topDescriptions = new ArrayList();
236
		List subNames = new ArrayList();
237
238
		while (ptargets.hasMoreElements()) {
239
			currentTarget = (Target) ptargets.nextElement();
240
			targetName = currentTarget.getName();
241
			targetDescription = currentTarget.getDescription();
242
			if (targetDescription == null) {
243
				subNames.add(targetName);
244
			} else {
245
				topNames.add(targetName);
246
				topDescriptions.add(targetDescription);
247
				if (targetName.length() > maxLength) {
248
					maxLength = targetName.length();
249
				}
250
			}
251
		}
252
253
		Collections.sort(subNames);
254
		Collections.sort(topNames);
255
		Collections.sort(topDescriptions);
256
		
257
		String defaultTargetName = project.getDefaultTarget();
258
		if (defaultTargetName != null && !"".equals(defaultTargetName)) { // shouldn't need to check but... //$NON-NLS-1$
259
			List defaultName = new ArrayList(1);
260
			List defaultDesc = null;
261
			defaultName.add(defaultTargetName);
262
263
			int indexOfDefDesc = topNames.indexOf(defaultTargetName);
264
			if (indexOfDefDesc >= 0) {
265
				defaultDesc = new ArrayList(1);
266
				defaultDesc.add(topDescriptions.get(indexOfDefDesc));
267
			}
268
			printTargets(project, defaultName, defaultDesc, RemoteAntMessages.getString("InternalAntRunner.Default_target__3"), maxLength); //$NON-NLS-1$
269
270
		}
271
272
		printTargets(project, topNames, topDescriptions, RemoteAntMessages.getString("InternalAntRunner.Main_targets__4"), maxLength); //$NON-NLS-1$
273
		printTargets(project, subNames, null, RemoteAntMessages.getString("InternalAntRunner.Subtargets__5"), 0); //$NON-NLS-1$
274
	}
275
276
	/**
277
	 * Logs a message with the client that lists the target names and optional descriptions
278
	 * 
279
	 * @param project the enclosing target
280
	 * @param names the targets names
281
	 * @param descriptions the corresponding descriptions
282
	 * @param heading the message heading
283
	 * @param maxlen maximum length that can be allocated for a name
284
	 */
285
	private void printTargets(Project project, List names, List descriptions, String heading, int maxlen) {
286
		// now, start printing the targets and their descriptions
287
		String lSep = System.getProperty("line.separator"); //$NON-NLS-1$
288
		
289
		String spaces = "    "; //$NON-NLS-1$
290
		while (spaces.length() < maxlen) {
291
			spaces += spaces;
292
		}
293
		StringBuffer msg = new StringBuffer();
294
		msg.append(heading + lSep + lSep);
295
		for (int i = 0; i < names.size(); i++) {
296
			msg.append(' ');
297
			msg.append(names.get(i));
298
			if (descriptions != null) {
299
				msg.append(spaces.substring(0, maxlen - ((String) names.get(i)).length() + 2));
300
				msg.append(descriptions.get(i));
301
			}
302
			msg.append(lSep);
303
		}
304
		logMessage(project, msg.toString(), Project.MSG_INFO);
305
	}
306
307
	/*
308
	 * Note that the list passed to this method must support
309
	 * List#remove(Object)
310
	 */
311
	private void run(List argList) {
312
		setCurrentProject(new Project());
313
         if (isVersionCompatible("1.6.3")) { //$NON-NLS-1$
314
               new ExecutorSetter().setExecutor(getCurrentProject());
315
            }
316
		Throwable error = null;
317
		PrintStream originalErr = System.err;
318
		PrintStream originalOut = System.out;
319
		InputStream originalIn= System.in;
320
		
321
		SecurityManager originalSM= System.getSecurityManager();
322
		scriptExecuted= true;
323
		try {
324
			if (argList != null && (argList.remove("-projecthelp") || argList.remove("-p"))) { //$NON-NLS-1$ //$NON-NLS-2$
325
				projectHelp = true;
326
			}
327
			getCurrentProject().init();
328
			if (argList != null) {
329
				scriptExecuted= preprocessCommandLine(argList);
330
			
331
				if (!scriptExecuted) {
332
					return;
333
				}
334
			}
335
			
336
            boolean exceptionState= processProperties(argList);
337
            
338
			addBuildListeners(getCurrentProject());
339
            
340
			addInputHandler(getCurrentProject());
341
			
342
			remapSystemIn();
343
			System.setOut(new PrintStream(new DemuxOutputStream(getCurrentProject(), false)));
344
			System.setErr(new PrintStream(new DemuxOutputStream(getCurrentProject(), true)));
345
			
346
			if (!projectHelp) {
347
				fireBuildStarted(getCurrentProject());
348
			}
349
            
350
            if (fEarlyErrorMessage != null) {
351
                //an error occurred processing the properties
352
                //build started has fired and we have
353
                //listeners/loggers to report the error
354
                logMessage(getCurrentProject(), fEarlyErrorMessage, Project.MSG_ERR);
355
                if (exceptionState) {
356
                    throw new BuildException(fEarlyErrorMessage);
357
                }
358
            }
359
            
360
            //properties can only be set after buildStarted as some listeners/loggers
361
            //depend on this (e.g. XMLLogger)
362
            setProperties(getCurrentProject());
363
			
364
			if (argList != null && !argList.isEmpty()) {
365
				try {
366
					scriptExecuted= processCommandLine(argList);
367
				} catch (BuildException e) {
368
					scriptExecuted= false;
369
					throw e;
370
				}
371
			}
372
			if (!scriptExecuted) {
373
				return;
374
			}
375
			
376
            //needs to occur after processCommandLine(List)
377
			if (allowInput && (inputHandlerClassname != null && inputHandlerClassname.length() > 0)) {
378
				if (isVersionCompatible("1.6")) { //$NON-NLS-1$
379
					getCurrentProject().setDefaultInputStream(originalIn);
380
				}
381
			} else {
382
				//set the system property that any input handler
383
				//can check to see if handling input is allowed
384
				System.setProperty("eclipse.ant.noInput", "true");  //$NON-NLS-1$//$NON-NLS-2$
385
				if (isVersionCompatible("1.5") && (inputHandlerClassname == null || inputHandlerClassname.length() == 0)) { //$NON-NLS-1$
386
					InputHandlerSetter setter= new InputHandlerSetter();
387
					setter.setInputHandler(getCurrentProject(), "org.eclipse.ant.internal.ui.antsupport.inputhandler.FailInputHandler"); //$NON-NLS-1$
388
				}
389
			}
390
			
391
			getCurrentProject().log(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Build_file__{0}_1"), new String[]{getBuildFileLocation()})); //$NON-NLS-1$
392
			
393
			setTasks();
394
			setTypes();
395
			
396
			if (isVersionCompatible("1.6")) { //$NON-NLS-1$
397
				getCurrentProject().setKeepGoingMode(keepGoing);
398
			}
399
			
400
			parseBuildFile(getCurrentProject());
401
			
402
			if (projectHelp) {
403
				printHelp(getCurrentProject());
404
				scriptExecuted= false;
405
				return;
406
			}
407
			
408
			if (extraArguments != null) {
409
				printArguments(getCurrentProject());
410
			}
411
			
412
			System.setSecurityManager(new AntSecurityManager(originalSM, Thread.currentThread()));
413
			
414
			if (targets == null) {
415
                targets= new Vector(1);
416
            }
417
            if (targets.isEmpty() && getCurrentProject().getDefaultTarget() != null) {
418
                targets.add(getCurrentProject().getDefaultTarget());
419
            }
420
			if (!isVersionCompatible("1.6.3")) {  //$NON-NLS-1$
421
	            getCurrentProject().addReference("eclipse.ant.targetVector", targets); //$NON-NLS-1$
422
			}
423
			getCurrentProject().executeTargets(targets);
424
		} catch (AntSecurityException e) {
425
			//expected
426
		} catch (Throwable e) {
427
			error = e;
428
		} finally {
429
			System.setErr(originalErr);
430
			System.setOut(originalOut);
431
			System.setIn(originalIn);
432
			if (System.getSecurityManager() instanceof AntSecurityManager) {
433
				System.setSecurityManager(originalSM);
434
			}
435
			
436
			if (!projectHelp) {				
437
				fireBuildFinished(getCurrentProject(), error);
438
			}
439
						
440
			//close any user specified build log
441
			if (err != originalErr) {
442
				err.close();
443
			}
444
			if (out != originalOut) {
445
				out.close();
446
			}
447
		}
448
	}
449
	
450
	private void setTasks() {
451
		if (eclipseSpecifiedTasks != null) {
452
			Iterator itr= eclipseSpecifiedTasks.keySet().iterator();
453
			String taskName;
454
			String taskClassName;
455
			while (itr.hasNext()) {
456
				taskName= (String) itr.next();
457
				taskClassName= (String) eclipseSpecifiedTasks.get(taskName);
458
				
459
				if (isVersionCompatible("1.6")) { //$NON-NLS-1$
460
					AntTypeDefinition def= new AntTypeDefinition();
461
					def.setName(taskName);
462
		            def.setClassName(taskClassName);
463
		            def.setClassLoader(this.getClass().getClassLoader());
464
		            def.setAdaptToClass(Task.class);
465
		            def.setAdapterClass(TaskAdapter.class);
466
		            ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def);
467
				} else {
468
					try {
469
						Class taskClass = Class.forName(taskClassName);
470
						getCurrentProject().addTaskDefinition(taskName, taskClass);
471
					} catch (ClassNotFoundException e) {
472
						String message= MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.161"), new String[]{taskClassName, taskName}); //$NON-NLS-1$
473
						getCurrentProject().log(message, Project.MSG_WARN);
474
					}	
475
				}
476
			}
477
		}
478
	}
479
480
	private void setTypes() {
481
		if (eclipseSpecifiedTypes != null) {
482
			Iterator itr= eclipseSpecifiedTypes.keySet().iterator();
483
			String typeName;
484
			String typeClassName;
485
			while (itr.hasNext()) {
486
				typeName = (String) itr.next();
487
				typeClassName= (String) eclipseSpecifiedTypes.get(typeName);
488
				if (isVersionCompatible("1.6")) { //$NON-NLS-1$
489
					AntTypeDefinition def = new AntTypeDefinition();
490
	                def.setName(typeName);
491
	                def.setClassName(typeClassName);
492
	                def.setClassLoader(this.getClass().getClassLoader());
493
	                ComponentHelper.getComponentHelper(getCurrentProject()).addDataTypeDefinition(def);
494
				} else {
495
					try {
496
						Class typeClass = Class.forName(typeClassName);
497
						getCurrentProject().addDataTypeDefinition(typeName, typeClass);
498
					} catch (ClassNotFoundException e) {
499
						String message= MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.162"), new String[]{typeClassName, typeName}); //$NON-NLS-1$
500
						getCurrentProject().log(message, Project.MSG_WARN);
501
					}	
502
				}
503
			}
504
		}
505
	}
506
507
	private void remapSystemIn() {
508
		if (!isVersionCompatible("1.6")) { //$NON-NLS-1$
509
			return;
510
		}
511
		DemuxInputStreamSetter setter= new DemuxInputStreamSetter();
512
		setter.remapSystemIn(getCurrentProject());
513
	}
514
	
515
	/**
516
	 * Creates and returns the default build logger for logging build events to the ant log.
517
	 * 
518
	 * @return the default build logger for logging build events to the ant log
519
	 * 			can return <code>null</code> if no logging is to occur
520
	 */
521
	private BuildLogger createLogger() {
522
		if (loggerClassname == null) {
523
			buildLogger= new DefaultLogger();
524
		} else if (!"".equals(loggerClassname)) { //$NON-NLS-1$
525
			try {
526
				buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
527
			} catch (ClassCastException e) {
528
				String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2"), new String[]{loggerClassname}); //$NON-NLS-1$
529
				logMessage(null, message, Project.MSG_ERR);
530
				throw new BuildException(message, e);
531
			} catch (Exception e) {
532
				String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_logger__{0}_6"), new String[]{loggerClassname}); //$NON-NLS-1$
533
				logMessage(null, message, Project.MSG_ERR);
534
				throw new BuildException(message, e);
535
			}
536
		} 
537
		
538
		if (buildLogger != null) {
539
			buildLogger.setMessageOutputLevel(messageOutputLevel);
540
			buildLogger.setOutputPrintStream(out);
541
			buildLogger.setErrorPrintStream(err);
542
			buildLogger.setEmacsMode(emacsMode);
543
            if (buildLogger instanceof RemoteAntBuildLogger) {
544
                ((RemoteAntBuildLogger) buildLogger).configure(userProperties);
545
            }
546
		}
547
548
		return buildLogger;
549
    }
550
    
551
    /**
552
     * Project.fireBuildStarted is protected in Ant earlier than 1.5.*.
553
     * Provides backwards compatibility with old Ant installs.
554
     */
555
    private void fireBuildStarted(Project project) {
556
        if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
557
            BuildEvent event = new BuildEvent(project);
558
            for (Iterator iterator = project.getBuildListeners().iterator(); iterator.hasNext();) {
559
                BuildListener listener = (BuildListener) iterator.next();
560
                listener.buildStarted(event);
561
            }
562
        } else {
563
            project.fireBuildStarted();
564
        }
565
    }
566
567
	private void fireBuildFinished(Project project, Throwable error) {
568
		if (error == null && scriptExecuted) {
569
			logMessage(project, RemoteAntMessages.getString("InternalAntRunner.BUILD_SUCCESSFUL_1"), messageOutputLevel); //$NON-NLS-1$
570
		}
571
        if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
572
            BuildEvent event = new BuildEvent(project);
573
            event.setException(error);
574
            Iterator iter = project.getBuildListeners().iterator();
575
            while (iter.hasNext()) {
576
                BuildListener listener = (BuildListener) iter.next();
577
                listener.buildFinished(event);
578
            }   
579
        } else {
580
            project.fireBuildFinished(error);
581
        }
582
	}
583
584
	private void logMessage(Project project, String message, int priority) {
585
		if (project != null) {
586
			project.log(message, priority);	
587
		} else {
588
			if (buildListeners != null) {
589
				project = new Project();
590
				BuildEvent event = new BuildEvent(project);
591
				event.setMessage(message, priority);
592
				//notify the build listeners that are not registered as
593
				//no project existed
594
				for (Iterator iterator = buildListeners.iterator(); iterator.hasNext();) {
595
					try {
596
						BuildListener listener = (BuildListener) iterator.next();
597
						listener.messageLogged(event);
598
					} catch (ClassCastException e) {
599
						//ignore we could be trying to log that a build listener is the
600
						//wrong type of class
601
					}
602
				}
603
			}
604
		}
605
	}
606
607
	/**
608
	 * Sets the buildFileLocation.
609
	 * 
610
	 * @param buildFileLocation the file system location of the build file
611
	 */
612
	private void setBuildFileLocation(String buildFileLocation) {
613
		this.buildFileLocation = buildFileLocation;
614
		if (getCurrentProject() != null) {
615
			getCurrentProject().setUserProperty("ant.file", buildFileLocation); //$NON-NLS-1$
616
		}
617
	}
618
619
	private String getBuildFileLocation() {
620
		if (buildFileLocation == null) {
621
			buildFileLocation = new File("build.xml").getAbsolutePath(); //$NON-NLS-1$
622
		}
623
		return buildFileLocation;
624
	}
625
626
	/**
627
	 * Sets the message output level. Use -1 for none.
628
	 * @param level The message output level
629
	 */
630
	private void setMessageOutputLevel(int level) {
631
		messageOutputLevel = level;
632
		if (buildLogger != null) {
633
			buildLogger.setMessageOutputLevel(level);
634
		}
635
	}
636
	
637
	/*
638
	 * Returns a String representation of the Ant version number as specified
639
	 * in the version.txt file.
640
	 */
641
	private String getAntVersionNumber() throws BuildException {
642
		if (antVersionNumber == null) {
643
			try {
644
				Properties props = new Properties();
645
				InputStream in = Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); //$NON-NLS-1$
646
				props.load(in);
647
				in.close();
648
				String versionNumber= props.getProperty("VERSION");  //$NON-NLS-1$
649
				antVersionNumber= versionNumber;
650
			} catch (IOException ioe) {
651
				throw new BuildException(MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._{0}_9"), new String[]{ioe.getMessage()})); //$NON-NLS-1$
652
			} catch (NullPointerException npe) {
653
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_the_version_information._10")); //$NON-NLS-1$
654
			}
655
		}
656
		return antVersionNumber;
657
	}
658
	
659
	/*
660
	 * Returns whether the given version is compatible with the
661
	 * current Ant version. A version is compatible if it is less
662
	 * than or equal to the current version. 
663
	 */
664
	private boolean isVersionCompatible(String comparison) {
665
		String version= getAntVersionNumber();
666
		return version.compareTo(comparison) >= 0;
667
	}
668
	
669
	private boolean preprocessCommandLine(List commands) {
670
		
671
		String arg = getArgument(commands, "-listener"); //$NON-NLS-1$
672
		while (arg != null) {
673
			if (arg.length() == 0) {
674
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_classname_when_using_the_-listener_argument_1")); //$NON-NLS-1$
675
			} 
676
			if (buildListeners == null) {
677
				buildListeners= new ArrayList(1);
678
			}
679
			buildListeners.add(arg);
680
			arg = getArgument(commands, "-listener"); //$NON-NLS-1$
681
		}
682
683
		arg = getArgument(commands, "-logger"); //$NON-NLS-1$
684
		if (arg != null) {
685
			//allow empty string to mean no logger
686
			loggerClassname = arg;
687
		}
688
		arg = getArgument(commands, "-logger"); //$NON-NLS-1$
689
		if (arg != null) {
690
			throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Only_one_logger_class_may_be_specified_1")); //$NON-NLS-1$
691
		}
692
		
693
		arg = getArgument(commands, "-inputhandler"); //$NON-NLS-1$
694
		if (arg != null) {
695
			if (arg.length() == 0) {
696
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_classname_when_using_the_-inputhandler_argument_1")); //$NON-NLS-1$
697
			} 
698
			inputHandlerClassname = arg;
699
		}
700
		arg = getArgument(commands, "-inputhandler"); //$NON-NLS-1$
701
		if (arg != null) {
702
			throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.Only_one_input_handler_class_may_be_specified._2")); //$NON-NLS-1$
703
		}
704
		return true;
705
	}
706
	
707
	/*
708
	 * Looks for interesting command line arguments. 
709
	 * Returns whether it is OK to run the script.
710
	 */
711
	private boolean processCommandLine(List commands) {
712
		
713
		if (commands.remove("-help") || commands.remove("-h")) { //$NON-NLS-1$ //$NON-NLS-2$
714
			printUsage();
715
			return false;
716
		}
717
		
718
		if (commands.remove("-version")) { //$NON-NLS-1$
719
			printVersion();
720
			return false;
721
		}
722
		
723
		if (commands.remove("-verbose") || commands.remove("-v")) { //$NON-NLS-1$ //$NON-NLS-2$
724
			printVersion();
725
			setMessageOutputLevel(Project.MSG_VERBOSE);
726
		}
727
		
728
		if (commands.remove("-debug") || commands.remove("-d")) { //$NON-NLS-1$ //$NON-NLS-2$
729
			printVersion();
730
			setMessageOutputLevel(Project.MSG_DEBUG);
731
		}
732
		
733
		if (commands.remove("-quiet") || commands.remove("-q")) { //$NON-NLS-1$ //$NON-NLS-2$
734
			setMessageOutputLevel(Project.MSG_WARN);
735
		}
736
737
		if (commands.remove("-emacs") || commands.remove("-e")) { //$NON-NLS-1$ //$NON-NLS-2$
738
			emacsMode = true;
739
			if (buildLogger != null) {
740
				buildLogger.setEmacsMode(true);
741
			}
742
		}
743
		
744
		if (commands.remove("-diagnostics")) { //$NON-NLS-1$
745
			if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
746
				throw new BuildException(RemoteAntMessages.getString("InternalAntRunner.The_diagnositics_options_is_an_Ant_1.5.*_feature._Please_update_your_Ant_classpath_to_include_an_Ant_version_greater_than_this._4")); //$NON-NLS-1$
747
			}
748
			try {
749
				Diagnostics.doReport(System.out);
750
			} catch (NullPointerException e) {
751
				logMessage(getCurrentProject(), RemoteAntMessages.getString("InternalAntRunner.ANT_HOME_must_be_set_to_use_Ant_diagnostics_2"), Project.MSG_ERR); //$NON-NLS-1$
752
			}
753
			return false;
754
		}
755
		
756
		String arg = getArgument(commands, "-logfile"); //$NON-NLS-1$
757
		if (arg == null) {
758
			arg = getArgument(commands, "-l"); //$NON-NLS-1$
759
		}
760
		if (arg != null) {
761
			if (arg.length() == 0) {
762
				String message= RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_log_file_when_using_the_-log_argument_3"); //$NON-NLS-1$
763
				logMessage(currentProject, message, Project.MSG_ERR); 
764
				throw new BuildException(message);
765
			} 
766
			try {
767
				createLogFile(arg);
768
			} catch (IOException e) {
769
				// just log message and ignore exception
770
				logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_write_to_the_specified_log_file__{0}._Make_sure_the_path_exists_and_you_have_write_permissions._2"), new String[]{arg}), Project.MSG_ERR); //$NON-NLS-1$
771
				return false;
772
			}
773
		
774
		}
775
		
776
		arg = getArgument(commands, "-buildfile"); //$NON-NLS-1$
777
		if (arg == null) {
778
			arg = getArgument(commands, "-file"); //$NON-NLS-1$
779
			if (arg == null) {
780
				arg = getArgument(commands, "-f"); //$NON-NLS-1$
781
			}
782
		}
783
		
784
		if (arg != null) {
785
			if (arg.length() == 0) {
786
				String message= RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_buildfile_when_using_the_-buildfile_argument_4"); //$NON-NLS-1$
787
				logMessage(currentProject, message, Project.MSG_ERR); 
788
				throw new BuildException(message);
789
			} 
790
			setBuildFileLocation(arg);
791
		}
792
		
793
		if (isVersionCompatible("1.6")) { //$NON-NLS-1$
794
			if (commands.remove("-k") || commands.remove("-keep-going")) { //$NON-NLS-1$ //$NON-NLS-2$
795
				keepGoing= true;
796
			}
797
			if (commands.remove("-noinput")) { //$NON-NLS-1$
798
				allowInput= false;
799
			}
800
			arg= getArgument(commands, "-lib"); //$NON-NLS-1$
801
			if (arg != null) {
802
				logMessage(currentProject, RemoteAntMessages.getString("InternalAntRunner.157"), Project.MSG_ERR); //$NON-NLS-1$
803
				return false;
804
			}
805
		}
806
		
807
		arg= getArgument(commands, "-find"); //$NON-NLS-1$
808
		if (arg == null) {
809
			arg= getArgument(commands, "-s"); //$NON-NLS-1$
810
		}
811
		if (arg != null) {
812
			logMessage(currentProject, RemoteAntMessages.getString("InternalAntRunner.-find_not_supported"), Project.MSG_ERR); //$NON-NLS-1$
813
			return false;
814
		}
815
		
816
		processTasksAndTypes(commands);
817
		
818
		if (!commands.isEmpty()) {
819
			processUnrecognizedCommands(commands);
820
		}
821
822
		if (!commands.isEmpty()) {
823
			processTargets(commands);
824
		}
825
		
826
		return true;
827
	}
828
	
829
	private void processTasksAndTypes(List commands) {
830
		String arg = getArgument(commands, "-eclipseTask"); //$NON-NLS-1$
831
		while (arg != null) {
832
			if (eclipseSpecifiedTasks == null) {
833
				eclipseSpecifiedTasks= new HashMap();
834
			}
835
			int index= arg.indexOf(',');
836
			if (index != -1) {
837
				String name= arg.substring(0, index);
838
				String className= arg.substring(index + 1);
839
				eclipseSpecifiedTasks.put(name, className);
840
			}
841
			arg = getArgument(commands, "-eclipseTask"); //$NON-NLS-1$
842
		}
843
		
844
		arg = getArgument(commands, "-eclipseType"); //$NON-NLS-1$
845
		while (arg != null) {
846
			if (eclipseSpecifiedTypes == null) {
847
				eclipseSpecifiedTypes= new HashMap();
848
			}
849
			int index= arg.indexOf(',');
850
			if (index != -1) {	
851
				String name= arg.substring(0, index);
852
				String className= arg.substring(index + 1);
853
				eclipseSpecifiedTypes.put(name, className);
854
			}
855
			arg = getArgument(commands, "-eclipseType"); //$NON-NLS-1$
856
		}
857
	}
858
859
	/*
860
	 * Checks for unrecognized arguments on the command line.
861
	 * Since there is no syntactic way to distingush between
862
	 * ant -foo target1 target2
863
	 * ant -foo fooarg target
864
	 * we remove everything up to the last argument that
865
	 * begins with a '-'.  In the latter case, above, that
866
	 * means that there will be an extra target, 'fooarg',
867
	 * left lying around.
868
	 */
869
	private void processUnrecognizedCommands(List commands) {
870
		int p = -1;
871
872
		// find the last arg that begins with '-'
873
		for (int i = commands.size() - 1; i >= 0; i--) {
874
			if (((String) commands.get(0)).startsWith("-")) { //$NON-NLS-1$
875
				p = i;
876
				break;
877
			}
878
		}
879
		if (p < 0) { return; }
880
881
		// remove everything preceding that last '-arg'
882
		String s = ""; //$NON-NLS-1$
883
		for (int i = 0; i <= p; i++) {
884
			s += " " + ((String) commands.get(0)); //$NON-NLS-1$
885
			commands.remove(0);
886
		}
887
		
888
		// warn of ignored commands
889
		String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unknown_argument__{0}_2"), new Object[]{ s.substring(1) }); //$NON-NLS-1$
890
		logMessage(currentProject, message, Project.MSG_WARN); 
891
	}
892
	
893
894
	/*
895
	 * Checks for targets specified at the command line.
896
	 */
897
	private void processTargets(List commands) {
898
		if (targets == null) {
899
			targets = new Vector(commands.size());
900
		}
901
		for (Iterator iter = commands.iterator(); iter.hasNext();) {
902
			targets.add(iter.next());
903
		}
904
	}
905
906
	/*
907
	 * Creates the log file with the name specified by the user.
908
	 * If the fileName is not absolute, the file will be created in the
909
	 * working directory if specified or in the same directory as the location
910
	 * of the build file.
911
	 */
912
	private void createLogFile(String fileName) throws FileNotFoundException, IOException {
913
		File logFile = getFileRelativeToBaseDir(fileName);
914
		
915
		//this stream is closed in the finally block of run(list)
916
		out = new PrintStream(new FileOutputStream(logFile));
917
		err = out;
918
		logMessage(getCurrentProject(), MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Using_{0}_file_as_build_log._1"), new String[]{logFile.getCanonicalPath()}), Project.MSG_INFO); //$NON-NLS-1$
919
		if (buildLogger != null) {
920
			buildLogger.setErrorPrintStream(err);
921
			buildLogger.setOutputPrintStream(out);
922
		}
923
	}
924
925
	private File getFileRelativeToBaseDir(String fileName) {
926
		File parentFile= null;
927
		
928
		String base= getCurrentProject().getUserProperty("basedir"); //$NON-NLS-1$
929
		if (base != null) {
930
			parentFile= new File(base);
931
		} else {
932
			//relative to the build file location
933
			parentFile= new File(getBuildFileLocation()).getParentFile();
934
		}
935
		
936
		//remain backwards compatible for older Ant usage
937
		return FileUtils.newFileUtils().resolveFile(parentFile, fileName);
938
	}
939
940
	/*
941
	 * Processes cmd line properties and adds the user properties
942
	 * Any user properties that have been explicitly set are set as well.
943
	 * Ensures that -D properties take precedence.
944
	 */
945
	private boolean processProperties(List commands) {
946
        boolean exceptionToBeThrown= false;
947
		//MULTIPLE property files are allowed
948
		String arg= getArgument(commands, "-propertyfile"); //$NON-NLS-1$
949
		while (arg != null) {
950
			if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
951
				fEarlyErrorMessage= RemoteAntMessages.getString("InternalAntRunner.Specifying_property_files_is_a_Ant_1.5.*_feature._Please_update_your_Ant_classpath._6"); //$NON-NLS-1$
952
				break;
953
			}
954
			if (arg.length() == 0) {
955
                fEarlyErrorMessage= RemoteAntMessages.getString("InternalAntRunner.You_must_specify_a_property_filename_when_using_the_-propertyfile_argument_3"); //$NON-NLS-1$
956
                exceptionToBeThrown= true;
957
                break;
958
			} 
959
			
960
			propertyFiles.add(arg);
961
			arg= getArgument(commands, "-propertyfile"); //$NON-NLS-1$
962
		}
963
        
964
        if (propertyFiles != null && !propertyFiles.isEmpty()) {
965
            loadPropertyFiles();
966
        }
967
        
968
        if (commands != null) {
969
            processMinusDProperties(commands);
970
        }
971
        return exceptionToBeThrown;
972
	}
973
974
	private void processMinusDProperties(List commands) {
975
		String[] args = (String[]) commands.toArray(new String[commands.size()]);
976
		for (int i = 0; i < args.length; i++) {
977
			String arg = args[i];
978
			if (arg.startsWith("-D")) { //$NON-NLS-1$
979
				String name = arg.substring(2, arg.length());
980
				String value = null;
981
				int posEq = name.indexOf("="); //$NON-NLS-1$
982
				if (posEq == 0) {
983
					value= name.substring(1);
984
					name= ""; //$NON-NLS-1$
985
				} else if (posEq > 0 && posEq != name.length() - 1) {
986
					value = name.substring(posEq + 1).trim();
987
					name = name.substring(0, posEq);
988
				}
989
				
990
				if (value == null) {
991
					//the user has specified something like "-Debug"
992
					continue;
993
				}
994
				if (userProperties == null) {
995
					userProperties= new HashMap();
996
				}
997
				userProperties.put(name, value);
998
				commands.remove(args[i]);
999
			}
1000
		}
1001
	}
1002
	
1003
	private void setProperties(Project project) {
1004
		setBuiltInProperties(project);
1005
		if (userProperties != null) {
1006
			for (Iterator iterator = userProperties.entrySet().iterator(); iterator.hasNext();) {
1007
				Map.Entry entry = (Map.Entry) iterator.next();
1008
				project.setUserProperty((String) entry.getKey(), (String) entry.getValue());
1009
			}
1010
		} 
1011
	}
1012
1013
	private void setBuiltInProperties(Project project) {
1014
		project.setUserProperty("ant.file", getBuildFileLocation()); //$NON-NLS-1$
1015
		project.setUserProperty("ant.version", Main.getAntVersion()); //$NON-NLS-1$
1016
	}
1017
1018
	/*
1019
	 * Print the project description, if any
1020
	 */
1021
	private void printHelp(Project project) {
1022
		if (project.getDescription() != null) {
1023
			logMessage(project, project.getDescription(), Project.MSG_INFO);
1024
		}
1025
		printTargets(project);
1026
	}
1027
1028
	/*
1029
	 * Logs a message with the client indicating the version of <b>Ant</b> that this class
1030
	 * fronts.
1031
	 */
1032
	private void printVersion() {
1033
		logMessage(getCurrentProject(), Main.getAntVersion(), Project.MSG_INFO);
1034
	}
1035
1036
	/*
1037
	 * Logs a message with the client outlining the usage of <b>Ant</b>.
1038
	 */
1039
	private void printUsage() {
1040
		String lSep = System.getProperty("line.separator"); //$NON-NLS-1$
1041
		StringBuffer msg = new StringBuffer();
1042
		msg.append("ant ["); //$NON-NLS-1$
1043
		msg.append(RemoteAntMessages.getString("InternalAntRunner.options_13")); //$NON-NLS-1$
1044
		msg.append("] ["); //$NON-NLS-1$
1045
		msg.append(RemoteAntMessages.getString("InternalAntRunner.target_15")); //$NON-NLS-1$
1046
		msg.append(" ["); //$NON-NLS-1$
1047
		msg.append(RemoteAntMessages.getString("InternalAntRunner.target_15")); //$NON-NLS-1$
1048
		msg.append("2 ["); //$NON-NLS-1$
1049
		msg.append(RemoteAntMessages.getString("InternalAntRunner.target_15")); //$NON-NLS-1$
1050
		msg.append("3] ...]]"); //$NON-NLS-1$
1051
		msg.append(lSep);
1052
		msg.append(RemoteAntMessages.getString("InternalAntRunner.Options___21")); //$NON-NLS-1$
1053
		msg.append(lSep);
1054
		msg.append("\t-help, -h\t\t\t\t"); //$NON-NLS-1$
1055
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_this_message_23")); //$NON-NLS-1$
1056
		msg.append(lSep);
1057
		msg.append("\t-projecthelp, -p\t\t"); //$NON-NLS-1$
1058
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_project_help_information_25")); //$NON-NLS-1$
1059
		msg.append(lSep);
1060
		msg.append("\t-version\t\t\t\t"); //$NON-NLS-1$
1061
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_the_version_information_and_exit_27")); //$NON-NLS-1$
1062
		msg.append(lSep); 
1063
		msg.append("\t-diagnostics\t\t\t"); //$NON-NLS-1$
1064
		msg.append(RemoteAntMessages.getString("InternalAntRunner.12")); //$NON-NLS-1$
1065
		msg.append(lSep);
1066
		msg.append(RemoteAntMessages.getString("InternalAntRunner.13")); //$NON-NLS-1$
1067
		msg.append(lSep);
1068
		msg.append("\t-quiet, -q\t\t\t"); //$NON-NLS-1$
1069
		msg.append(RemoteAntMessages.getString("InternalAntRunner.be_extra_quiet_29")); //$NON-NLS-1$
1070
		msg.append(lSep);
1071
		msg.append("\t-verbose, -v\t\t\t"); //$NON-NLS-1$
1072
		msg.append(RemoteAntMessages.getString("InternalAntRunner.be_extra_verbose_31")); //$NON-NLS-1$
1073
		msg.append(lSep);
1074
		msg.append("\t-debug, -d\t\t\t"); //$NON-NLS-1$
1075
		msg.append(RemoteAntMessages.getString("InternalAntRunner.print_debugging_information_33")); //$NON-NLS-1$
1076
		msg.append(lSep);
1077
		msg.append("\t-emacs, -e\t\t\t"); //$NON-NLS-1$
1078
		msg.append(RemoteAntMessages.getString("InternalAntRunner.produce_logging_information_without_adornments_35")); //$NON-NLS-1$
1079
		msg.append(lSep);
1080
		msg.append("\t-logfile\t<file>\t\t"); //$NON-NLS-1$
1081
		msg.append(RemoteAntMessages.getString("InternalAntRunner.use_given_file_for_log_37")); //$NON-NLS-1$
1082
		msg.append(lSep);
1083
		msg.append("\t\t-l\t<file>"); //$NON-NLS-1$
1084
		msg.append(RemoteAntMessages.getString("InternalAntRunner.1")); //$NON-NLS-1$
1085
		msg.append(lSep);  
1086
		msg.append("\t-logger <classname>\t\t"); //$NON-NLS-1$
1087
		msg.append(RemoteAntMessages.getString("InternalAntRunner.the_class_which_is_to_perform_logging_39")); //$NON-NLS-1$
1088
		msg.append(lSep);  
1089
		msg.append("\t-listener <classname>\t"); //$NON-NLS-1$
1090
		msg.append(RemoteAntMessages.getString("InternalAntRunner.add_an_instance_of_class_as_a_project_listener_41")); //$NON-NLS-1$
1091
		msg.append(lSep);
1092
		msg.append("\t-noinput\t"); //$NON-NLS-1$
1093
		msg.append(RemoteAntMessages.getString("InternalAntRunner.158")); //$NON-NLS-1$
1094
		msg.append(lSep); 
1095
		msg.append("\t-buildfile\t<file>\t"); //$NON-NLS-1$
1096
		msg.append(RemoteAntMessages.getString("InternalAntRunner.use_given_buildfile_43")); //$NON-NLS-1$
1097
		msg.append(lSep); 
1098
		msg.append("\t\t-file\t<file>"); //$NON-NLS-1$
1099
		msg.append(RemoteAntMessages.getString("InternalAntRunner.1")); //$NON-NLS-1$
1100
		msg.append(lSep);
1101
		msg.append("\t\t-f\t\t<file>"); //$NON-NLS-1$
1102
		msg.append(RemoteAntMessages.getString("InternalAntRunner.1")); //$NON-NLS-1$
1103
		msg.append(lSep);
1104
		msg.append("\t-D<property>=<value>\t"); //$NON-NLS-1$
1105
		msg.append(RemoteAntMessages.getString("InternalAntRunner.use_value_for_given_property_45")); //$NON-NLS-1$
1106
		msg.append(lSep);
1107
		msg.append("\t-keep-going, -k"); //$NON-NLS-1$
1108
		msg.append(RemoteAntMessages.getString("InternalAntRunner.159")); //$NON-NLS-1$
1109
		msg.append(lSep);
1110
		msg.append(RemoteAntMessages.getString("InternalAntRunner.160")); //$NON-NLS-1$
1111
		msg.append(lSep); 
1112
		msg.append("\t-propertyfile <name>\t"); //$NON-NLS-1$
1113
		msg.append(RemoteAntMessages.getString("InternalAntRunner.19")); //$NON-NLS-1$
1114
		msg.append(lSep);
1115
		msg.append(RemoteAntMessages.getString("InternalAntRunner.20")); //$NON-NLS-1$
1116
		msg.append(lSep);
1117
		msg.append("\t-inputhandler <class>\t"); //$NON-NLS-1$
1118
		msg.append(RemoteAntMessages.getString("InternalAntRunner.22")); //$NON-NLS-1$
1119
		msg.append(lSep);
1120
1121
		logMessage(getCurrentProject(), msg.toString(), Project.MSG_INFO);
1122
	}
1123
1124
	/*
1125
	 * From a command line list, return the argument for the given parameter.
1126
	 * The parameter and its argument are removed from the list.
1127
	 * 
1128
	 * @return <code>null</code> if the parameter is not found 
1129
	 * 			or an empty String if no arguments are found
1130
	 */
1131
	private String getArgument(List commands, String param) {
1132
		if (commands == null) {
1133
			return null;
1134
		}
1135
		int index = commands.indexOf(param);
1136
		if (index == -1) {
1137
			return null;
1138
		}
1139
		commands.remove(index);
1140
		if (index == commands.size()) {// if this is the last command
1141
			return ""; //$NON-NLS-1$
1142
		}
1143
		
1144
		String command = (String) commands.get(index);
1145
		if (command.startsWith("-")) { //new parameter //$NON-NLS-1$
1146
			return ""; //$NON-NLS-1$
1147
		}
1148
		
1149
		commands.remove(index);
1150
		return command;
1151
	}
1152
1153
	/*
1154
	 * Helper method to ensure an array is converted into an ArrayList.
1155
	 */
1156
	private static ArrayList getArrayList(String[] args) {
1157
		if (args == null) {
1158
			return null;
1159
		}
1160
		// We could be using Arrays.asList() here, but it does not specify
1161
		// what kind of list it will return. We need a list that
1162
		// implements the method List.remove(Object) and ArrayList does.
1163
		ArrayList result = new ArrayList(args.length);
1164
		for (int i = 0; i < args.length; i++) {
1165
			result.add(args[i]);
1166
		}
1167
		return result;
1168
	}
1169
1170
	private Project getCurrentProject() {
1171
		return currentProject;
1172
	}
1173
1174
	private void setCurrentProject(Project currentProject) {
1175
		this.currentProject = currentProject;
1176
	}
1177
	
1178
	/**
1179
	 * Load all properties from the files 
1180
	 * specified by -propertyfile.
1181
	 */
1182
	private void loadPropertyFiles() {
1183
		Iterator itr= propertyFiles.iterator();
1184
        while (itr.hasNext()) {
1185
            String filename= (String) itr.next();
1186
           	File file= getFileRelativeToBaseDir(filename);
1187
            Properties props = new Properties();
1188
            FileInputStream fis = null;
1189
            try {
1190
                fis = new FileInputStream(file);
1191
                props.load(fis);
1192
            } catch (IOException e) {
1193
            	fEarlyErrorMessage= MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Could_not_load_property_file_{0}__{1}_4"), new String[]{filename, e.getMessage()}); //$NON-NLS-1$
1194
            } finally {
1195
                if (fis != null) {
1196
                    try {
1197
                        fis.close();
1198
                    } catch (IOException e){
1199
                    }
1200
                }
1201
            }
1202
1203
            if (userProperties == null) {
1204
            	userProperties= new HashMap();
1205
            }
1206
            Enumeration propertyNames = props.propertyNames();
1207
            while (propertyNames.hasMoreElements()) {
1208
                String name = (String) propertyNames.nextElement();
1209
                //most specific to global
1210
                //do not overwrite specific with a global property
1211
                if (userProperties.get(name) == null) {
1212
            		userProperties.put(name, props.getProperty(name));
1213
                }
1214
            }
1215
        }
1216
	}
1217
	
1218
	/*
1219
     * Creates the InputHandler and adds it to the project.
1220
     *
1221
     * @exception BuildException if a specified InputHandler
1222
     *                           implementation could not be loaded.
1223
     */
1224
    private void addInputHandler(Project project) {
1225
    	if (!isVersionCompatible("1.5")) { //$NON-NLS-1$
1226
			return;
1227
		}
1228
		InputHandlerSetter setter= new InputHandlerSetter();
1229
		setter.setInputHandler(project, inputHandlerClassname);
1230
    }
1231
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/RemoteAntMessages.java (-33 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport;
12
13
14
import java.util.MissingResourceException;
15
import java.util.ResourceBundle;
16
17
public class RemoteAntMessages {
18
19
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.antsupport.RemoteAntMessages"; //$NON-NLS-1$
20
21
	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
22
23
	private RemoteAntMessages() {
24
	}
25
26
	public static String getString(String key) {
27
		try {
28
			return RESOURCE_BUNDLE.getString(key);
29
		} catch (MissingResourceException e) {
30
			return '!' + key + '!';
31
		}
32
	}
33
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/RemoteAntMessages.properties (-83 lines)
Removed Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2008 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
InternalAntRunner.Build_file__{0}_1=Buildfile: {0}
13
InternalAntRunner.Arguments__{0}_2=Arguments: {0}
14
InternalAntRunner.Default_target__3=Default target:
15
InternalAntRunner.Main_targets__4=Main targets:
16
InternalAntRunner.Subtargets__5=Subtargets:
17
InternalAntRunner.Unable_to_instantiate_logger__{0}_6=Unable to instantiate logger: {0}
18
InternalAntRunner.Could_not_load_the_version_information._{0}_9=Could not load the version information. {0}
19
InternalAntRunner.Could_not_load_the_version_information._10=Could not load the version information.
20
InternalAntRunner.options_13=options
21
InternalAntRunner.target_15=target
22
InternalAntRunner.Options___21=Options: 
23
InternalAntRunner.print_this_message_23=print this message
24
InternalAntRunner.print_project_help_information_25=print project help information
25
InternalAntRunner.print_the_version_information_and_exit_27=print the version information and exit
26
InternalAntRunner.be_extra_quiet_29=be extra quiet
27
InternalAntRunner.be_extra_verbose_31=be extra verbose
28
InternalAntRunner.print_debugging_information_33=print debugging information
29
InternalAntRunner.produce_logging_information_without_adornments_35=produce logging information without adornments
30
InternalAntRunner.use_given_file_for_log_37=use given file for log
31
InternalAntRunner.the_class_which_is_to_perform_logging_39=the class which is to perform logging
32
InternalAntRunner.add_an_instance_of_class_as_a_project_listener_41=add an instance of class as a project listener
33
InternalAntRunner.use_given_buildfile_43=use given buildfile
34
InternalAntRunner.use_value_for_given_property_45=use value for given property
35
InternalAntRunner.Using_{0}_file_as_build_log._1=Using {0} file as build log.
36
InternalAntRunner.Could_not_write_to_the_specified_log_file__{0}._Make_sure_the_path_exists_and_you_have_write_permissions._2=Cannot write on the specified log file: {0}. Make sure the path exists and you have write permissions.
37
InternalAntRunner.BUILD_SUCCESSFUL_1=BUILD SUCCESSFUL
38
InternalAntRunner.Unknown_argument__{0}_2=Unknown argument: {0}
39
InternalAntRunner.Buildfile__{0}_does_not_exist_!_1=Buildfile: {0} does not exist
40
InternalAntRunner.{0}_which_was_specified_to_be_a_build_listener_is_not_an_instance_of_org.apache.tools.ant.BuildListener._1={0} which was specified to be a build listener is not an instance of org.apache.tools.ant.BuildListener.
41
InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2={0} which was specified to perform logging is not an instance of org.apache.tools.ant.BuildLogger.
42
InternalAntRunner.You_must_specify_a_classname_when_using_the_-listener_argument_1=You must specify a classname when using the -listener argument
43
InternalAntRunner.You_must_specify_a_log_file_when_using_the_-log_argument_3=You must specify a log file when using the -log argument
44
InternalAntRunner.You_must_specify_a_buildfile_when_using_the_-buildfile_argument_4=You must specify a buildfile when using the -buildfile argument
45
InternalAntRunner.12=print information that might be helpful to
46
InternalAntRunner.13=\t\t\t\t\t\t\tdiagnose or report problems.
47
InternalAntRunner.19=load all properties from file with -D
48
InternalAntRunner.20=\t\t\t\t\t\t\tproperties taking precedence
49
InternalAntRunner.22=the class which will handle input requests
50
InternalAntRunner.1=\t\t\t\t\'
51
InternalAntRunner.Only_one_logger_class_may_be_specified_1=Only one logger class may be specified
52
InternalAntRunner.You_must_specify_a_classname_when_using_the_-inputhandler_argument_1=You must specify a classname when using the -inputhandler argument
53
InternalAntRunner.Only_one_input_handler_class_may_be_specified._2=Only one input handler class may be specified.
54
InternalAntRunner.You_must_specify_a_property_filename_when_using_the_-propertyfile_argument_3=You must specify a property filename when using the -propertyfile argument
55
InternalAntRunner.Could_not_load_property_file_{0}__{1}_4=Could not load property file {0}: {1}
56
InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5=The specified input handler class {0} does not implement the org.apache.tools.ant.input.InputHandler interface
57
InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6=Unable to instantiate specified input handler class {0} : {1}
58
InternalAntRunner.The_diagnositics_options_is_an_Ant_1.5.*_feature._Please_update_your_Ant_classpath_to_include_an_Ant_version_greater_than_this._4=The diagnostics options is an Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this.
59
InternalAntRunner.Specifying_property_files_is_a_Ant_1.5.*_feature._Please_update_your_Ant_classpath._6=Specifying property files is a Ant 1.5.* feature. Please update your Ant classpath to include an Ant version greater than this.
60
InternalAntRunner.ANT_HOME_must_be_set_to_use_Ant_diagnostics_2=ANT_HOME must be set to use Ant diagnostics
61
InternalAntRunner.Buildfile__{0}_is_not_a_file_1=Buildfile: {0} is not a file
62
InternalAntRunner.-find_not_supported=-find not supported.\nCan be emulated using Run As > Ant Build located\nin the Run > External Tools menu
63
InternalAntRunner.157=-lib not supported\nConfigure the Ant runtime classpath using either the\nglobal Ant runtime classpath or the Ant runtime classpath\n for this particular build
64
InternalAntRunner.158=\t\t\tdo not allow interactive input
65
InternalAntRunner.159=\t\texecute all targets that do not depend
66
InternalAntRunner.160=\t\t\t\t\t\ton failed target(s)
67
InternalAntRunner.161=Class {0} not found for task {1}
68
InternalAntRunner.162=Class {0} not found for type {1}
69
70
RemoteAntBuildLogger.1=BUILD FAILED
71
RemoteAntBuildLogger.Total_time=Total time: 
72
RemoteAntBuildLogger._minutes_2=\ minutes
73
RemoteAntBuildLogger._minute_3=\ minute
74
RemoteAntBuildLogger._seconds_4=\ seconds
75
RemoteAntBuildLogger._second_5=\ second
76
RemoteAntBuildLogger._milliseconds_6=\ milliseconds
77
78
SWTInputHandler.0=Unable to respond to input request as a result of the user specified -noinput command
79
SWTInputHandler.1=Ant Input Request
80
SWTInputHandler.2=Unable to respond to <input> request
81
SWTInputHandler.3=Input does not match validargs attribute
82
SWTInputHandler.4=OK
83
SWTInputHandler.5=Cancel
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/inputhandler/FailInputHandler.java (-29 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.ant.internal.ui.antsupport.inputhandler;
13
14
import java.io.IOException;
15
import java.io.InputStream;
16
17
import org.apache.tools.ant.input.DefaultInputHandler;
18
19
public class FailInputHandler extends DefaultInputHandler {
20
	
21
	protected InputStream getInputStream() {
22
		//ensure any attempts to read input fail
23
		return new InputStream(){
24
			public int read() throws IOException {
25
				throw new IOException();
26
			}
27
		};
28
	}
29
}
(-)Remote (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.inputhandler;
12
13
14
import java.util.MissingResourceException;
15
import java.util.ResourceBundle;
16
17
public class RemoteAntMessages {
18
19
	private static final String BUNDLE_NAME = "org.eclipse.ant.internal.ui.antsupport.inputhandler.RemoteAntMessages"; //$NON-NLS-1$
20
21
	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
22
23
	private RemoteAntMessages() {
24
	}
25
26
	public static String getString(String key) {
27
		try {
28
			return RESOURCE_BUNDLE.getString(key);
29
		} catch (MissingResourceException e) {
30
			return '!' + key + '!';
31
		}
32
	}
33
}
(-)Remote (+17 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
SWTInputHandler.0=Unable to respond to input request as a result of the user specified -noinput command
13
SWTInputHandler.1=Ant Input Request
14
SWTInputHandler.2=Unable to respond to <input> request
15
SWTInputHandler.3=Input does not match validargs attribute
16
SWTInputHandler.4=OK
17
SWTInputHandler.5=Cancel
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/inputhandler/SWTInputHandler.java (-1 lines)
Lines 18-24 Link Here
18
import org.apache.tools.ant.input.DefaultInputHandler;
18
import org.apache.tools.ant.input.DefaultInputHandler;
19
import org.apache.tools.ant.input.InputRequest;
19
import org.apache.tools.ant.input.InputRequest;
20
import org.apache.tools.ant.input.MultipleChoiceInputRequest;
20
import org.apache.tools.ant.input.MultipleChoiceInputRequest;
21
import org.eclipse.ant.internal.ui.antsupport.RemoteAntMessages;
22
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.events.ModifyEvent;
22
import org.eclipse.swt.events.ModifyEvent;
24
import org.eclipse.swt.events.ModifyListener;
23
import org.eclipse.swt.events.ModifyListener;
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/MessageIds.java (-21 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger;
12
13
14
public class MessageIds {
15
16
	public final static String PROCESS_ID=   "processID"; //$NON-NLS-1$
17
	public final static String BUILD_CANCELLED= "cancelled"; //$NON-NLS-1$
18
    //constants need to start greater than the Project.MSG_* constants
19
	public final static String TASK= "6"; //$NON-NLS-1$
20
	public final static String TARGET= "7"; //$NON-NLS-1$
21
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/RemoteAntBuildLogger.java (-396 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger;
12
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.PrintStream;
17
import java.io.PrintWriter;
18
import java.io.StringReader;
19
import java.net.Socket;
20
import java.util.ArrayList;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
25
import org.apache.tools.ant.BuildEvent;
26
import org.apache.tools.ant.BuildException;
27
import org.apache.tools.ant.DefaultLogger;
28
import org.apache.tools.ant.Location;
29
import org.apache.tools.ant.Project;
30
import org.apache.tools.ant.Target;
31
import org.apache.tools.ant.util.StringUtils;
32
import org.eclipse.ant.internal.ui.antsupport.AntSecurityException;
33
import org.eclipse.ant.internal.ui.antsupport.InternalAntRunner;
34
import org.eclipse.ant.internal.ui.antsupport.RemoteAntMessages;
35
import org.eclipse.ant.internal.ui.antsupport.logger.util.AntDebugState;
36
37
/**
38
 * Parts adapted from org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
39
 * A build logger that reports via a socket connection.
40
 * See MessageIds for more information about the protocol.
41
 */
42
public class RemoteAntBuildLogger extends DefaultLogger {
43
44
    /** Time of the start of the build */
45
    private long fStartTime = System.currentTimeMillis();
46
47
    /**
48
     * The client socket.
49
     */
50
    private Socket fEventSocket;
51
    /**
52
     * Print writer for sending messages
53
     */
54
    private PrintWriter fWriter;
55
    /**
56
     * Host to connect to, default is the localhost
57
     */
58
    protected String fHost= ""; //$NON-NLS-1$
59
    /**
60
     * Port to connect to.
61
     */
62
    private int fEventPort= -1;
63
    
64
    private String fProcessId= null;
65
    
66
    /**
67
     * Is the debug mode enabled?
68
     */
69
    protected boolean fDebugMode= false;    
70
    
71
    protected boolean fSentProcessId= false;
72
    
73
    private List fEventQueue;
74
    
75
    private String fLastFileName= null;
76
    private String fLastTaskName= null;
77
    
78
    /* (non-Javadoc)
79
     * @see org.apache.tools.ant.DefaultLogger#printMessage(java.lang.String, java.io.PrintStream, int)
80
     */
81
    protected void printMessage(String message, PrintStream stream, int priority) {
82
        marshalMessage(priority, message);
83
    }
84
    
85
    /**
86
     * Connect to the remote Ant build listener.
87
     */
88
    protected void connect() {
89
        if (fDebugMode) {
90
            System.out.println("RemoteAntBuildLogger: trying to connect" + fHost + ":" + fEventPort); //$NON-NLS-1$ //$NON-NLS-2$
91
        }
92
        
93
        for (int i= 1; i < 5; i++) {
94
            try{
95
                fEventSocket= new Socket(fHost, fEventPort);
96
                fWriter= new PrintWriter(fEventSocket.getOutputStream(), true);
97
                return;
98
            } catch(IOException e){
99
            }
100
            try {
101
                Thread.sleep(500);
102
            } catch(InterruptedException e) {
103
            }
104
        }
105
        shutDown();
106
    }
107
108
    /**
109
     * Shutdown the connection to the remote build listener.
110
     */
111
    protected void shutDown() {
112
        if (fEventQueue != null) {
113
            fEventQueue.clear();
114
        }
115
        if (fWriter != null) {
116
            fWriter.close();
117
            fWriter= null;
118
        }
119
        
120
        try {
121
            if (fEventSocket != null) {
122
                fEventSocket.close();
123
                fEventSocket= null;
124
            }
125
        } catch(IOException e) {
126
        }
127
    }
128
129
    private void sendMessage(String msg) {
130
        if (fWriter == null) {
131
            return;
132
        }
133
        
134
        fWriter.println(msg);
135
    }
136
    
137
    /* (non-Javadoc)
138
     * @see org.apache.tools.ant.BuildListener#buildFinished(org.apache.tools.ant.BuildEvent)
139
     */
140
    public void buildFinished(BuildEvent event) {
141
        if (!fSentProcessId) {
142
            establishConnection();
143
        }
144
        handleException(event);
145
        printMessage( getTimeString(System.currentTimeMillis() - fStartTime), out, Project.MSG_INFO); 
146
        shutDown();
147
    }
148
    
149
    protected void handleException(BuildEvent event) {
150
        Throwable exception = event.getException();
151
        if (exception == null || exception instanceof AntSecurityException) {
152
            return;
153
        }
154
        
155
         StringBuffer message= new StringBuffer();
156
         message.append(StringUtils.LINE_SEP);
157
         message.append(RemoteAntMessages.getString("RemoteAntBuildLogger.1")); //$NON-NLS-1$
158
         message.append(StringUtils.LINE_SEP);
159
         if (Project.MSG_VERBOSE <= this.msgOutputLevel || !(exception instanceof BuildException)) {
160
             message.append(StringUtils.getStackTrace(exception));
161
         } else {
162
             if (exception instanceof BuildException) {
163
                 message.append(exception.toString()).append(StringUtils.LINE_SEP);
164
             } else {
165
                 message.append(exception.getMessage()).append(StringUtils.LINE_SEP);
166
             }
167
         }
168
        message.append(StringUtils.LINE_SEP);
169
        printMessage(message.toString(), out, Project.MSG_ERR); 
170
    }
171
    
172
    private String getTimeString(long milliseconds) {
173
        long seconds = milliseconds / 1000;
174
        long minutes = seconds / 60;
175
        seconds= seconds % 60;
176
177
        StringBuffer result= new StringBuffer(RemoteAntMessages.getString("RemoteAntBuildLogger.Total_time")); //$NON-NLS-1$
178
        if (minutes > 0) {
179
            result.append(minutes);
180
            if (minutes > 1) {
181
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._minutes_2")); //$NON-NLS-1$
182
            } else {
183
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._minute_3")); //$NON-NLS-1$
184
            }
185
        }
186
        if (seconds > 0) {
187
            if (minutes > 0) {
188
                result.append(' ');
189
            }
190
            result.append(seconds);
191
    
192
            if (seconds > 1) {
193
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._seconds_4")); //$NON-NLS-1$
194
            } else {
195
                result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._second_5")); //$NON-NLS-1$
196
            } 
197
        }
198
        if (seconds == 0 && minutes == 0) {
199
            result.append(milliseconds);
200
            result.append(RemoteAntMessages.getString("RemoteAntBuildLogger._milliseconds_6"));      //$NON-NLS-1$
201
        }
202
        return result.toString();
203
    }
204
            
205
206
    /* (non-Javadoc)
207
     * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
208
     */
209
    public void targetStarted(BuildEvent event) {
210
        if (!fSentProcessId) {
211
            establishConnection();
212
        }
213
214
        if (Project.MSG_INFO <= msgOutputLevel) {
215
            marshalTargetMessage(event);
216
        }
217
    }
218
219
    protected void establishConnection() {
220
        if (fEventPort != -1) {
221
            connect();
222
        } else {
223
            shutDown();
224
            return;
225
        }
226
        
227
        fSentProcessId= true;
228
        StringBuffer message= new StringBuffer(MessageIds.PROCESS_ID);
229
        message.append(fProcessId);
230
        sendMessage(message.toString());
231
        if (fEventQueue != null) {
232
            for (Iterator iter = fEventQueue.iterator(); iter.hasNext();) {
233
                processEvent((BuildEvent)iter.next());
234
            }
235
            fEventQueue= null;
236
        }
237
    }
238
239
    /* (non-Javadoc)
240
     * @see org.apache.tools.ant.BuildListener#messageLogged(org.apache.tools.ant.BuildEvent)
241
     */
242
    public void messageLogged(BuildEvent event) {
243
        if (event.getPriority() > msgOutputLevel && event.getPriority() != InternalAntRunner.MSG_PROJECT_HELP) {
244
            return;
245
        }
246
        
247
        if (!fSentProcessId) {
248
            if (event.getPriority() == InternalAntRunner.MSG_PROJECT_HELP) {
249
                if (Project.MSG_INFO > msgOutputLevel) {
250
                    return;
251
                }
252
                //no buildstarted or project started for project help option
253
                establishConnection();
254
                return;
255
            }
256
            if (fEventQueue == null){
257
                fEventQueue= new ArrayList(10);
258
            }
259
            fEventQueue.add(event);
260
            return;
261
        }
262
        
263
        processEvent(event);
264
    }
265
266
    private void processEvent(BuildEvent event) {
267
        if (event.getTask() != null & !emacsMode) {
268
            try {
269
                marshalTaskMessage(event);
270
            } catch (IOException e) {
271
            }
272
        } else {
273
            marshalMessage(event);
274
        }
275
    }
276
    
277
    private void marshalMessage(BuildEvent event) {
278
        String eventMessage= event.getMessage();
279
        if (eventMessage.length() == 0) {
280
            return;
281
        }
282
        marshalMessage(event.getPriority(), eventMessage);
283
    }
284
285
    protected void marshalMessage(int priority, String message) {
286
        try {
287
            BufferedReader r = new BufferedReader(new StringReader(message));
288
            String line = r.readLine();
289
            StringBuffer messageLine;
290
            while (line != null) {
291
                messageLine= new StringBuffer();
292
                if (priority != -1) {
293
                    messageLine.append(priority);
294
                    messageLine.append(',');
295
                }
296
                messageLine.append(line);
297
                sendMessage(messageLine.toString());
298
                line = r.readLine();
299
            }
300
        } catch (IOException e) {
301
        }
302
    }
303
304
    private void marshalTaskMessage(BuildEvent event) throws IOException {
305
        String eventMessage= event.getMessage();
306
        if (eventMessage.length() == 0) {
307
            return;
308
        }
309
        BufferedReader r = new BufferedReader(new StringReader(eventMessage));
310
        String line = r.readLine();
311
        StringBuffer message;
312
        String taskName= event.getTask().getTaskName();
313
        if (taskName != null && taskName.equals(fLastTaskName)) {
314
            taskName= ""; //$NON-NLS-1$
315
        } else {
316
            fLastTaskName= taskName;
317
        }
318
        Location location= event.getTask().getLocation();
319
        String fileName= null;
320
        int lineNumber= -1;
321
        try {
322
            fileName= location.getFileName();
323
            lineNumber= location.getLineNumber();
324
        } catch (NoSuchMethodError e) {
325
            //older Ant
326
            fileName= location.toString();
327
        }
328
        if (location.equals(Location.UNKNOWN_LOCATION)) {
329
            fileName= location.toString();
330
            lineNumber= -1;
331
        }
332
        int priority= event.getPriority();
333
        while (line != null) {
334
            message= new StringBuffer(MessageIds.TASK);
335
            message.append(priority);
336
            message.append(',');
337
            message.append(taskName);
338
            message.append(',');
339
            message.append(line.length());
340
            message.append(',');
341
            message.append(line);
342
            message.append(',');
343
            if (!fileName.equals(fLastFileName)) {
344
            	message.append(fileName.length());
345
            	message.append(',');
346
                message.append(fileName);
347
            } 
348
            message.append(',');
349
            message.append(lineNumber);
350
            sendMessage(message.toString());
351
            fLastFileName= fileName;
352
            line= r.readLine();
353
        }
354
    }
355
    
356
    private void marshalTargetMessage(BuildEvent event) {
357
        Target target= event.getTarget();
358
        Location location= AntDebugState.getLocation(target);
359
        
360
        StringBuffer message= new StringBuffer();
361
        message.append(MessageIds.TARGET);
362
        message.append(',');
363
        message.append(target.getName());
364
        message.append(':');
365
        message.append(',');
366
        if (location != null && location != Location.UNKNOWN_LOCATION) {
367
            //if a target has a valid location then we are on an Ant that is 
368
            //new enough to have the accessor methods on Location
369
        	String fileName= location.getFileName();
370
        	message.append(fileName.length());
371
        	message.append(',');
372
            message.append(fileName);
373
            message.append(',');
374
            message.append(location.getLineNumber());
375
        }
376
        sendMessage(message.toString());
377
    }
378
379
    /* (non-Javadoc)
380
     * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
381
     */
382
    public void buildStarted(BuildEvent event) {
383
        establishConnection();
384
        super.buildStarted(event);
385
    }
386
    
387
    public void configure(Map userProperties) {
388
        String portProperty= (String) userProperties.remove("eclipse.connect.port"); //$NON-NLS-1$
389
        
390
        if (portProperty != null) {
391
            fEventPort= Integer.parseInt(portProperty);
392
        }
393
        
394
        fProcessId= (String) userProperties.remove("org.eclipse.ant.core.ANT_PROCESS_ID"); //$NON-NLS-1$
395
    } 
396
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/debug/RemoteAntBreakpoint.java (-73 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger.debug;
12
13
import java.io.File;
14
import org.eclipse.ant.internal.ui.antsupport.logger.util.DebugMessageIds;
15
16
public class RemoteAntBreakpoint {
17
	
18
    private File fFile;
19
	private int fLineNumber;
20
	private String fFileName;
21
	
22
	public RemoteAntBreakpoint(String breakpointRepresentation) {
23
		String[] data= breakpointRepresentation.split(DebugMessageIds.MESSAGE_DELIMITER);
24
		String fileName= data[1];
25
		String lineNumber= data[2];
26
		fFileName= fileName;
27
		fFile= new File(fileName);
28
		fLineNumber= Integer.parseInt(lineNumber);
29
	}
30
31
	public boolean isAt(String fileName, int lineNumber) {
32
		return fLineNumber == lineNumber && fileName != null && fFile.equals(new File(fileName));
33
	}
34
	
35
	public String toMarshallString() {
36
		StringBuffer buffer= new StringBuffer(DebugMessageIds.BREAKPOINT);
37
		buffer.append(DebugMessageIds.MESSAGE_DELIMITER);
38
		buffer.append(fFileName);
39
		buffer.append(DebugMessageIds.MESSAGE_DELIMITER);
40
		buffer.append(fLineNumber);
41
		return buffer.toString();
42
	}
43
	
44
	/* (non-Javadoc)
45
	 * @see java.lang.Object#equals(java.lang.Object)
46
	 */
47
	public boolean equals(Object obj) {
48
		if (!(obj instanceof RemoteAntBreakpoint)) {
49
			return false;
50
		}
51
		RemoteAntBreakpoint other= (RemoteAntBreakpoint) obj;
52
		return other.getLineNumber() == fLineNumber && other.getFile().equals(fFile);
53
	}
54
	
55
	/* (non-Javadoc)
56
	 * @see java.lang.Object#hashCode()
57
	 */
58
	public int hashCode() {
59
		return fFileName.hashCode() + fLineNumber;
60
	}
61
	
62
	public int getLineNumber() {
63
		return fLineNumber;
64
	}
65
66
	public String getFileName() {
67
		return fFileName;
68
	}
69
	
70
	public File getFile() {
71
	    return fFile;
72
	}
73
}
(-)Remote Ant Support/org/eclipse/ant/internal/ui/antsupport/logger/debug/RemoteAntDebugBuildLogger.java (-354 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ant.internal.ui.antsupport.logger.debug;
12
13
import java.io.BufferedReader;
14
import java.io.IOException;
15
import java.io.InputStreamReader;
16
import java.io.PrintWriter;
17
import java.net.ServerSocket;
18
import java.net.Socket;
19
import java.net.SocketTimeoutException;
20
import java.util.ArrayList;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
24
25
import org.apache.tools.ant.BuildEvent;
26
import org.apache.tools.ant.Location;
27
import org.apache.tools.ant.Task;
28
import org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger;
29
import org.eclipse.ant.internal.ui.antsupport.logger.util.AntDebugState;
30
import org.eclipse.ant.internal.ui.antsupport.logger.util.DebugMessageIds;
31
import org.eclipse.ant.internal.ui.antsupport.logger.util.IDebugBuildLogger;
32
33
/**
34
 * Parts adapted from org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
35
 * A build logger that reports via a socket connection.
36
 * See DebugMessageIds and MessageIds for more information about the protocol.
37
 */
38
public class RemoteAntDebugBuildLogger extends RemoteAntBuildLogger implements IDebugBuildLogger {
39
	
40
	private ServerSocket fServerSocket;
41
	private static final int fgServerSocketTimeout= 5000;
42
	private Socket fRequestSocket;
43
	
44
	private PrintWriter fRequestWriter;
45
	
46
	private BufferedReader fRequestReader;
47
	
48
    private boolean fBuildStartedSuspend= true;
49
	
50
	private Task fStepOverTaskInterrupted;
51
	
52
	private List fBreakpoints= null;
53
	
54
	/**
55
	 * Request port to connect to.
56
	 * Used for debug connections
57
	 */
58
	private int fRequestPort= -1;
59
	private AntDebugState fDebugState;
60
61
	/**
62
	 * Reader thread that processes requests from the debug client.
63
	 */
64
	private class ReaderThread extends Thread {
65
		public ReaderThread() {
66
			super("ReaderThread"); //$NON-NLS-1$
67
			setDaemon(true);
68
		}
69
70
		public void run(){
71
			try { 
72
				String message= null; 
73
				while (fRequestReader != null) { 
74
					if ((message= fRequestReader.readLine()) != null) {
75
						
76
						if (message.startsWith(DebugMessageIds.STEP_INTO)){
77
							synchronized(RemoteAntDebugBuildLogger.this) {
78
								fDebugState.setStepIntoSuspend(true);
79
								fDebugState.setStepIntoTask(fDebugState.getCurrentTask());
80
								RemoteAntDebugBuildLogger.this.notifyAll();
81
							}
82
						} if (message.startsWith(DebugMessageIds.STEP_OVER)){
83
							synchronized(RemoteAntDebugBuildLogger.this) {
84
								fDebugState.stepOver();
85
							}
86
						} else if (message.startsWith(DebugMessageIds.SUSPEND)) {
87
							synchronized(RemoteAntDebugBuildLogger.this) {
88
								fDebugState.setStepIntoTask(null);
89
								fDebugState.setStepOverTask(null);
90
								fStepOverTaskInterrupted= null;
91
								fDebugState.setClientSuspend(true);
92
							}
93
						} else if (message.startsWith(DebugMessageIds.RESUME)) {
94
							synchronized(RemoteAntDebugBuildLogger.this) {
95
								fDebugState.setStepIntoTask(null);
96
								fDebugState.setStepOverTask(null);
97
								fStepOverTaskInterrupted= null;
98
								RemoteAntDebugBuildLogger.this.notifyAll();
99
							}
100
						} else if (message.startsWith(DebugMessageIds.TERMINATE)) {
101
						    sendRequestResponse(DebugMessageIds.TERMINATED);
102
							shutDown();
103
						} else if (message.startsWith(DebugMessageIds.STACK)) {
104
							marshallStack();
105
						} else if (message.startsWith(DebugMessageIds.ADD_BREAKPOINT)) {
106
							addBreakpoint(message);
107
						} else if (message.startsWith(DebugMessageIds.REMOVE_BREAKPOINT)) {
108
							removeBreakpoint(message);
109
						}  else if (message.startsWith(DebugMessageIds.PROPERTIES)) {
110
							marshallProperties();
111
						}
112
					}
113
				} 
114
			} catch (Exception e) {
115
				RemoteAntDebugBuildLogger.this.shutDown();
116
			}
117
		}
118
	}
119
	
120
	private void requestConnect() {
121
		if (fDebugMode) {
122
			System.out.println("RemoteAntDebugBuildLogger: trying to connect" + fHost + ":" + fRequestPort); //$NON-NLS-1$ //$NON-NLS-2$
123
		}
124
		
125
		try{
126
			fServerSocket.setSoTimeout(fgServerSocketTimeout);
127
			fRequestSocket= fServerSocket.accept();
128
			fRequestWriter= new PrintWriter(fRequestSocket.getOutputStream(), true);
129
			fRequestReader = new BufferedReader(new InputStreamReader(fRequestSocket.getInputStream()));
130
			
131
			ReaderThread readerThread= new ReaderThread();
132
			readerThread.setDaemon(true);
133
			readerThread.start();
134
			return;
135
		} catch(SocketTimeoutException e){
136
		} catch(IOException e) {
137
		}
138
		shutDown();
139
	}
140
	
141
	/* (non-Javadoc)
142
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger#shutDown()
143
	 */
144
	protected void shutDown() {
145
		if (fRequestWriter != null) {
146
			fRequestWriter.close();
147
			fRequestWriter= null;
148
		}
149
		
150
		if (fRequestReader != null) {
151
			try {
152
				fRequestReader.close();
153
			} catch (IOException e) {
154
			}
155
			fRequestReader= null;
156
		}
157
		
158
		if (fRequestSocket != null) {
159
			try {
160
				fRequestSocket.close();	
161
			} catch(IOException e) {
162
			}
163
		}
164
		fRequestSocket= null;
165
		
166
		super.shutDown();
167
	}
168
	
169
	/* (non-Javadoc)
170
	 * @see org.apache.tools.ant.BuildListener#buildStarted(org.apache.tools.ant.BuildEvent)
171
	 */
172
	public synchronized void buildStarted(BuildEvent event) {
173
		fDebugState= new AntDebugState(this);
174
		super.buildStarted(event);
175
		marshalMessage(-1, DebugMessageIds.BUILD_STARTED);
176
		if (fRequestPort != -1) {
177
			try {
178
				fServerSocket= new ServerSocket(fRequestPort);
179
			} catch (IOException ioe) {
180
				shutDown();
181
			}
182
			requestConnect();
183
		} else {
184
			shutDown();
185
		}
186
        fDebugState.buildStarted();
187
		fDebugState.setShouldSuspend(true);
188
		waitIfSuspended();
189
	}
190
191
	/* (non-Javadoc)
192
	 * @see org.apache.tools.ant.BuildListener#taskStarted(org.apache.tools.ant.BuildEvent)
193
	 */
194
	public void taskStarted(BuildEvent event) {
195
        super.taskStarted(event);
196
		fDebugState.taskStarted(event);
197
	}
198
	
199
	/* (non-Javadoc)
200
	 * @see org.apache.tools.ant.BuildListener#taskFinished(org.apache.tools.ant.BuildEvent)
201
	 */
202
	public synchronized void taskFinished(BuildEvent event) {
203
		super.taskFinished(event);
204
		fDebugState.taskFinished();
205
	}
206
	
207
	/* (non-Javadoc)
208
	 * @see org.eclipse.ant.internal.ui.antsupport.logger.util.IDebugBuildLogger#waitIfSuspended()
209
	 */
210
	public synchronized void waitIfSuspended() {
211
		String detail= null;
212
		boolean shouldSuspend= true;
213
		RemoteAntBreakpoint breakpoint= breakpointAtLineNumber(fDebugState.getBreakpointLocation());
214
		if (breakpoint != null) {
215
			detail= breakpoint.toMarshallString();
216
			fDebugState.setShouldSuspend(false);
217
			if (fDebugState.getStepOverTask() != null) {
218
				fStepOverTaskInterrupted= fDebugState.getStepOverTask();
219
				fDebugState.setStepOverTask(null);
220
			}
221
		} else if (fDebugState.getCurrentTask() != null) {
222
	        if (fDebugState.isStepIntoSuspend()) {
223
	            detail= DebugMessageIds.STEP;
224
				fDebugState.setStepIntoSuspend(false);
225
	        } else if ((fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fDebugState.getStepOverTask()) || fDebugState.shouldSuspend()) {
226
	        	//suspend as a step over has finished
227
	        	detail= DebugMessageIds.STEP;
228
				fDebugState.setStepOverTask(null);
229
				fDebugState.setShouldSuspend(false);
230
	        } else if (fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fDebugState.getStepIntoTask()) {
231
	        	//suspend as a task that was stepped into has finally completed
232
	        	 detail= DebugMessageIds.STEP;
233
	        	 fDebugState.setStepIntoTask(null);
234
	        } else if (fDebugState.getLastTaskFinished() != null && fDebugState.getLastTaskFinished() == fStepOverTaskInterrupted) {
235
	        	//suspend as a task that was stepped over but hit a breakpoint has finally completed
236
	        	 detail= DebugMessageIds.STEP;
237
	        	 fStepOverTaskInterrupted= null;
238
	        } else if (fDebugState.isClientSuspend()) {
239
	            detail= DebugMessageIds.CLIENT_REQUEST;
240
				fDebugState.setClientSuspend(false);
241
	        } else {
242
	            shouldSuspend= false;
243
	        }
244
	    } else if (fDebugState.shouldSuspend() && fBuildStartedSuspend) {
245
            fBuildStartedSuspend= false;
246
			fDebugState.setShouldSuspend(false);
247
	    } else {
248
			shouldSuspend= false;
249
	    }
250
		
251
		if (shouldSuspend) {
252
			if (detail != null) {
253
				StringBuffer message= new StringBuffer(DebugMessageIds.SUSPENDED);
254
				message.append(detail);
255
				sendRequestResponse(message.toString());
256
			}
257
			 try {
258
				 wait();
259
                 shouldSuspend= false;
260
			 } catch (InterruptedException e) {
261
			 }
262
		}
263
	}
264
265
	private RemoteAntBreakpoint breakpointAtLineNumber(Location location) {
266
		if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
267
			return null;
268
		}
269
		String fileName= fDebugState.getFileName(location);
270
		int lineNumber= fDebugState.getLineNumber(location);
271
		for (int i = 0; i < fBreakpoints.size(); i++) {
272
			RemoteAntBreakpoint breakpoint = (RemoteAntBreakpoint) fBreakpoints.get(i);
273
			if (breakpoint.isAt(fileName, lineNumber)) {
274
				return breakpoint;
275
			}
276
		}
277
		return null;
278
	}
279
280
	private void sendRequestResponse(String message) {
281
		if (fRequestWriter == null) {
282
			return;
283
		}
284
		
285
		fRequestWriter.println(message);
286
	}
287
	
288
	protected void marshallStack() {
289
	    StringBuffer stackRepresentation= new StringBuffer();
290
	    fDebugState.marshalStack(stackRepresentation);
291
	    sendRequestResponse(stackRepresentation.toString());
292
	}
293
	
294
	protected void marshallProperties() {
295
	    StringBuffer propertiesRepresentation= new StringBuffer();
296
		fDebugState.marshallProperties(propertiesRepresentation, true);
297
	    sendRequestResponse(propertiesRepresentation.toString());
298
	}
299
	
300
	protected void addBreakpoint(String breakpointRepresentation) {
301
		if (fBreakpoints == null) {
302
			fBreakpoints= new ArrayList();
303
		}
304
		RemoteAntBreakpoint newBreakpoint= new RemoteAntBreakpoint(breakpointRepresentation);
305
		if (!fBreakpoints.contains(newBreakpoint)) {
306
			fBreakpoints.add(newBreakpoint);	
307
		}
308
	}
309
	
310
	protected void removeBreakpoint(String breakpointRepresentation) {
311
		if (fBreakpoints == null) {
312
			return;
313
		} 
314
		RemoteAntBreakpoint equivalentBreakpoint= new RemoteAntBreakpoint(breakpointRepresentation);
315
		for (Iterator iter = fBreakpoints.iterator(); iter.hasNext(); ) {
316
			RemoteAntBreakpoint breakpoint = (RemoteAntBreakpoint) iter.next();
317
			if (breakpoint.equals(equivalentBreakpoint)) {
318
				iter.remove();
319
				return;
320
			}
321
		}
322
	}
323
324
	/* (non-Javadoc)
325
	 * @see org.apache.tools.ant.BuildListener#targetStarted(org.apache.tools.ant.BuildEvent)
326
	 */
327
	public void targetStarted(BuildEvent event) {
328
		fDebugState.targetStarted(event);
329
		if (!fSentProcessId) {
330
			establishConnection();
331
		}
332
		waitIfSuspended();
333
		super.targetStarted(event);
334
	}
335
    
336
    /* (non-Javadoc)
337
     * @see org.apache.tools.ant.BuildListener#targetFinished(org.apache.tools.ant.BuildEvent)
338
     */
339
    public void targetFinished(BuildEvent event) {
340
        super.targetFinished(event);
341
		fDebugState.setTargetExecuting(null);
342
    }   
343
    
344
    /* (non-Javadoc)
345
     * @see org.eclipse.ant.internal.ui.antsupport.logger.RemoteAntBuildLogger#configure(java.util.Map)
346
     */
347
    public void configure(Map userProperties) {
348
       super.configure(userProperties);
349
       String requestPortProperty= (String) userProperties.remove("eclipse.connect.request_port"); //$NON-NLS-1$
350
        if (requestPortProperty != null) {
351
            fRequestPort= Integer.parseInt(requestPortProperty);
352
        }
353
    }
354
}
(-)buildfiles/buildRemoteExtraJAR.xml (-2 / +2 lines)
Lines 30-40 Link Here
30
			<classpath>
30
			<classpath>
31
				<dirset dir="${basedir}/..">
31
				<dirset dir="${basedir}/..">
32
					<include name="org.eclipse.swt*/bin"/>
32
					<include name="org.eclipse.swt*/bin"/>
33
					<include name="org.eclipse.ant.ui/common_ant_support_bin"/>
33
					<include name="org.eclipse.ant.launching/common_bin"/>
34
				</dirset>
34
				</dirset>
35
				<fileset dir="${eclipse.home}">
35
				<fileset dir="${eclipse.home}">
36
					<include name="plugins/org.eclipse.swt*.jar"/>
36
					<include name="plugins/org.eclipse.swt*.jar"/>
37
					<include name="plugins/org.eclipse.osgi*.jar"/>
37
					<include name="plugins/org.eclipse.osgi*.jar"/>
38
					<include name="plugins/org.eclipse.ant.launching*.jar"/>
38
				</fileset>
39
				</fileset>
39
			</classpath>
40
			</classpath>
40
			<src path="Remote Ant Support/"/>
41
			<src path="Remote Ant Support/"/>
Lines 42-48 Link Here
42
		<!-- copy necessary resources -->
43
		<!-- copy necessary resources -->
43
		<copy todir="${destdir}">
44
		<copy todir="${destdir}">
44
			<fileset dir="Remote Ant Support/" excludes="**/*.java"/>
45
			<fileset dir="Remote Ant Support/" excludes="**/*.java"/>
45
			<fileset dir="${basedir}/common_ant_support_bin"/>
46
		</copy>
46
		</copy>
47
		<mkdir dir="${build.result.folder}/lib"/>
47
		<mkdir dir="${build.result.folder}/lib"/>
48
		<jar destfile="${build.result.folder}/lib/remoteAnt.jar" basedir="${destdir}"/>
48
		<jar destfile="${build.result.folder}/lib/remoteAnt.jar" basedir="${destdir}"/>
(-)plugin.properties (-8 lines)
Lines 12-28 Link Here
12
pluginName = Ant UI
12
pluginName = Ant UI
13
providerName = Eclipse.org
13
providerName = Eclipse.org
14
14
15
AntBuild = Ant Build
16
AntBuilder.name=Ant Builder
17
AntLaunchShortcut.label = Ant Build
15
AntLaunchShortcut.label = Ant Build
18
AntLaunchShortcutWithDialog.label = Ant Build...
16
AntLaunchShortcutWithDialog.label = Ant Build...
19
antLaunchConfigurationTabGroup.description=Run an Ant build file.
17
antLaunchConfigurationTabGroup.description=Run an Ant build file.
20
antBuilderLaunchConfigurationTabGroup.description=Create a configuration that will run an Ant build file during a build.
18
antBuilderLaunchConfigurationTabGroup.description=Create a configuration that will run an Ant build file during a build.
21
19
22
AntLaunchDelegate.name=Eclipse Ant Launcher
23
AntLaunchDelegate.description=The Eclipse Ant Launcher supports running and debugging Ant build files.
24
AntBuilderLaunchDelegate.name= Eclipse Ant Builder Launcher
25
AntBuilderLaunchDelegate.description=The Eclipse Ant Builder Launcher supports running Ant build files.
26
AntBuild...Shortcut.description=Launches an Ant build and allows it to be configured 
20
AntBuild...Shortcut.description=Launches an Ant build and allows it to be configured 
27
AntBuildShortcut.description=Launches an Ant build with default settings
21
AntBuildShortcut.description=Launches an Ant build with default settings
28
22
Lines 106-110 Link Here
106
AntElementHyperlinkDetector.description= A hyperlink detector for Ant buildfile elements
100
AntElementHyperlinkDetector.description= A hyperlink detector for Ant buildfile elements
107
AntElementHyperlinkDetector.label= Ant Element
101
AntElementHyperlinkDetector.label= Ant Element
108
AntEditorHyperlinkTarget.name= Ant Editor
102
AntEditorHyperlinkTarget.name= Ant Editor
109
110
AntLineBreakpoint.name = Ant Line Breakpoint
(-)plugin.xml (-68 / +2 lines)
Lines 24-71 Link Here
24
      </editor>
24
      </editor>
25
   </extension>
25
   </extension>
26
   <extension
26
   <extension
27
         point="org.eclipse.debug.core.launchConfigurationTypes">
28
      <launchConfigurationType
29
            category="org.eclipse.ui.externaltools"
30
            delegate="org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate"
31
            delegateDescription="%AntLaunchDelegate.description"
32
            delegateName="%AntLaunchDelegate.name"
33
            id="org.eclipse.ant.AntLaunchConfigurationType"
34
            migrationDelegate="org.eclipse.ant.internal.ui.launchConfigurations.AntMigrationDelegate"
35
            modes="run, debug"
36
            name="%AntBuild"
37
            sourceLocatorId="org.eclipse.ant.ui.debug.sourceLookupDirector"
38
            sourcePathComputerId="org.eclipse.ant.ui.debug.sourcePathComputer">
39
      </launchConfigurationType>
40
      <launchConfigurationType
41
            category="org.eclipse.ui.externaltools.builder"
42
            delegate="org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchDelegate"
43
            delegateDescription="%AntBuilderLaunchDelegate.description"
44
            delegateName="%AntBuilderLaunchDelegate.name"
45
            id="org.eclipse.ant.AntBuilderLaunchConfigurationType"
46
            modes="run"
47
            name="%AntBuilder.name">
48
      </launchConfigurationType>
49
   </extension>
50
   <extension
51
         point="org.eclipse.jdt.launching.classpathProviders">
52
      <classpathProvider
53
            class="org.eclipse.ant.internal.ui.launchConfigurations.AntClasspathProvider"
54
            id="org.eclipse.ant.ui.AntClasspathProvider">
55
      </classpathProvider>
56
   </extension>
57
   <extension
58
         point="org.eclipse.jdt.launching.runtimeClasspathEntries">
59
      <runtimeClasspathEntry
60
            class="org.eclipse.ant.internal.ui.launchConfigurations.AntHomeClasspathEntry"
61
            id="org.eclipse.ant.ui.classpathentry.antHome">
62
      </runtimeClasspathEntry>
63
      <runtimeClasspathEntry
64
            class="org.eclipse.ant.internal.ui.launchConfigurations.ContributedClasspathEntriesEntry"
65
            id="org.eclipse.ant.ui.classpathentry.extraClasspathEntries">
66
      </runtimeClasspathEntry>
67
   </extension>
68
   <extension
69
         point="org.eclipse.ui.views">
27
         point="org.eclipse.ui.views">
70
      <category
28
      <category
71
            name="%CategoryView.antViews"
29
            name="%CategoryView.antViews"
Lines 553-565 Link Here
553
            id="org.eclipse.ant.ui.statusHandler.runAntInit">
511
            id="org.eclipse.ant.ui.statusHandler.runAntInit">
554
      </statusHandler>
512
      </statusHandler>
555
   </extension>
513
   </extension>
556
   <extension
557
         point="org.eclipse.debug.core.processFactories">
558
      <processFactory
559
            class="org.eclipse.ant.internal.ui.launchConfigurations.RemoteAntProcessFactory"
560
            id="org.eclipse.ant.ui.remoteAntProcessFactory">
561
      </processFactory>
562
   </extension>
563
   
514
   
564
   <extension
515
   <extension
565
         point="org.eclipse.ui.editors.templates">
516
         point="org.eclipse.ui.editors.templates">
Lines 648-661 Link Here
648
         point="org.eclipse.debug.core.sourceLocators">
599
         point="org.eclipse.debug.core.sourceLocators">
649
      <sourceLocator
600
      <sourceLocator
650
            name="%antSourceLookupDirector.name"
601
            name="%antSourceLookupDirector.name"
651
            class="org.eclipse.ant.internal.ui.debug.AntSourceLookupDirector"
602
            class="org.eclipse.ant.internal.launching.debug.AntSourceLookupDirector"
652
            id="org.eclipse.ant.ui.debug.sourceLookupDirector">
603
            id="org.eclipse.ant.ui.debug.sourceLookupDirector">
653
      </sourceLocator>
604
      </sourceLocator>
654
   </extension>
605
   </extension>
655
   <extension
606
   <extension
656
         point="org.eclipse.debug.core.sourcePathComputers">
607
         point="org.eclipse.debug.core.sourcePathComputers">
657
      <sourcePathComputer
608
      <sourcePathComputer
658
            class="org.eclipse.ant.internal.ui.debug.AntSourcePathComputerDelegate"
609
            class="org.eclipse.ant.internal.launching.debug.AntSourcePathComputerDelegate"
659
            id="org.eclipse.ant.ui.debug.sourcePathComputer">
610
            id="org.eclipse.ant.ui.debug.sourcePathComputer">
660
      </sourcePathComputer>
611
      </sourcePathComputer>
661
   </extension>
612
   </extension>
Lines 668-690 Link Here
668
   </extension>
619
   </extension>
669
   
620
   
670
    <extension
621
    <extension
671
         point="org.eclipse.debug.core.breakpoints">
672
      <breakpoint
673
            markerType="org.eclipse.ant.ui.antLineBreakpointMarker"
674
            class="org.eclipse.ant.internal.ui.debug.model.AntLineBreakpoint"
675
            id="org.eclipse.ant.ui.lineBreakpoint"
676
            name="%antBreakpointGroupName">
677
      </breakpoint>
678
   </extension>
679
   <extension
680
         id="antLineBreakpointMarker"
681
         name="%AntLineBreakpoint.name"
682
         point="org.eclipse.core.resources.markers">
683
      <super type="org.eclipse.debug.core.lineBreakpointMarker"/>
684
      <persistent value="true"/>
685
   </extension>
686
   
687
    <extension
688
         point="org.eclipse.ui.editorActions">
622
         point="org.eclipse.ui.editorActions">
689
      <editorContribution
623
      <editorContribution
690
            targetID="org.eclipse.ant.ui.internal.editor.AntEditor"
624
            targetID="org.eclipse.ant.ui.internal.editor.AntEditor"
(-).settings/org.eclipse.pde.prefs (+25 lines)
Added Link Here
1
#Wed Oct 07 13:13:28 CDT 2009
2
compilers.f.unresolved-features=1
3
compilers.f.unresolved-plugins=1
4
compilers.incompatible-environment=1
5
compilers.p.build=1
6
compilers.p.deprecated=1
7
compilers.p.discouraged-class=1
8
compilers.p.internal=1
9
compilers.p.missing-packages=1
10
compilers.p.missing-version-export-package=2
11
compilers.p.missing-version-import-package=2
12
compilers.p.missing-version-require-bundle=1
13
compilers.p.no-required-att=0
14
compilers.p.not-externalized-att=1
15
compilers.p.unknown-attribute=1
16
compilers.p.unknown-class=1
17
compilers.p.unknown-element=1
18
compilers.p.unknown-identifier=1
19
compilers.p.unknown-resource=1
20
compilers.p.unresolved-ex-points=0
21
compilers.p.unresolved-import=0
22
compilers.s.create-docs=false
23
compilers.s.doc-folder=doc
24
compilers.s.open-tags=1
25
eclipse.preferences.version=1
(-)META-INF/MANIFEST.MF (-3 / +7 lines)
Lines 1-13 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.core.externaltools
4
Bundle-Localization: plugin
5
Bundle-SymbolicName: org.eclipse.core.externaltools;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.eclipse.core.internal.externaltools.ExternalToolsCore
7
Bundle-Activator: org.eclipse.core.externaltools.internal.ExternalToolsCore
7
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
8
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
8
 org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)",
9
 org.eclipse.debug.core;bundle-version="[3.6.0,4.0.0)",
9
 org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)"
10
 org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)"
10
Bundle-RequiredExecutionEnvironment: J2SE-1.4
11
Bundle-RequiredExecutionEnvironment: J2SE-1.4
11
Bundle-ActivationPolicy: lazy
12
Bundle-ActivationPolicy: lazy
12
Bundle-Vendor: %providerName
13
Bundle-Vendor: %providerName
13
Export-Package: org.eclipse.core.internal.externaltools;x-internal:=true
14
Export-Package: org.eclipse.core.externaltools.internal;x-friends:="org.eclipse.ant.launching,org.eclipse.ui.externaltools",
15
 org.eclipse.core.externaltools.internal.launchConfigurations;x-friends:="org.eclipse.ant.launching,org.eclipse.ui.externaltools",
16
 org.eclipse.core.externaltools.internal.model;x-friends:="org.eclipse.ant.launching,org.eclipse.ui.externaltools",
17
 org.eclipse.core.externaltools.internal.registry;x-friends:="org.eclipse.ui.externaltools"
(-)build.properties (-1 / +3 lines)
Lines 1-4 Link Here
1
source.. = src/
1
source.. = src/
2
output.. = bin/
2
output.. = bin/
3
bin.includes = META-INF/,\
3
bin.includes = META-INF/,\
4
               .
4
               .,\
5
               plugin.xml,\
6
               plugin.properties
(-)plugin.properties (-1 / +4 lines)
Lines 10-13 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
pluginName=External Tools Headless Support
12
pluginName=External Tools Headless Support
13
providerName=Eclipse.org
13
providerName=Eclipse.org
14
15
Program.externalTools = Program
16
Builder.externalTools = Integrated External Tool Builder
(-)plugin.xml (+32 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
 <extension
5
         point="org.eclipse.debug.core.launchConfigurationTypes">
6
      <launchConfigurationType
7
            name="%Program.externalTools"
8
            delegate="org.eclipse.core.externaltools.internal.launchConfigurations.ProgramLaunchDelegate"
9
            category="org.eclipse.ui.externaltools"
10
            modes="run"
11
            id="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
12
      </launchConfigurationType>
13
      <launchConfigurationType
14
            name="%Program.externalTools"
15
            delegate="org.eclipse.core.externaltools.internal.launchConfigurations.ProgramLaunchDelegate"
16
            category="org.eclipse.ui.externaltools.builder"
17
            modes="run"
18
            id="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
19
      </launchConfigurationType>
20
   </extension>
21
   <extension
22
         id="org.eclipse.ui.externaltools.ExternalToolBuilder"
23
         name="%Builder.externalTools"
24
         point="org.eclipse.core.resources.builders">
25
     <builder
26
      	isConfigurable= "true">
27
         <run
28
               class="org.eclipse.core.externaltools.internal.model.ExternalToolBuilder">
29
         </run>
30
      </builder>
31
   </extension>   
32
</plugin>
(-)src/org/eclipse/core/externaltools/internal/ExternalToolsCore.java (+118 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.externaltools.internal;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Plugin;
16
import org.eclipse.core.runtime.Status;
17
import org.osgi.framework.BundleContext;
18
19
/**
20
 * Controls the plug-in life cycle
21
 */
22
public class ExternalToolsCore extends Plugin {
23
24
	// The plug-in ID
25
	public static final String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$
26
	
27
	private static final String EMPTY_STRING= ""; //$NON-NLS-1$
28
	
29
	/**
30
	 * Status code indicating an unexpected internal error.
31
	 * @since 2.1
32
	 */
33
	public static final int INTERNAL_ERROR = 120;	
34
35
	// The shared instance
36
	private static ExternalToolsCore plugin;
37
	
38
	/**
39
	 * The constructor
40
	 */
41
	public ExternalToolsCore() {
42
	}
43
44
	/*
45
	 * (non-Javadoc)
46
	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
47
	 */
48
	public void start(BundleContext context) throws Exception {
49
		super.start(context);
50
		plugin = this;
51
	}
52
53
	/*
54
	 * (non-Javadoc)
55
	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
56
	 */
57
	public void stop(BundleContext context) throws Exception {
58
		plugin = null;
59
		super.stop(context);
60
	}
61
62
	/**
63
	 * Returns the shared instance
64
	 *
65
	 * @return the shared instance
66
	 */
67
	public static ExternalToolsCore getDefault() {
68
		return plugin;
69
	}
70
	
71
	/**
72
	 * Logs the specified throwable with this plug-in's log.
73
	 * 
74
	 * @param t throwable to log 
75
	 */
76
	public static void log(Throwable t) {
77
		IStatus status= new Status(IStatus.ERROR, PLUGIN_ID, INTERNAL_ERROR, "Error logged from Ant UI: ", t); //$NON-NLS-1$
78
		log(status);
79
	}
80
81
	/**
82
	 * Logs the specified status with this plug-in's log.
83
	 * 
84
	 * @param status status 
85
	 */
86
	public static void log(IStatus status) {
87
		getDefault().getLog().log(status);
88
	}
89
	
90
	/**
91
	 * Writes the message to the plug-in's log
92
	 * 
93
	 * @param message the text to write to the log
94
	 */
95
	public static void log(String message, Throwable exception) {
96
		IStatus status = newErrorStatus(message, exception);
97
		log(status);
98
	}
99
	
100
	/**
101
	 * Returns a new <code>IStatus</code> for this plug-in
102
	 */
103
	public static IStatus newErrorStatus(String message, Throwable exception) {
104
		if (message == null) {
105
			message= EMPTY_STRING; 
106
		}		
107
		return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception);
108
	}
109
	
110
	/**
111
	 * Returns a new <code>CoreException</code> for this plug-in
112
	 */
113
	public static CoreException newError(String message, Throwable exception) {
114
		return new CoreException(new Status(IStatus.ERROR,
115
				IExternalToolConstants.PLUGIN_ID, 0, message, exception));
116
	}
117
118
}
(-)src/org/eclipse/core/externaltools/internal/IExternalToolConstants.java (+243 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     dakshinamurthy.karra@gmail.com - bug 165371
11
 *******************************************************************************/
12
13
package org.eclipse.core.externaltools.internal;
14
/**
15
 * Defines the constants available for client use.
16
 * <p>
17
 * This interface is not intended to be extended or implemented by clients.
18
 * </p>
19
 */
20
public interface IExternalToolConstants {
21
	/**
22
	 * Plug-in identifier for external tools UI (value <code>org.eclipse.ui.externaltools</code>).
23
	 */
24
	public static final String UI_PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$;
25
	
26
	/**
27
	 * Plug-in identifier for external tools core (value <code>org.eclipse.core.externaltools</code>).
28
	 */
29
	public static final String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$;
30
31
	// ------- Extensions Points -------
32
	/**
33
	 * Extension point to declare the launch configuration type that should be
34
	 * created when duplicating an existing configuration as a project builder.
35
	 */
36
	public static final String EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS = "configurationDuplicationMaps"; //$NON-NLS-1$
37
	// ------- Refresh Variables -------
38
	/**
39
	 * Variable that expands to the workspace root object (value <code>workspace</code>).
40
	 */
41
	public static final String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$
42
	/**
43
	 * Variable that expands to the project resource (value <code>project</code>).
44
	 */
45
	public static final String VAR_PROJECT = "project"; //$NON-NLS-1$
46
	/**
47
	 * Variable that expands to the container resource (value <code>container</code>).
48
	 */
49
	public static final String VAR_CONTAINER = "container"; //$NON-NLS-1$
50
	/**
51
	 * Variable that expands to a resource (value <code>resource</code>).
52
	 */
53
	public static final String VAR_RESOURCE = "resource"; //$NON-NLS-1$
54
	/**
55
	 * Variable that expands to the working set object (value <code>working_set</code>).
56
	 */
57
	public static final String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$
58
	// ------- Tool Types -------
59
	/**
60
	 * External tool type for programs such as executables, batch files, 
61
	 * shell scripts, etc (value <code>programType</code>).
62
	 */
63
	public static final String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$;
64
65
	// ------- Build Types -------
66
	/**
67
	 * Build type indicating an incremental project build request for
68
	 * the external tool running as a builder (value <code>incremental</code>).
69
	 */
70
	public static final String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$
71
72
	/**
73
	 * Build type indicating a full project build request for
74
	 * the external tool running as a builder (value <code>full</code>).
75
	 */
76
	public static final String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$
77
78
	/**
79
	 * Build type indicating an automatic project build request for
80
	 * the external tool running as a builder (value <code>auto</code>).
81
	 */
82
	public static final String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$
83
	
84
	/**
85
	 * Build type indicating a clean project build request for
86
	 * the external tool running as a builder (value <code>clean</code>).
87
	 */
88
	public static final String BUILD_TYPE_CLEAN = "clean"; //$NON-NLS-1$
89
90
	/**
91
	 * Build type indicating no project build request for
92
	 * the external tool running as a builder (value <code>none</code>).
93
	 */
94
	public static final String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$
95
96
	// ------- Images -------
97
98
	/**
99
	 * Main tab image.
100
	 */
101
	public static final String IMG_TAB_MAIN = UI_PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$
102
103
	/**
104
	 * Build tab image
105
	 */
106
	public static final String IMG_TAB_BUILD = UI_PLUGIN_ID + ".IMG_TAB_BUILD"; //$NON-NLS-1$
107
108
	// ------- Launch configuration types --------
109
	/**
110
	 * Program launch configuration type identifier.
111
	 */
112
	public static final String ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$
113
	
114
	/**
115
	 * Program builder launch configuration type identifier. Program project
116
	 * builders are of this type.
117
	 */
118
	public static final String ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"; //$NON-NLS-1$	
119
	
120
	// ------- Launch configuration category --------
121
	/**
122
	 * Identifier for external tools launch configuration category. Launch
123
	 * configuration types for external tools that appear in the external tools
124
	 * launch configuration dialog should belong to this category.
125
	 */
126
	public static final String ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools"; //$NON-NLS-1$
127
	/**
128
	 * Identifier for external tools launch configuration builders category.
129
	 * Launch configuration types that can be added as project builders should
130
	 * belong to this category.
131
	 */
132
	public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools.builder"; //$NON-NLS-1$
133
134
	// ------- Launch configuration groups --------
135
	/**
136
	 * Identifier for external tools launch configuration group. The external
137
	 * tools launch configuration group corresponds to the external tools
138
	 * category in run mode.
139
	 */
140
	public static final String ID_EXTERNAL_TOOLS_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$
141
	/**
142
	 * Identifier for external tools launch configuration group
143
	 */
144
	public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup.builder"; //$NON-NLS-1$
145
146
	// ------- Common External Tool Launch Configuration Attributes -------
147
148
	/**
149
	 * Boolean attribute indicating if external tool output should be captured.
150
	 * Default value is <code>false</code>.
151
	 * @deprecated since 3.1 Replaced by <code>org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT</code>
152
	 */
153
	public static final String ATTR_CAPTURE_OUTPUT = UI_PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$
154
	/**
155
	 * String attribute identifying the location of an external. Default value
156
	 * is <code>null</code>. Encoding is tool specific.
157
	 */
158
	public static final String ATTR_LOCATION = UI_PLUGIN_ID + ".ATTR_LOCATION"; //$NON-NLS-1$
159
160
	/**
161
	 * Boolean attribute indicating if the user should be prompted for
162
	 * arguments before running a tool. Default value is <code>false</code>.
163
	 * THIS ATTRIBUTE IS NOT USED.
164
	 */
165
	public static final String ATTR_PROMPT_FOR_ARGUMENTS = UI_PLUGIN_ID + ".ATTR_PROMPT_FOR_ARGUMENTS"; //$NON-NLS-1$
166
	
167
	/**
168
	 * String attribute identifying the scope of resources that should trigger an 
169
	 * external tool to run. Default value is <code>null</code>
170
	 * indicating that the builder will be triggered for all changes.
171
	 */
172
	public static final String ATTR_BUILDER_SCOPE = UI_PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
173
		
174
	/**
175
	 * String attribute containing an array of build kinds for which an
176
	 * external tool builder should be run.
177
	 */
178
	public static final String ATTR_RUN_BUILD_KINDS = UI_PLUGIN_ID + ".ATTR_RUN_BUILD_KINDS"; //$NON-NLS-1$
179
	
180
	/**
181
	 * Boolean attribute indicating if the console should be shown on external
182
	 * tool output. Default value is <code>false</code>.
183
	 */
184
	public static final String ATTR_SHOW_CONSOLE = UI_PLUGIN_ID + ".ATTR_SHOW_CONSOLE"; //$NON-NLS-1$
185
186
	/**
187
	 * String attribute containing the arguments that should be passed to the
188
	 * tool. Default value is <code>null</code>, and encoding is tool specific.
189
	 */
190
	public static final String ATTR_TOOL_ARGUMENTS = UI_PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$
191
192
	/**
193
	 * String attribute identifying the working directory of an external tool.
194
	 * Default value is <code>null</code>, which indicates a default working
195
	 * directory, which is tool specific.
196
	 */
197
	public static final String ATTR_WORKING_DIRECTORY = UI_PLUGIN_ID + ".ATTR_WORKING_DIRECTORY"; //$NON-NLS-1$
198
	
199
	/**
200
	 * String attribute identifying whether an external tool builder configuration
201
	 * is enabled. The default value is <code>true</code>, which indicates
202
	 * that the configuration will be executed as appropriate by the builder.
203
	 */
204
	public static final String ATTR_BUILDER_ENABLED = UI_PLUGIN_ID + ".ATTR_BUILDER_ENABLED"; //$NON-NLS-1$
205
	
206
	/**
207
	 * Boolean attribute identifying whether an external tool launcher should execute
208
	 * synchronously (value <code>false</code>) or asynchronously (value <code>true</code>).
209
	 * Default value is 
210
	 */
211
	public static final String ATTR_LAUNCH_IN_BACKGROUND = "org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND"; //$NON-NLS-1$
212
	
213
	/**
214
	 * Status code indicating an unexpected internal error.
215
	 */
216
	public static final int ERR_INTERNAL_ERROR = 150;
217
218
	/**
219
	 * String attribute identifying a non-external tool builder launch configuration that is disabled
220
	 * The value is the name of the disabled builder.
221
	 */
222
	public static final String ATTR_DISABLED_BUILDER = UI_PLUGIN_ID + ".ATTR_DISABLED_BUILDER";		 //$NON-NLS-1$
223
	
224
	/**
225
	 * boolean attribute identifying that an external tool builder has been configured for triggering
226
	 * using the <code>ICommand.setBuilding(int)</code> mechanism
227
	 * @since 3.1
228
	 */
229
	public static final String ATTR_TRIGGERS_CONFIGURED = UI_PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED";		 //$NON-NLS-1$
230
231
	/**
232
	 * String attribute identifying the build scope for a launch configuration.
233
	 * <code>null</code> indicates the default workspace build.
234
	 */
235
	public static final String ATTR_BUILD_SCOPE = UI_PLUGIN_ID + ".ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE"; //$NON-NLS-1$
236
237
	/**
238
	 * Attribute identifier specifying whether referenced projects should be 
239
	 * considered when computing the projects to build. Default value is
240
	 * <code>true</code>.
241
	 */
242
	public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = UI_PLUGIN_ID + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
243
}
(-)src/org/eclipse/core/externaltools/internal/launchConfigurations/BackgroundResourceRefresher.java (+89 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.externaltools.internal.launchConfigurations;
12
13
14
import org.eclipse.core.externaltools.internal.ExternalToolsCore;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.jobs.Job;
20
import org.eclipse.debug.core.DebugEvent;
21
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.IDebugEventSetListener;
23
import org.eclipse.debug.core.ILaunchConfiguration;
24
import org.eclipse.debug.core.RefreshUtil;
25
import org.eclipse.debug.core.model.IProcess;
26
27
/**
28
 * Refreshes resources as specified by a launch configuration, when 
29
 * an associated process terminates.
30
 */
31
public class BackgroundResourceRefresher implements IDebugEventSetListener  {
32
33
	private ILaunchConfiguration fConfiguration;
34
	private IProcess fProcess;
35
	
36
	
37
	
38
	public BackgroundResourceRefresher(ILaunchConfiguration configuration, IProcess process) {
39
		fConfiguration = configuration;
40
		fProcess = process;
41
	}
42
	
43
	/**
44
	 * If the process has already terminated, resource refreshing is done
45
	 * immediately in the current thread. Otherwise, refreshing is done when the
46
	 * process terminates.
47
	 */
48
	public void startBackgroundRefresh() {
49
		synchronized (fProcess) {
50
			if (fProcess.isTerminated()) {
51
				refresh();
52
			} else {
53
				DebugPlugin.getDefault().addDebugEventListener(this);
54
			}
55
		}
56
	}
57
	
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
60
	 */
61
	public void handleDebugEvents(DebugEvent[] events) {
62
		for (int i = 0; i < events.length; i++) {
63
			DebugEvent event = events[i];
64
			if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) {
65
				DebugPlugin.getDefault().removeDebugEventListener(this);
66
				refresh();
67
				break;
68
			}
69
		}
70
	}
71
	
72
	/**
73
	 * Submits a job to do the refresh
74
	 */
75
	protected void refresh() {
76
		Job job= new Job(ExternalToolsProgramMessages.BackgroundResourceRefresher_0) {
77
			public IStatus run(IProgressMonitor monitor) {
78
				try {
79
					RefreshUtil.refreshResources(fConfiguration, monitor);
80
				} catch (CoreException e) {
81
					ExternalToolsCore.log(e);
82
					return e.getStatus();
83
				}	
84
				return Status.OK_STATUS;
85
			}
86
		};
87
		job.schedule();
88
	}
89
}
(-)src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsCoreUtil.java (+274 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Keith Seitz (keiths@redhat.com) - Bug 27243 (environment variables contribution)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.core.externaltools.internal.launchConfigurations;
14
15
16
import java.io.File;
17
18
import org.eclipse.core.externaltools.internal.ExternalToolsCore;
19
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IWorkspaceRoot;
23
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.core.runtime.Path;
28
import org.eclipse.core.runtime.Status;
29
import org.eclipse.core.variables.IStringVariableManager;
30
import org.eclipse.core.variables.VariablesPlugin;
31
import org.eclipse.debug.core.DebugPlugin;
32
import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.debug.core.RefreshUtil;
34
import org.eclipse.osgi.util.NLS;
35
36
/**
37
 * Utilities for external tool launch configurations.
38
 * <p>
39
 * This class it not intended to be instantiated.
40
 * </p>
41
 */
42
public class ExternalToolsCoreUtil {
43
44
	/**
45
	 * Throws a core exception with an error status object built from
46
	 * the given message, lower level exception, and error code.
47
	 * @param message the status message
48
	 * @param exception lower level exception associated with the
49
	 *  error, or <code>null</code> if none
50
	 * @param code error code
51
	 */
52
	protected static void abort(String message, Throwable exception, int code) throws CoreException {
53
		throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception));
54
	}
55
	
56
	/**
57
	 * Expands and returns the location attribute of the given launch
58
	 * configuration. The location is
59
	 * verified to point to an existing file, in the local file system.
60
	 * 
61
	 * @param configuration launch configuration
62
	 * @return an absolute path to a file in the local file system  
63
	 * @throws CoreException if unable to retrieve the associated launch
64
	 * configuration attribute, if unable to resolve any variables, or if the
65
	 * resolved location does not point to an existing file in the local file
66
	 * system
67
	 */
68
	public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
69
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
70
		if (location == null) {
71
			abort(NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0);
72
		} else {
73
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
74
			if (expandedLocation == null || expandedLocation.length() == 0) {
75
				String msg = NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
76
				abort(msg, null, 0);
77
			} else {
78
				File file = new File(expandedLocation);
79
				if (file.isFile()) {
80
					return new Path(expandedLocation);
81
				} 
82
				
83
				String msg = NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
84
				abort(msg, null, 0);
85
			}
86
		}
87
		// execution will not reach here
88
		return null;
89
	}
90
	
91
	/**
92
	 * Returns a boolean specifying whether or not output should be captured for
93
	 * the given configuration
94
	 * 
95
	 * @param configuration the configuration from which the value will be
96
	 * extracted
97
	 * @return boolean specifying whether or not output should be captured
98
	 * @throws CoreException if unable to access the associated attribute
99
	 */
100
	public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
101
	    return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
102
	}
103
104
	/**
105
	 * Expands and returns the working directory attribute of the given launch
106
	 * configuration. Returns <code>null</code> if a working directory is not
107
	 * specified. If specified, the working is verified to point to an existing
108
	 * directory in the local file system.
109
	 * 
110
	 * @param configuration launch configuration
111
	 * @return an absolute path to a directory in the local file system, or
112
	 * <code>null</code> if unspecified
113
	 * @throws CoreException if unable to retrieve the associated launch
114
	 * configuration attribute, if unable to resolve any variables, or if the
115
	 * resolved location does not point to an existing directory in the local
116
	 * file system
117
	 */
118
	public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
119
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
120
		if (location != null) {
121
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
122
			if (expandedLocation.length() > 0) {
123
				File path = new File(expandedLocation);
124
				if (path.isDirectory()) {
125
					return new Path(expandedLocation);
126
				} 
127
				String msg = NLS.bind(ExternalToolsProgramMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()});
128
				abort(msg, null, 0);
129
			}
130
		}
131
		return null;
132
	}
133
134
	/**
135
	 * Expands and returns the arguments attribute of the given launch
136
	 * configuration. Returns <code>null</code> if arguments are not specified.
137
	 * 
138
	 * @param configuration launch configuration
139
	 * @return an array of resolved arguments, or <code>null</code> if
140
	 * unspecified
141
	 * @throws CoreException if unable to retrieve the associated launch
142
	 * configuration attribute, or if unable to resolve any variables
143
	 */
144
	public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
145
		String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
146
		if (args != null) {
147
			String expanded = getStringVariableManager().performStringSubstitution(args);
148
			return parseStringIntoList(expanded);
149
		}
150
		return null;
151
	}
152
153
	private static IStringVariableManager getStringVariableManager() {
154
		return VariablesPlugin.getDefault().getStringVariableManager();
155
	}
156
	
157
	/**
158
	 * Returns whether the given launch configuration is enabled. This property
159
	 * is intended only to apply to external tool builder configurations and
160
	 * determines whether the project builder will launch the configuration
161
	 * when it builds.
162
	 *  
163
	 * @param configuration the configuration for which the enabled state should
164
	 * 		be determined.
165
	 * @return whether the given configuration is enabled to be run when a build occurs.
166
	 * @throws CoreException if unable to access the associated attribute
167
	 */
168
	public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
169
		return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true);
170
	}
171
	
172
	/**
173
	 * Returns the collection of resources for the build scope as specified by the given launch configuration.
174
	 * 
175
	 * @param configuration launch configuration
176
	 * @throws CoreException if an exception occurs while retrieving the resources
177
	 */
178
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
179
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
180
		if (scope == null) {
181
			return null;
182
		}
183
	
184
		return RefreshUtil.toResources(scope);
185
	}
186
	
187
	/**
188
	 * Parses the argument text into an array of individual
189
	 * strings using the space character as the delimiter.
190
	 * An individual argument containing spaces must have a
191
	 * double quote (") at the start and end. Two double 
192
	 * quotes together is taken to mean an embedded double
193
	 * quote in the argument text.
194
	 * 
195
	 * @param arguments the arguments as one string
196
	 * @return the array of arguments
197
	 */
198
	public static String[] parseStringIntoList(String arguments) {
199
		if (arguments == null || arguments.length() == 0) {
200
			return new String[0];
201
		}
202
		String[] res= DebugPlugin.parseArguments(arguments);
203
		return res;		
204
	}	
205
	/**
206
	 * Returns a collection of projects referenced by a build scope attribute.
207
	 * 
208
	 * @return collection of projects referred to by configuration
209
	 */
210
	public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
211
		
212
		String scope = null;
213
		String id = buildScopeId ;
214
		if (id == null) {
215
			id = IExternalToolConstants.ATTR_BUILD_SCOPE ;
216
		}
217
		try {
218
			scope = configuration.getAttribute(id, (String)null);
219
		} catch (CoreException e) {
220
			return null;
221
		}
222
		if (scope == null) {
223
			return null;
224
		}
225
		if (scope.startsWith("${projects:")) { //$NON-NLS-1$
226
			String pathString = scope.substring(11, scope.length() - 1);
227
			if (pathString.length() > 1) {
228
				String[] names = pathString.split(","); //$NON-NLS-1$
229
				IProject[] projects = new IProject[names.length];
230
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
231
				for (int i = 0; i < names.length; i++) {
232
					projects[i] = root.getProject(names[i]);
233
				}
234
				return projects;
235
			}
236
		} else if (scope.equals("${project}")) { //$NON-NLS-1$
237
			if(configuration.getFile()!=null)
238
				return new IProject[]{((IResource)configuration.getFile()).getProject()};
239
		}
240
		return new IProject[0];
241
	}
242
	
243
	/**
244
	 * Whether referenced projects should be considered when building. Only valid
245
	 * when a set of projects is to be built.
246
	 * 
247
	 * @param configuration
248
	 * @return whether referenced projects should be considerd when building
249
	 * @throws CoreException if unable to access the associated attribute
250
	 */
251
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
252
		String id = includeReferencedProjectsId;
253
		if (id == null) {
254
			id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ;
255
		}
256
		return configuration.getAttribute(id, true);
257
	}
258
	
259
	/**
260
	 * Returns whether the given external builder configuration should build asynchronously.
261
	 * 
262
	 * @param configuration the configuration
263
	 * @return whether the configuration is configured to build asynchronously
264
	 */
265
	public static boolean isAsynchronousBuild(ILaunchConfiguration configuration) {
266
		boolean launchInBackground= false;
267
		try {
268
			launchInBackground= configuration.getAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
269
		} catch (CoreException ce) {
270
			ExternalToolsCore.log(ce);
271
		}
272
		return launchInBackground;
273
	}
274
}
(-)src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java (+30 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved.   This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.core.externaltools.internal.launchConfigurations;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class ExternalToolsProgramMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsProgramMessages";//$NON-NLS-1$
16
17
	public static String BackgroundResourceRefresher_0;
18
19
	public static String ProgramLaunchDelegate_3;
20
	public static String ProgramLaunchDelegate_4;
21
	
22
	public static String ExternalToolsUtil_Location_not_specified_by__0__1;
23
	public static String ExternalToolsUtil_invalidLocation__0_;
24
	public static String ExternalToolsUtil_invalidDirectory__0_;
25
26
	static {
27
		// load message values from bundle file
28
		NLS.initializeMessages(BUNDLE_NAME, ExternalToolsProgramMessages.class);
29
	}
30
}
(-)src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties (+23 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
BackgroundResourceRefresher_0=Refreshing resources...
13
14
ProgramLaunchDelegate_Workbench_Closing_1=Workbench Closing
15
ProgramLaunchDelegate_The_workbench_is_exiting=The workbench is exiting and a program launched from an external tool appears to still be running. These programs will be terminated when the workbench exits. It is recommended that you exit any external programs launched from the workbench before you proceed.\n\nClick OK to continue exiting the workbench.
16
ProgramLaunchDelegate_3=Running {0}...
17
ProgramLaunchDelegate_4=An IProcess could not be created for the launch
18
19
ProgramMainTab_Select=&Select a program:
20
21
ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
22
ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
23
ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}.
(-)src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java (+207 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Keith Seitz (keiths@redhat.com) - environment variables contribution (Bug 27243)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.core.externaltools.internal.launchConfigurations;
14
15
import java.io.File;
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.ILaunchConfiguration;
29
import org.eclipse.debug.core.RefreshUtil;
30
import org.eclipse.debug.core.model.IProcess;
31
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
32
import org.eclipse.osgi.util.NLS;
33
34
/**
35
 * Launch delegate for a program.
36
 */
37
public class ProgramLaunchDelegate extends LaunchConfigurationDelegate {
38
39
	/**
40
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
41
	 *      java.lang.String, org.eclipse.debug.core.ILaunch,
42
	 *      org.eclipse.core.runtime.IProgressMonitor)
43
	 */
44
	public void launch(ILaunchConfiguration configuration, String mode,
45
			ILaunch launch, IProgressMonitor monitor) throws CoreException {
46
47
		if (monitor.isCanceled()) {
48
			return;
49
		}
50
51
		// resolve location
52
		IPath location = ExternalToolsCoreUtil.getLocation(configuration);
53
54
		if (monitor.isCanceled()) {
55
			return;
56
		}
57
58
		// resolve working directory
59
		IPath workingDirectory = ExternalToolsCoreUtil
60
				.getWorkingDirectory(configuration);
61
62
		if (monitor.isCanceled()) {
63
			return;
64
		}
65
66
		// resolve arguments
67
		String[] arguments = ExternalToolsCoreUtil.getArguments(configuration);
68
69
		if (monitor.isCanceled()) {
70
			return;
71
		}
72
73
		int cmdLineLength = 1;
74
		if (arguments != null) {
75
			cmdLineLength += arguments.length;
76
		}
77
		String[] cmdLine = new String[cmdLineLength];
78
		cmdLine[0] = location.toOSString();
79
		if (arguments != null) {
80
			System.arraycopy(arguments, 0, cmdLine, 1, arguments.length);
81
		}
82
83
		File workingDir = null;
84
		if (workingDirectory != null) {
85
			workingDir = workingDirectory.toFile();
86
		}
87
88
		if (monitor.isCanceled()) {
89
			return;
90
		}
91
92
		String[] envp = DebugPlugin.getDefault().getLaunchManager()
93
				.getEnvironment(configuration);
94
95
		if (monitor.isCanceled()) {
96
			return;
97
		}
98
99
		Process p = DebugPlugin.exec(cmdLine, workingDir, envp);
100
		IProcess process = null;
101
102
		// add process type to process attributes
103
		Map processAttributes = new HashMap();
104
		String programName = location.lastSegment();
105
		String extension = location.getFileExtension();
106
		if (extension != null) {
107
			programName = programName.substring(0, programName.length()
108
					- (extension.length() + 1));
109
		}
110
		programName = programName.toLowerCase();
111
		processAttributes.put(IProcess.ATTR_PROCESS_TYPE, programName);
112
113
		if (p != null) {
114
			monitor.beginTask(NLS.bind(
115
					ExternalToolsProgramMessages.ProgramLaunchDelegate_3,
116
					new String[] { configuration.getName() }),
117
					IProgressMonitor.UNKNOWN);
118
			process = DebugPlugin.newProcess(launch, p, location.toOSString(),
119
					processAttributes);
120
		}
121
		if (p == null || process == null) {
122
			if (p != null)
123
				p.destroy();
124
			throw new CoreException(new Status(IStatus.ERROR,
125
					IExternalToolConstants.PLUGIN_ID,
126
					IExternalToolConstants.ERR_INTERNAL_ERROR,
127
					ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null));
128
		}
129
		process.setAttribute(IProcess.ATTR_CMDLINE,
130
				generateCommandLine(cmdLine));
131
132
//		if (launchManager.isLaunchInBackground(configuration)) {
133
//			// refresh resources after process finishes
134
//			if (launchManager.getRefreshScope(configuration) != null) {
135
//				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(
136
//						configuration, process);
137
//				refresher.startBackgroundRefresh();
138
//			}
139
//		} else {
140
			// wait for process to exit
141
			while (!process.isTerminated()) {
142
				try {
143
					if (monitor.isCanceled()) {
144
						process.terminate();
145
						break;
146
					}
147
					Thread.sleep(50);
148
				} catch (InterruptedException e) {
149
				}
150
			}
151
152
			// refresh resources
153
			RefreshUtil.refreshResources(configuration, monitor);
154
//		}
155
	}
156
157
	private String generateCommandLine(String[] commandLine) {
158
		if (commandLine.length < 1)
159
			return ""; //$NON-NLS-1$
160
		StringBuffer buf = new StringBuffer();
161
		for (int i = 0; i < commandLine.length; i++) {
162
			buf.append(' ');
163
			char[] characters = commandLine[i].toCharArray();
164
			StringBuffer command = new StringBuffer();
165
			boolean containsSpace = false;
166
			for (int j = 0; j < characters.length; j++) {
167
				char character = characters[j];
168
				if (character == '\"') {
169
					command.append('\\');
170
				} else if (character == ' ') {
171
					containsSpace = true;
172
				}
173
				command.append(character);
174
			}
175
			if (containsSpace) {
176
				buf.append('\"');
177
				buf.append(command);
178
				buf.append('\"');
179
			} else {
180
				buf.append(command);
181
			}
182
		}
183
		return buf.toString();
184
	}
185
186
	/*
187
	 * (non-Javadoc)
188
	 * 
189
	 * @see
190
	 * org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder
191
	 * (org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
192
	 */
193
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration,
194
			String mode) throws CoreException {
195
		IProject[] projects = ExternalToolsCoreUtil.getBuildProjects(
196
				configuration, null);
197
		if (projects == null) {
198
			return null;
199
		}
200
		boolean isRef = ExternalToolsCoreUtil.isIncludeReferencedProjects(
201
				configuration, null);
202
		if (isRef) {
203
			return computeReferencedBuildOrder(projects);
204
		}
205
		return computeBuildOrder(projects);
206
	}
207
}
(-)src/org/eclipse/core/externaltools/internal/model/BuilderCoreUtils.java (+341 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.externaltools.internal.model;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.StringTokenizer;
16
17
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
18
import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration;
19
import org.eclipse.core.resources.ICommand;
20
import org.eclipse.core.resources.IFile;
21
import org.eclipse.core.resources.IFolder;
22
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.resources.IncrementalProjectBuilder;
25
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.IPath;
28
import org.eclipse.core.runtime.IStatus;
29
import org.eclipse.core.runtime.NullProgressMonitor;
30
import org.eclipse.core.runtime.Path;
31
import org.eclipse.debug.core.DebugPlugin;
32
import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
34
import org.eclipse.debug.core.ILaunchManager;
35
36
/**
37
 * Utility methods for working with external tool project builders.
38
 */
39
public class BuilderCoreUtils {
40
41
	public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$
42
43
	/**
44
	 * Constant used to find a builder using the 3.0-interim format
45
	 */
46
	public static final String BUILDER_FOLDER_NAME = ".externalToolBuilders"; //$NON-NLS-1$
47
	/**
48
	 * Constant used to represent the current project in the 3.0-final format.
49
	 */
50
	public static final String PROJECT_TAG = "<project>"; //$NON-NLS-1$
51
52
	public static final String VERSION_1_0 = "1.0"; //$NON-NLS-1$
53
	public static final String VERSION_2_1 = "2.1"; //$NON-NLS-1$
54
	// The format shipped up to and including Eclipse 3.0 RC1
55
	public static final String VERSION_3_0_interim = "3.0.interim"; //$NON-NLS-1$
56
	// The format shipped in Eclipse 3.0 final
57
	public static final String VERSION_3_0_final = "3.0"; //$NON-NLS-1$
58
59
	private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
60
	private static final int[] DEFAULT_BUILD_TYPES = new int[] {
61
			IncrementalProjectBuilder.INCREMENTAL_BUILD,
62
			IncrementalProjectBuilder.FULL_BUILD };
63
64
	/**
65
	 * Returns a launch configuration from the given ICommand arguments. If the
66
	 * given arguments are from an old-style external tool, an unsaved working
67
	 * copy will be created from the arguments and returned.
68
	 * 
69
	 * @param commandArgs
70
	 *            the builder ICommand arguments
71
	 * @return a launch configuration, a launch configuration working copy, or
72
	 *         <code>null</code> if not possible.
73
	 */
74
	public static ILaunchConfiguration configFromBuildCommandArgs(
75
			IProject project, Map commandArgs, String[] version) {
76
		String configHandle = (String) commandArgs.get(LAUNCH_CONFIG_HANDLE);
77
		if (configHandle == null) {
78
			// Probably an old-style (Eclipse 1.0 or 2.0) external tool. Try to
79
			// migrate.
80
			version[0] = VERSION_1_0;
81
			return ExternalToolMigration.configFromArgumentMap(commandArgs);
82
		}
83
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
84
		ILaunchConfiguration configuration = null;
85
		if (configHandle.startsWith(PROJECT_TAG)) {
86
			version[0] = VERSION_3_0_final;
87
			IPath path = new Path(configHandle);
88
			IFile file = project.getFile(path.removeFirstSegments(1));
89
			if (file.exists()) {
90
				configuration = manager.getLaunchConfiguration(file);
91
			}
92
		} else {
93
			// Try treating the handle as a file name.
94
			// This is the format used in 3.0 RC1.
95
			IPath path = new Path(BUILDER_FOLDER_NAME).append(configHandle);
96
			IFile file = project.getFile(path);
97
			if (file.exists()) {
98
				version[0] = VERSION_3_0_interim;
99
				configuration = manager.getLaunchConfiguration(file);
100
			} else {
101
				try {
102
					// Treat the configHandle as a memento. This is the format
103
					// used in Eclipse 2.1.
104
					configuration = manager
105
							.getLaunchConfiguration(configHandle);
106
				} catch (CoreException e) {
107
				}
108
				if (configuration != null) {
109
					version[0] = VERSION_2_1;
110
				}
111
			}
112
		}
113
		return configuration;
114
	}
115
116
	public static void configureTriggers(ILaunchConfiguration config,
117
			ICommand newCommand) throws CoreException {
118
		newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
119
		newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD,
120
				false);
121
		newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
122
		newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
123
		String buildKinds = config.getAttribute(
124
				IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) null);
125
		int[] triggers = BuilderCoreUtils.buildTypesToArray(buildKinds);
126
		for (int i = 0; i < triggers.length; i++) {
127
			switch (triggers[i]) {
128
			case IncrementalProjectBuilder.FULL_BUILD:
129
				newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD,
130
						true);
131
				break;
132
			case IncrementalProjectBuilder.INCREMENTAL_BUILD:
133
				newCommand.setBuilding(
134
						IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
135
				break;
136
			case IncrementalProjectBuilder.AUTO_BUILD:
137
				newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD,
138
						true);
139
				break;
140
			case IncrementalProjectBuilder.CLEAN_BUILD:
141
				newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD,
142
						true);
143
				break;
144
			}
145
		}
146
		if (!config.getAttribute(
147
				IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) {
148
			ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();
149
			copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED,
150
					true);
151
			copy.doSave();
152
		}
153
	}
154
155
	/**
156
	 * Returns whether the given configuration is an "unmigrated" builder.
157
	 * Unmigrated builders are external tools that are stored in an old format
158
	 * but have not been migrated by the user. Old format builders are always
159
	 * translated into launch config working copies in memory, but they're not
160
	 * considered "migrated" until the config has been saved and the project
161
	 * spec updated.
162
	 * 
163
	 * @param config
164
	 *            the config to examine
165
	 * @return whether the given config represents an unmigrated builder
166
	 */
167
	public static boolean isUnmigratedConfig(ILaunchConfiguration config) {
168
		return config.isWorkingCopy()
169
				&& ((ILaunchConfigurationWorkingCopy) config).getOriginal() == null;
170
	}
171
172
	/**
173
	 * Converts the given config to a build command which is stored in the given
174
	 * command.
175
	 * 
176
	 * @return the configured build command
177
	 */
178
	public static ICommand toBuildCommand(IProject project,
179
			ILaunchConfiguration config, ICommand command) throws CoreException {
180
		Map args = null;
181
		if (isUnmigratedConfig(config)) {
182
			// This config represents an old external tool builder that hasn't
183
			// been edited. Try to find the old ICommand and reuse the
184
			// arguments.
185
			// The goal here is to not change the storage format of old,
186
			// unedited builders.
187
			ICommand[] commands = project.getDescription().getBuildSpec();
188
			for (int i = 0; i < commands.length; i++) {
189
				ICommand projectCommand = commands[i];
190
				String name = ExternalToolMigration
191
						.getNameFromCommandArgs(projectCommand.getArguments());
192
				if (name != null && name.equals(config.getName())) {
193
					args = projectCommand.getArguments();
194
					break;
195
				}
196
			}
197
		} else {
198
			if (config instanceof ILaunchConfigurationWorkingCopy) {
199
				ILaunchConfigurationWorkingCopy workingCopy = (ILaunchConfigurationWorkingCopy) config;
200
				if (workingCopy.getOriginal() != null) {
201
					config = workingCopy.getOriginal();
202
				}
203
			}
204
			args = new HashMap();
205
			// Launch configuration builders are stored with a project-relative
206
			// path
207
			StringBuffer buffer = new StringBuffer(PROJECT_TAG);
208
			// Append the project-relative path (workspace path minus first
209
			// segment)
210
			buffer.append('/').append(
211
					config.getFile().getFullPath().removeFirstSegments(1));
212
			args.put(LAUNCH_CONFIG_HANDLE, buffer.toString());
213
		}
214
		command.setBuilderName(ExternalToolBuilder.ID);
215
		command.setArguments(args);
216
		return command;
217
	}
218
219
	/**
220
	 * Returns the folder where project builders should be stored or
221
	 * <code>null</code> if the folder could not be created
222
	 */
223
	public static IFolder getBuilderFolder(IProject project, boolean create) {
224
		IFolder folder = project.getFolder(BUILDER_FOLDER_NAME);
225
		if (!folder.exists() && create) {
226
			try {
227
				folder.create(true, true, new NullProgressMonitor());
228
			} catch (CoreException e) {
229
				return null;
230
			}
231
		}
232
		return folder;
233
	}
234
235
	/**
236
	 * Migrates the launch configuration working copy, which is based on an old-
237
	 * style external tool builder, to a new, saved launch configuration. The
238
	 * returned launch configuration will contain the same attributes as the
239
	 * given working copy with the exception of the configuration name, which
240
	 * may be changed during the migration. The name of the configuration will
241
	 * only be changed if the current name is not a valid name for a saved
242
	 * config.
243
	 * 
244
	 * @param workingCopy
245
	 *            the launch configuration containing attributes from an
246
	 *            old-style project builder.
247
	 * @return ILaunchConfiguration a new, saved launch configuration whose
248
	 *         attributes match those of the given working copy as well as
249
	 *         possible
250
	 * @throws CoreException
251
	 *             if an exception occurs while attempting to save the new
252
	 *             launch configuration
253
	 */
254
	public static ILaunchConfiguration migrateBuilderConfiguration(
255
			IProject project, ILaunchConfigurationWorkingCopy workingCopy)
256
			throws CoreException {
257
		workingCopy.setContainer(getBuilderFolder(project, true));
258
		// Before saving, make sure the name is valid
259
		String name = workingCopy.getName();
260
		name = name.replace('/', '.');
261
		if (name.charAt(0) == ('.')) {
262
			name = name.substring(1);
263
		}
264
		IStatus status = ResourcesPlugin.getWorkspace().validateName(name,
265
				IResource.FILE);
266
		if (!status.isOK()) {
267
			name = "ExternalTool"; //$NON-NLS-1$
268
		}
269
		name = DebugPlugin.getDefault().getLaunchManager()
270
				.generateUniqueLaunchConfigurationNameFrom(name);
271
		workingCopy.rename(name);
272
		return workingCopy.doSave();
273
	}
274
275
	/**
276
	 * Converts the build types string into an array of build kinds.
277
	 * 
278
	 * @param buildTypes
279
	 *            the string of built types to convert
280
	 * @return the array of build kinds.
281
	 */
282
	public static int[] buildTypesToArray(String buildTypes) {
283
		if (buildTypes == null || buildTypes.length() == 0) {
284
			return DEFAULT_BUILD_TYPES;
285
		}
286
287
		int count = 0;
288
		boolean incremental = false;
289
		boolean full = false;
290
		boolean auto = false;
291
		boolean clean = false;
292
293
		StringTokenizer tokenizer = new StringTokenizer(buildTypes,
294
				BUILD_TYPE_SEPARATOR);
295
		while (tokenizer.hasMoreTokens()) {
296
			String token = tokenizer.nextToken();
297
			if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) {
298
				if (!incremental) {
299
					incremental = true;
300
					count++;
301
				}
302
			} else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) {
303
				if (!full) {
304
					full = true;
305
					count++;
306
				}
307
			} else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) {
308
				if (!auto) {
309
					auto = true;
310
					count++;
311
				}
312
			} else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(token)) {
313
				if (!clean) {
314
					clean = true;
315
					count++;
316
				}
317
			}
318
		}
319
320
		int[] results = new int[count];
321
		count = 0;
322
		if (incremental) {
323
			results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
324
			count++;
325
		}
326
		if (full) {
327
			results[count] = IncrementalProjectBuilder.FULL_BUILD;
328
			count++;
329
		}
330
		if (auto) {
331
			results[count] = IncrementalProjectBuilder.AUTO_BUILD;
332
			count++;
333
		}
334
		if (clean) {
335
			results[count] = IncrementalProjectBuilder.CLEAN_BUILD;
336
			count++;
337
		}
338
339
		return results;
340
	}
341
}
(-)src/org/eclipse/core/externaltools/internal/model/ExternalToolBuilder.java (+290 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Conway  - Bug 175186
11
 *******************************************************************************/
12
package org.eclipse.core.externaltools.internal.model;
13
14
15
import java.util.Map;
16
17
import org.eclipse.core.externaltools.internal.ExternalToolsCore;
18
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
19
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
20
import org.eclipse.core.externaltools.internal.registry.ExternalToolMigration;
21
import org.eclipse.core.resources.ICommand;
22
import org.eclipse.core.resources.IFile;
23
import org.eclipse.core.resources.IProject;
24
import org.eclipse.core.resources.IProjectDescription;
25
import org.eclipse.core.resources.IResource;
26
import org.eclipse.core.resources.IResourceDelta;
27
import org.eclipse.core.resources.IResourceDeltaVisitor;
28
import org.eclipse.core.resources.IncrementalProjectBuilder;
29
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.IPath;
31
import org.eclipse.core.runtime.IProgressMonitor;
32
import org.eclipse.debug.core.ILaunchConfiguration;
33
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
34
import org.eclipse.debug.core.ILaunchManager;
35
import org.eclipse.osgi.util.NLS;
36
import org.osgi.framework.Bundle;
37
38
/**
39
 * This project builder implementation will run an external tool during the
40
 * build process. 
41
 */
42
public final class ExternalToolBuilder extends IncrementalProjectBuilder {
43
	private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor {
44
		private boolean[] fTrueChange;
45
		private IgnoreTeamPrivateChanges(boolean[] trueChange) {
46
			super();
47
			fTrueChange= trueChange;
48
		}
49
		public boolean visit(IResourceDelta visitDelta) throws CoreException {
50
			IResource resource= visitDelta.getResource();
51
			if (resource instanceof IFile) {
52
				fTrueChange[0]= true;
53
				return false;
54
			}
55
			return true;
56
		}
57
	}
58
59
	public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$;
60
61
	private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
62
	
63
	private static IProject buildProject= null;
64
    private static IResourceDelta buildDelta= null;
65
	
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
68
	 */
69
	protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {		
70
		if (ExternalToolsCore.getDefault().getBundle().getState() != Bundle.ACTIVE) {
71
			return null;
72
		}
73
		
74
		ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), args, new String[1]);
75
        if (config == null) {
76
            throw ExternalToolsCore.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
77
        }
78
		IProject[] projectsWithinScope= null;
79
		IResource[] resources = ExternalToolsCoreUtil.getResourcesForBuildScope(config);
80
		if (resources != null) {
81
			projectsWithinScope= new IProject[resources.length];
82
			for (int i = 0; i < resources.length; i++) {
83
				projectsWithinScope[i]= resources[i].getProject();
84
			}
85
		}
86
        boolean kindCompatible= commandConfiguredForKind(config, kind);
87
        if (kindCompatible && configEnabled(config)) {
88
            doBuildBasedOnScope(resources, kind, config, monitor);
89
        }
90
        
91
		return projectsWithinScope;
92
	}
93
94
    private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) {
95
        try {
96
            if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
97
                ICommand command= getCommand();
98
                //adapt the builder command to make use of the 3.1 support for setting command build kinds
99
                //this will only happen once for builder/command defined before the support existed
100
                BuilderCoreUtils.configureTriggers(config, command);
101
                IProjectDescription desc= getProject().getDescription();
102
                ICommand[] commands= desc.getBuildSpec();
103
                int index= getBuilderCommandIndex(commands, command);
104
                if (index != -1) {
105
                    commands[index]= command;
106
                    desc.setBuildSpec(commands);
107
                    getProject().setDescription(desc, null);
108
                    ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
109
                    copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
110
                    copy.doSave();
111
                }
112
                return command.isBuilding(kind);
113
            }
114
        } catch (CoreException e) {
115
           ExternalToolsCore.log(e);
116
           return true;
117
        }
118
        return true;
119
    }
120
    
121
    private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) {
122
        Map commandArgs= command.getArguments();
123
        if (commandArgs == null) {
124
            return -1;
125
        }
126
        String handle= (String) commandArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE);
127
        if (handle == null) {
128
            return -1;
129
        }
130
        for (int i = 0; i < buildSpec.length; ++i) {
131
            ICommand buildSpecCommand= buildSpec[i];
132
            if (ID.equals(buildSpecCommand.getBuilderName())) {
133
                Map buildSpecArgs= buildSpecCommand.getArguments();
134
                if (buildSpecArgs != null) {
135
                    String buildSpecHandle= (String) buildSpecArgs.get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE);
136
                    if (handle.equals(buildSpecHandle)) {
137
                        return i;
138
                    }
139
                }
140
            }
141
        }
142
        return -1;
143
    }
144
145
	/**
146
	 * Returns whether the given builder config is enabled or not.
147
	 * 
148
	 * @param config the config to examine
149
	 * @return whether the config is enabled
150
	 */
151
	private boolean configEnabled(ILaunchConfiguration config) {
152
		try {
153
			return ExternalToolsCoreUtil.isBuilderEnabled(config);
154
		} catch (CoreException e) {
155
			ExternalToolsCore.log(e);
156
		}
157
		return true;
158
	}
159
160
	private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
161
		boolean buildForChange = true;
162
		if (kind != FULL_BUILD) { //scope not applied for full builds
163
			if (resources != null && resources.length > 0) {
164
				buildForChange = buildScopeIndicatesBuild(resources);
165
			}
166
		}
167
168
		if (buildForChange) {
169
			launchBuild(kind, config, monitor);
170
		}
171
	}
172
	
173
	private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
174
		monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()}));
175
		buildStarted(kind);
176
		// The default value for "launch in background" is true in debug core. If
177
		// the user doesn't go through the UI, the new attribute won't be set. This means
178
		// that existing Ant builders will try to run in the background (and likely conflict with
179
		// each other) without migration.
180
		config= ExternalToolMigration.migrateRunInBackground(config);
181
		config.launch(ILaunchManager.RUN_MODE, monitor);
182
		buildEnded();
183
	}
184
185
	/**
186
	 * Returns the build type being performed if the
187
	 * external tool is being run as a project builder.
188
	 * 
189
	 * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants.
190
	 */
191
	public static String getBuildType() {
192
		return buildType;
193
	}
194
	
195
	/**
196
	 * Returns the project that is being built and has triggered the current external
197
	 * tool builder. <code>null</code> is returned if no build is currently occurring.
198
	 * 
199
	 * @return project being built or <code>null</code>.
200
	 */
201
	public static IProject getBuildProject() {
202
		return buildProject;
203
	}
204
205
    /**
206
     * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external
207
     * tool builder. <code>null</code> is returned if no build is currently occurring.
208
     * 
209
     * @return resource delta for the build or <code>null</code>
210
     */
211
    public static IResourceDelta getBuildDelta() {
212
        return buildDelta;
213
    }
214
    
215
	/**
216
	 * Stores the currently active build kind and build project when a build begins
217
	 * @param buildKind
218
	 */
219
	private void buildStarted(int buildKind) {
220
		switch (buildKind) {
221
			case IncrementalProjectBuilder.INCREMENTAL_BUILD :
222
				buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
223
				buildDelta = getDelta(getProject());
224
				break;
225
			case IncrementalProjectBuilder.FULL_BUILD :
226
				buildType = IExternalToolConstants.BUILD_TYPE_FULL;
227
				break;
228
			case IncrementalProjectBuilder.AUTO_BUILD :
229
				buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
230
				buildDelta = getDelta(getProject());
231
				break;
232
            case IncrementalProjectBuilder.CLEAN_BUILD :
233
                buildType = IExternalToolConstants.BUILD_TYPE_CLEAN;
234
                break;
235
			default :
236
				buildType = IExternalToolConstants.BUILD_TYPE_NONE;
237
				break;
238
		}
239
		buildProject= getProject();
240
	}
241
	
242
	/**
243
	 * Clears the current build kind, build project and build delta when a build finishes.
244
	 */
245
	private void buildEnded() {
246
		buildType= IExternalToolConstants.BUILD_TYPE_NONE;
247
		buildProject= null;
248
        buildDelta= null;
249
	}
250
	
251
	private boolean buildScopeIndicatesBuild(IResource[] resources) {
252
		for (int i = 0; i < resources.length; i++) {
253
			IResourceDelta delta = getDelta(resources[i].getProject());
254
			if (delta == null) {
255
				//project just added to the workspace..no previous build tree
256
				return true;
257
			} 
258
			IPath path= resources[i].getProjectRelativePath();
259
			IResourceDelta change= delta.findMember(path);
260
			if (change != null) {
261
				final boolean[] trueChange= new boolean[1];
262
				trueChange[0]= false;
263
				try {
264
					change.accept(new IgnoreTeamPrivateChanges(trueChange));
265
				} catch (CoreException e) {
266
					ExternalToolsCore.log("Internal error resolving changed resources during build", e); //$NON-NLS-1$
267
				}
268
				
269
				return trueChange[0]; //filtered out team private changes
270
			}
271
		}
272
		return false;
273
	}
274
    
275
    protected void clean(IProgressMonitor monitor) throws CoreException {
276
	    ICommand command= getCommand();
277
        ILaunchConfiguration config= BuilderCoreUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]);
278
    	if (!configEnabled(config)) {
279
	    	return;
280
	    }
281
        
282
        if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
283
            //old behavior
284
            super.clean(monitor);
285
            return;
286
        }
287
	
288
		launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, monitor);
289
    }
290
}
(-)src/org/eclipse/core/externaltools/internal/model/ExternalToolsModelMessages.java (+24 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.core.externaltools.internal.model;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class ExternalToolsModelMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.model.ExternalToolsModelMessages";//$NON-NLS-1$
16
    
17
	public static String ExternalToolBuilder_Running__0_____1;
18
	public static String ExternalToolBuilder_0;
19
	
20
	static {
21
		// load message values from bundle file
22
		NLS.initializeMessages(BUNDLE_NAME, ExternalToolsModelMessages.class);
23
	}
24
}
(-)src/org/eclipse/core/externaltools/internal/model/ExternalToolsModelMessages.properties (+13 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
ExternalToolBuilder_Running__0_____1=Running {0}...
13
ExternalToolBuilder_0=The builder launch configuration could not be found.
(-)src/org/eclipse/core/externaltools/internal/registry/ExternalToolMigration.java (+410 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.externaltools.internal.registry;
12
13
14
import java.util.ArrayList;
15
import java.util.Map;
16
import java.util.StringTokenizer;
17
18
import org.eclipse.core.externaltools.internal.ExternalToolsCore;
19
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.debug.core.DebugPlugin;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationType;
24
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
25
import org.eclipse.debug.core.ILaunchManager;
26
import org.eclipse.debug.core.RefreshUtil;
27
28
29
/**
30
 * Responsible reading an old external tool format and creating
31
 * and migrating it to create a new external tool.
32
 */
33
public final class ExternalToolMigration {
34
	/**
35
	 * Structure to represent a variable definition within a
36
	 * source string.
37
	 */
38
	public static final class VariableDefinition {
39
		/**
40
		 * Index in the source text where the variable started
41
		 * or <code>-1</code> if no valid variable start tag 
42
		 * identifier found.
43
		 */
44
		public int start = -1;
45
		
46
		/**
47
		 * Index in the source text of the character following
48
		 * the end of the variable or <code>-1</code> if no 
49
		 * valid variable end tag found.
50
		 */
51
		public int end = -1;
52
		
53
		/**
54
		 * The variable's name found in the source text, or
55
		 * <code>null</code> if no valid variable found.
56
		 */
57
		public String name = null;
58
		
59
		/**
60
		 * The variable's argument found in the source text, or
61
		 * <code>null</code> if no valid variable found or if
62
		 * the variable did not specify an argument
63
		 */
64
		public String argument = null;
65
		
66
		/**
67
		 * Create an initialized variable definition.
68
		 */
69
		private VariableDefinition() {
70
			super();
71
		}
72
	}
73
	
74
	/**
75
	 * Variable tag indentifiers
76
	 */
77
	private static final String VAR_TAG_START = "${"; //$NON-NLS-1$
78
	private static final String VAR_TAG_END = "}"; //$NON-NLS-1$
79
	private static final String VAR_TAG_SEP = ":"; //$NON-NLS-1$	
80
	
81
	/**
82
	 * External tool type for Ant build files (value <code>antBuildType</code>).
83
	 */
84
	public static final String TOOL_TYPE_ANT_BUILD = "antBuildType"; //$NON-NLS-1$;
85
	/**
86
	 * Ant builder launch configuration type identifier. Ant project builders
87
	 * are of this type.
88
	 */
89
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$
90
		
91
	public static final String RUN_TARGETS_ATTRIBUTE = TOOL_TYPE_ANT_BUILD + ".runTargets"; //$NON-NLS-1$;
92
93
	/**
94
	* String attribute indicating the Ant targets to execute. Default value is
95
	 * <code>null</code> which indicates that the default target is to be
96
	 * executed. Format is a comma separated listing of targets.
97
	 * NOTE: This value is copied here from org.eclipse.ant.ui.internal.IAntLaunchConfigurationConstants.
98
	 * 		Ant no longer resides in External Tools and this plug-in. This value is kept here only
99
	 * 		for migration.
100
	 */
101
	public static final String ATTR_ANT_TARGETS = IExternalToolConstants.UI_PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$
102
	
103
	/*
104
	 * 2.0 External Tool Tags
105
	 */
106
	public static final String TAG_TOOL_TYPE = "!{tool_type}"; //$NON-NLS-1$
107
	public static final String TAG_TOOL_NAME = "!{tool_name}"; //$NON-NLS-1$
108
	public static final String TAG_TOOL_LOCATION = "!{tool_loc}"; //$NON-NLS-1$
109
	public static final String TAG_TOOL_ARGUMENTS = "!{tool_args}"; //$NON-NLS-1$
110
	public static final String TAG_TOOL_DIRECTORY = "!{tool_dir}"; //$NON-NLS-1$
111
	public static final String TAG_TOOL_REFRESH = "!{tool_refresh}"; //$NON-NLS-1$
112
	public static final String TAG_TOOL_SHOW_LOG = "!{tool_show_log}"; //$NON-NLS-1$
113
	public static final String TAG_TOOL_BUILD_TYPES = "!{tool_build_types}"; //$NON-NLS-1$
114
	public static final String TAG_TOOL_BLOCK = "!{tool_block}"; //$NON-NLS-1$
115
116
	// Known kind of tools
117
	private static final String TOOL_TYPE_ANT = "org.eclipse.ui.externaltools.type.ant"; //$NON-NLS-1$
118
	private static final String TOOL_TYPE_PROGRAM = "org.eclipse.ui.externaltools.type.program"; //$NON-NLS-1$
119
120
	/*
121
	 * 2.1 External Tool Keys
122
	 */
123
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
124
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
125
	public static final String TAG_LOCATION = "location"; //$NON-NLS-1$
126
	public static final String TAG_WORK_DIR = "workDirectory"; //$NON-NLS-1$
127
	public static final String TAG_CAPTURE_OUTPUT = "captureOutput"; //$NON-NLS-1$
128
	public static final String TAG_SHOW_CONSOLE = "showConsole"; //$NON-NLS-1$
129
	public static final String TAG_RUN_BKGRND = "runInBackground"; //$NON-NLS-1$
130
	public static final String TAG_PROMPT_ARGS = "promptForArguments"; //$NON-NLS-1$
131
	public static final String TAG_ARGS = "arguments"; //$NON-NLS-1$
132
	public static final String TAG_REFRESH_SCOPE = "refreshScope"; //$NON-NLS-1$
133
	public static final String TAG_REFRESH_RECURSIVE = "refreshRecursive"; //$NON-NLS-1$
134
	public static final String TAG_RUN_BUILD_KINDS = "runForBuildKinds"; //$NON-NLS-1$
135
	public static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$
136
	public static final String TAG_VERSION = "version"; //$NON-NLS-1$
137
138
	private static final String EXTRA_ATTR_SEPARATOR = "="; //$NON-NLS-1$
139
140
	private static final String VERSION_21 = "2.1"; //$NON-NLS-1$;
141
142
	private static final String TRUE = "true"; //$NON-NLS-1$
143
	private static final String FALSE = "false"; //$NON-NLS-1$
144
145
	/**
146
	 * Allows no instances.
147
	 */
148
	private ExternalToolMigration() {
149
		super();
150
	}
151
152
	/**
153
	 * Returns a  launch configuration working copy from the argument map or
154
	 * <code>null</code> if the given map cannot be interpreted as a 2.0 or 2.1
155
	 * branch external tool. The returned working copy will be unsaved and its
156
	 * location will be set to the metadata area.
157
	 */
158
	public static ILaunchConfigurationWorkingCopy configFromArgumentMap(Map args) {
159
		String version = (String) args.get(TAG_VERSION);
160
		if (VERSION_21.equals(version)) {
161
			return configFrom21ArgumentMap(args);
162
		}
163
		return configFrom20ArgumentMap(args);
164
	}
165
166
	public static ILaunchConfigurationWorkingCopy configFrom21ArgumentMap(Map commandArgs) {
167
		String name = (String) commandArgs.get(TAG_NAME);
168
		String type = (String) commandArgs.get(TAG_TYPE);
169
		
170
		ILaunchConfigurationWorkingCopy config = newConfig(type, name);
171
		if (config == null) {
172
			return null;
173
		}
174
		
175
		config.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String) commandArgs.get(TAG_LOCATION));
176
		config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) commandArgs.get(TAG_WORK_DIR));
177
		config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(commandArgs.get(TAG_CAPTURE_OUTPUT)));
178
		config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(commandArgs.get(TAG_SHOW_CONSOLE)));
179
		config.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, TRUE.equals(commandArgs.get(TAG_RUN_BKGRND)));
180
		config.setAttribute(IExternalToolConstants.ATTR_PROMPT_FOR_ARGUMENTS, TRUE.equals(commandArgs.get(TAG_PROMPT_ARGS)));
181
		config.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, (String) commandArgs.get(TAG_REFRESH_SCOPE));
182
		config.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, TRUE.equals(commandArgs.get(TAG_REFRESH_RECURSIVE)));
183
184
		config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) commandArgs.get(TAG_RUN_BUILD_KINDS));
185
		
186
		String args = (String) commandArgs.get(TAG_ARGS);
187
		if (args != null) {
188
			config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, args);
189
		}
190
191
		String extraAttributes = (String) commandArgs.get(TAG_EXTRA_ATTR);
192
		if (extraAttributes != null) {
193
			StringTokenizer tokenizer = new StringTokenizer(extraAttributes, EXTRA_ATTR_SEPARATOR);
194
			while (tokenizer.hasMoreTokens()) {
195
				String key = tokenizer.nextToken();
196
				if (!tokenizer.hasMoreTokens())
197
					break;
198
				String value = tokenizer.nextToken();
199
				if (key.equals(RUN_TARGETS_ATTRIBUTE)) {
200
					// 2.1 implementation only defined 1 "extra attribute"
201
					config.setAttribute(ATTR_ANT_TARGETS, value);
202
				}
203
			}
204
		}
205
		return config;
206
	}
207
208
	/**
209
	 * Creates an external tool from the map.
210
	 */
211
	public static ILaunchConfigurationWorkingCopy configFrom20ArgumentMap(Map args) {
212
		// Update the type...
213
		String type = (String) args.get(TAG_TOOL_TYPE);
214
		if (TOOL_TYPE_ANT.equals(type)) {
215
			type = TOOL_TYPE_ANT_BUILD;
216
		} else if (TOOL_TYPE_PROGRAM.equals(type)){
217
			type = IExternalToolConstants.TOOL_TYPE_PROGRAM;
218
		} else {
219
			return null;
220
		}
221
222
		String name = (String) args.get(TAG_TOOL_NAME);
223
		
224
		ILaunchConfigurationWorkingCopy config = newConfig(type, name);
225
		if (config == null) {
226
			return null;
227
		}
228
229
		// Update the location...
230
		String location = (String) args.get(TAG_TOOL_LOCATION);
231
		config.setAttribute(IExternalToolConstants.ATTR_LOCATION, location);
232
233
		// Update the refresh scope...
234
		String refresh = (String) args.get(TAG_TOOL_REFRESH);
235
		if (refresh != null) {
236
			VariableDefinition varDef = extractVariableDefinition(refresh, 0);
237
			if ("none".equals(varDef.name)) { //$NON-NLS-1$
238
				refresh = null;
239
			}
240
			config.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, refresh);
241
		}
242
243
		// Update the arguments
244
		String arguments = (String) args.get(TAG_TOOL_ARGUMENTS);
245
		if (type.equals(TOOL_TYPE_ANT_BUILD)) {
246
			String targetNames = null;
247
			if (arguments != null) {
248
				int start = 0;
249
				ArrayList targets = new ArrayList();
250
				StringBuffer buffer = new StringBuffer();
251
				VariableDefinition varDef = extractVariableDefinition(arguments, start);
252
				while (varDef.end != -1) {
253
					if ("ant_target".equals(varDef.name) && varDef.argument != null) { //$NON-NLS-1$
254
						targets.add(varDef.argument);
255
						buffer.append(arguments.substring(start, varDef.start));
256
					} else {
257
						buffer.append(arguments.substring(start, varDef.end));
258
					}
259
					start = varDef.end;
260
					varDef = extractVariableDefinition(arguments, start);
261
				}
262
				buffer.append(arguments.substring(start, arguments.length()));
263
				arguments = buffer.toString();
264
	
265
				buffer.setLength(0);
266
				for (int i = 0; i < targets.size(); i++) {
267
					String target = (String) targets.get(i);
268
					if (target != null && target.length() > 0) {
269
						buffer.append(target);
270
						buffer.append(","); //$NON-NLS-1$
271
					}
272
				}
273
				targetNames = buffer.toString();
274
			}
275
			if (targetNames != null && targetNames.length() > 0) {
276
				config.setAttribute(ATTR_ANT_TARGETS, targetNames);
277
			}
278
		}
279
		config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
280
281
		// Collect the rest of the information
282
		config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG)));
283
		config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG)));
284
		config.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, FALSE.equals(args.get(TAG_TOOL_BLOCK)));
285
		String buildKinds= (String) args.get(TAG_TOOL_BUILD_TYPES);
286
		if (buildKinds != null) {
287
			buildKinds= buildKinds.replace(';', ','); // Replace the old separator with the new
288
		}
289
		config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buildKinds);
290
		config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) args.get(TAG_TOOL_DIRECTORY));
291
		return config;
292
	}
293
294
	/**
295
	 * Returns a new working copy with the given external tool name and external
296
	 * tool type or <code>null</code> if no config could be created.
297
	 */
298
	private static ILaunchConfigurationWorkingCopy newConfig(String type, String name) {
299
		if (type == null || name == null) {
300
			return null;
301
		}
302
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
303
		ILaunchConfigurationType configType;
304
		if (TOOL_TYPE_ANT_BUILD.equals(type)) {
305
			configType = manager.getLaunchConfigurationType(ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE);
306
		} else if (IExternalToolConstants.TOOL_TYPE_PROGRAM.equals(type)) {
307
			configType = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE);
308
		} else {
309
			return null;
310
		}
311
		try {
312
			if (configType != null) {
313
				return configType.newInstance(null, name);
314
			}
315
		} catch (CoreException e) {
316
			ExternalToolsCore.log(e);
317
		}
318
		return null;
319
	}
320
	
321
	/**
322
	 * Returns the tool name extracted from the given command argument map.
323
	 * Extraction is attempted using 2.0 and 2.1 external tool formats.
324
	 */
325
	public static String getNameFromCommandArgs(Map commandArgs) {
326
		String name= (String) commandArgs.get(TAG_NAME);
327
		if (name == null) {
328
			name= (String) commandArgs.get(TAG_TOOL_NAME);
329
		}
330
		return name;
331
	}
332
	
333
	/**
334
	 * Migrate the old RUN_IN_BACKGROUND launch config attribute to the new
335
	 * LAUNCH_IN_BACKGROUND attribute provided by the debug ui plugin.
336
	 * 
337
	 * @param config the config to migrate
338
	 * @return the migrated config
339
	 */
340
	public static ILaunchConfiguration migrateRunInBackground(ILaunchConfiguration config) {
341
		String noValueFlag= "NoValue"; //$NON-NLS-1$
342
		String attr= null;
343
		try {
344
			attr = config.getAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, noValueFlag);
345
		} catch (CoreException e) {
346
			// Exception will occur if the attribute is already set because the attribute is actually a boolean.
347
			// No migration necessary.
348
			return config;
349
		}
350
		if (noValueFlag.equals(attr)) {
351
			//the old constant
352
			String ATTR_RUN_IN_BACKGROUND= IExternalToolConstants.UI_PLUGIN_ID + ".ATTR_RUN_IN_BACKGROUND"; //$NON-NLS-1$
353
			boolean runInBackground= false;
354
			try {
355
				runInBackground = config.getAttribute(ATTR_RUN_IN_BACKGROUND, runInBackground);
356
			} catch (CoreException e) {
357
				ExternalToolsCore.log(ExternalToolsMigrationMessages.ExternalToolMigration_37, e);
358
			}
359
			try {
360
				ILaunchConfigurationWorkingCopy workingCopy= config.getWorkingCopy();
361
				workingCopy.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, runInBackground);
362
				config= workingCopy.doSave();
363
			} catch (CoreException e) {
364
				ExternalToolsCore.log(ExternalToolsMigrationMessages.ExternalToolMigration_38, e);
365
			}
366
		}
367
		return config;
368
	}
369
	
370
	/**
371
	 * Extracts a variable name and argument from the given string.
372
	 * 
373
	 * @param text the source text to parse for a variable tag
374
	 * @param start the index in the string to start the search
375
	 * @return the variable definition
376
	 */
377
	public static VariableDefinition extractVariableDefinition(String text, int start) {
378
		VariableDefinition varDef = new VariableDefinition();
379
		
380
		varDef.start = text.indexOf(VAR_TAG_START, start);
381
		if (varDef.start < 0){
382
			return varDef;
383
		}
384
		start = varDef.start + VAR_TAG_START.length();
385
		
386
		int end = text.indexOf(VAR_TAG_END, start);
387
		if (end < 0) {
388
			return varDef;
389
		}
390
		varDef.end = end + VAR_TAG_END.length();
391
		if (end == start) {
392
			return varDef;
393
		}
394
	
395
		int mid = text.indexOf(VAR_TAG_SEP, start);
396
		if (mid < 0 || mid > end) {
397
			varDef.name = text.substring(start, end);
398
		} else {
399
			if (mid > start) {
400
				varDef.name = text.substring(start, mid);
401
			}
402
			mid = mid + VAR_TAG_SEP.length();
403
			if (mid < end) {
404
				varDef.argument = text.substring(mid, end);
405
			}
406
		}
407
		
408
		return varDef;
409
	}	
410
}
(-)src/org/eclipse/core/externaltools/internal/registry/ExternalToolsMigrationMessages.java (+25 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
6
 * 
7
 * Contributors: 
8
 * IBM - Initial API and implementation
9
 **********************************************************************/
10
package org.eclipse.core.externaltools.internal.registry;
11
12
import org.eclipse.osgi.util.NLS;
13
14
public class ExternalToolsMigrationMessages extends NLS {
15
	private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.registry.launchConfigurations.ExternalToolsUIMessages";//$NON-NLS-1$
16
17
	public static String ExternalToolMigration_37;
18
	public static String ExternalToolMigration_38;
19
20
	static {
21
		// load message values from bundle file
22
		NLS.initializeMessages(BUNDLE_NAME,
23
				ExternalToolsMigrationMessages.class);
24
	}
25
}
(-)src/org/eclipse/core/externaltools/internal/registry/ExternalToolsMigrationMessages.properties (+13 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
ExternalToolMigration_37=An exception occurred accessing external tool\'s \"run in background\" attribute
13
ExternalToolMigration_38=An exception occurred attempting to migrate external tool\'s \"run in background\" attribute
(-)src/org/eclipse/core/internal/externaltools/ExternalToolsCore.java (-60 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.core.internal.externaltools;
12
13
import org.eclipse.core.runtime.Plugin;
14
import org.osgi.framework.BundleContext;
15
16
/**
17
 * Controls the plug-in life cycle
18
 */
19
public class ExternalToolsCore extends Plugin {
20
21
	// The plug-in ID
22
	public static final String PLUGIN_ID = "org.eclipse.core.externaltools"; //$NON-NLS-1$
23
24
	// The shared instance
25
	private static ExternalToolsCore plugin;
26
	
27
	/**
28
	 * The constructor
29
	 */
30
	public ExternalToolsCore() {
31
	}
32
33
	/*
34
	 * (non-Javadoc)
35
	 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
36
	 */
37
	public void start(BundleContext context) throws Exception {
38
		super.start(context);
39
		plugin = this;
40
	}
41
42
	/*
43
	 * (non-Javadoc)
44
	 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
45
	 */
46
	public void stop(BundleContext context) throws Exception {
47
		plugin = null;
48
		super.stop(context);
49
	}
50
51
	/**
52
	 * Returns the shared instance
53
	 *
54
	 * @return the shared instance
55
	 */
56
	public static ExternalToolsCore getDefault() {
57
		return plugin;
58
	}
59
60
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java (-41 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-31 Link Here
16
import java.util.Iterator;
16
import java.util.Iterator;
17
import java.util.List;
17
import java.util.List;
18
18
19
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
20
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
19
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IWorkspace;
22
import org.eclipse.core.resources.IWorkspace;
22
import org.eclipse.core.resources.IWorkspaceRoot;
23
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfiguration;
26
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
26
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
27
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
27
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
28
import org.eclipse.debug.ui.DebugUITools;
29
import org.eclipse.jface.viewers.IStructuredContentProvider;
28
import org.eclipse.jface.viewers.IStructuredContentProvider;
30
import org.eclipse.jface.viewers.Viewer;
29
import org.eclipse.jface.viewers.Viewer;
31
import org.eclipse.jface.window.Window;
30
import org.eclipse.jface.window.Window;
Lines 41-47 Link Here
41
import org.eclipse.ui.dialogs.ListSelectionDialog;
40
import org.eclipse.ui.dialogs.ListSelectionDialog;
42
import org.eclipse.ui.externaltools.internal.model.ExternalToolsImages;
41
import org.eclipse.ui.externaltools.internal.model.ExternalToolsImages;
43
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
42
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
44
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
45
import org.eclipse.ui.model.WorkbenchLabelProvider;
43
import org.eclipse.ui.model.WorkbenchLabelProvider;
46
44
47
/**
45
/**
Lines 330-366 Link Here
330
	 * @return collection of projects referred to by configuration
328
	 * @return collection of projects referred to by configuration
331
	 */
329
	 */
332
	public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
330
	public static IProject[] getBuildProjects(ILaunchConfiguration configuration, String buildScopeId) {
333
		String scope = null;
331
		return ExternalToolsCoreUtil.getBuildProjects(configuration,
334
		String id = buildScopeId ;
332
				buildScopeId);
335
		if (id == null) {
333
336
			id = IExternalToolConstants.ATTR_BUILD_SCOPE ;
337
		}
338
		try {
339
			scope = configuration.getAttribute(id, (String)null);
340
		} catch (CoreException e) {
341
			return null;
342
		}
343
		if (scope == null) {
344
			return null;
345
		}
346
		if (scope.startsWith("${projects:")) { //$NON-NLS-1$
347
			String pathString = scope.substring(11, scope.length() - 1);
348
			if (pathString.length() > 1) {
349
				String[] names = pathString.split(","); //$NON-NLS-1$
350
				IProject[] projects = new IProject[names.length];
351
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
352
				for (int i = 0; i < names.length; i++) {
353
					projects[i] = root.getProject(names[i]);
354
				}
355
				return projects;
356
			}
357
		} else if (scope.equals("${project}")) { //$NON-NLS-1$
358
			IResource resource = DebugUITools.getSelectedResource();
359
			if (resource != null) {
360
				return new IProject[]{resource.getProject()};
361
			}
362
		}
363
		return new IProject[0];
364
	}
334
	}
365
	
335
	
366
	/**
336
	/**
Lines 372-382 Link Here
372
	 * @throws CoreException if unable to access the associated attribute
342
	 * @throws CoreException if unable to access the associated attribute
373
	 */
343
	 */
374
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
344
	public static boolean isIncludeReferencedProjects(ILaunchConfiguration configuration, String includeReferencedProjectsId) throws CoreException {
375
		String id = includeReferencedProjectsId;
345
		return ExternalToolsCoreUtil.isIncludeReferencedProjects(configuration,
376
		if (id == null) {
346
				includeReferencedProjectsId);
377
			id = IExternalToolConstants.ATTR_INCLUDE_REFERENCED_PROJECTS ;
378
		}
379
		return configuration.getAttribute(id, true);
380
	}
347
	}
381
	
348
	
382
	/**
349
	/**
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuilderTab.java (-19 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
package org.eclipse.ui.externaltools.internal.launchConfigurations;
12
package org.eclipse.ui.externaltools.internal.launchConfigurations;
13
13
14
14
15
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
16
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
15
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IncrementalProjectBuilder;
18
import org.eclipse.core.resources.IncrementalProjectBuilder;
17
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.ResourcesPlugin;
Lines 50-56 Link Here
50
import org.eclipse.ui.dialogs.IWorkingSetEditWizard;
52
import org.eclipse.ui.dialogs.IWorkingSetEditWizard;
51
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
53
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
52
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
54
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
53
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
54
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
55
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
55
import org.eclipse.ui.ide.IDE;
56
import org.eclipse.ui.ide.IDE;
56
import org.eclipse.ui.model.WorkbenchContentProvider;
57
import org.eclipse.ui.model.WorkbenchContentProvider;
Lines 358-364 Link Here
358
	}
359
	}
359
	
360
	
360
	protected void updateRunInBackground(ILaunchConfiguration configuration) { 
361
	protected void updateRunInBackground(ILaunchConfiguration configuration) { 
361
		fLaunchInBackgroundButton.setSelection(isLaunchInBackground(configuration));
362
		fLaunchInBackgroundButton.setSelection(ExternalToolsCoreUtil.isAsynchronousBuild(configuration));
362
	}
363
	}
363
    
364
    
364
    private void updateConsoleOutput(ILaunchConfiguration configuration) {
365
    private void updateConsoleOutput(ILaunchConfiguration configuration) {
Lines 386-407 Link Here
386
        fVariables.setEnabled(haveOutputFile);
387
        fVariables.setEnabled(haveOutputFile);
387
        fAppend.setEnabled(haveOutputFile);
388
        fAppend.setEnabled(haveOutputFile);
388
    }
389
    }
389
	
390
	/**
391
	 * Returns whether the given configuration should be run in the background.
392
	 * 
393
	 * @param configuration the configuration
394
	 * @return whether the configuration is configured to run in the background
395
	 */
396
	public static boolean isLaunchInBackground(ILaunchConfiguration configuration) {
397
		boolean launchInBackground= false;
398
		try {
399
			launchInBackground= configuration.getAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
400
		} catch (CoreException ce) {
401
			ExternalToolsPlugin.getDefault().log(ce);
402
		}
403
		return launchInBackground;
404
	}
405
390
406
	/* (non-Javadoc)
391
	/* (non-Javadoc)
407
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
392
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.java (-6 / +1 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 48-58 Link Here
48
	public static String ExternalToolsBuildTab_8;
48
	public static String ExternalToolsBuildTab_8;
49
	public static String ExternalToolsBuildTab_9;
49
	public static String ExternalToolsBuildTab_9;
50
50
51
52
	public static String ExternalToolsUtil_Location_not_specified_by__0__1;
53
	public static String ExternalToolsUtil_invalidLocation__0_;
54
	public static String ExternalToolsUtil_invalidDirectory__0_;
55
56
	public static String ExternalToolsBuilderTab_Run_this_builder_for__1;
51
	public static String ExternalToolsBuilderTab_Run_this_builder_for__1;
57
	public static String ExternalToolsBuilderTab__Full_builds_2;
52
	public static String ExternalToolsBuilderTab__Full_builds_2;
58
	public static String ExternalToolsBuilderTab_Full;
53
	public static String ExternalToolsBuilderTab_Full;
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsLaunchConfigurationMessages.properties (-5 / +1 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2007 IBM Corporation and others.
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 43-52 Link Here
43
ExternalToolsBuildTab_8=Build
43
ExternalToolsBuildTab_8=Build
44
ExternalToolsBuildTab_9=No projects specified
44
ExternalToolsBuildTab_9=No projects specified
45
45
46
ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
47
ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
48
ExternalToolsUtil_invalidDirectory__0_ = The working directory {0} does not exist for the external tool named {1}.
49
50
ExternalToolsBuilderTab_Run_this_builder_for__1=Run the builder:
46
ExternalToolsBuilderTab_Run_this_builder_for__1=Run the builder:
51
ExternalToolsBuilderTab__Full_builds_2=A&fter a \"Clean\"
47
ExternalToolsBuilderTab__Full_builds_2=A&fter a \"Clean\"
52
ExternalToolsBuilderTab_Full=Runs on the first build that occurs after a clean.
48
ExternalToolsBuilderTab_Full=Runs on the first build that occurs after a clean.
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsMainTab.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
13
14
import java.io.File;
14
import java.io.File;
15
16
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
15
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
17
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
Lines 46-52 Link Here
46
import org.eclipse.ui.dialogs.ResourceSelectionDialog;
48
import org.eclipse.ui.dialogs.ResourceSelectionDialog;
47
import org.eclipse.ui.externaltools.internal.model.ExternalToolsImages;
49
import org.eclipse.ui.externaltools.internal.model.ExternalToolsImages;
48
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
50
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
49
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
50
51
51
/**
52
/**
52
 * The external tools main tab allows the user to configure primary attributes
53
 * The external tools main tab allows the user to configure primary attributes
(-)External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsUtil.java (-67 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-33 Link Here
13
package org.eclipse.ui.externaltools.internal.launchConfigurations;
13
package org.eclipse.ui.externaltools.internal.launchConfigurations;
14
14
15
15
16
import java.io.File;
16
import org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsCoreUtil;
17
18
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.runtime.Status;
24
import org.eclipse.core.variables.IStringVariableManager;
25
import org.eclipse.core.variables.VariablesPlugin;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.debug.core.ILaunchConfiguration;
28
import org.eclipse.debug.ui.RefreshTab;
23
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
29
import org.eclipse.osgi.util.NLS;
30
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
31
24
32
/**
25
/**
33
 * Utilities for external tool launch configurations.
26
 * Utilities for external tool launch configurations.
Lines 47-53 Link Here
47
	 * @param code error code
40
	 * @param code error code
48
	 */
41
	 */
49
	protected static void abort(String message, Throwable exception, int code) throws CoreException {
42
	protected static void abort(String message, Throwable exception, int code) throws CoreException {
50
		throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, code, message, exception));
43
		throw new CoreException(new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, code, message, exception));
51
	}
44
	}
52
	
45
	
53
	/**
46
	/**
Lines 63-88 Link Here
63
	 * system
56
	 * system
64
	 */
57
	 */
65
	public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
58
	public static IPath getLocation(ILaunchConfiguration configuration) throws CoreException {
66
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_LOCATION, (String) null);
59
		return ExternalToolsCoreUtil.getLocation(configuration);
67
		if (location == null) {
68
			abort(NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_Location_not_specified_by__0__1, new String[] { configuration.getName()}), null, 0);
69
		} else {
70
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
71
			if (expandedLocation == null || expandedLocation.length() == 0) {
72
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
73
				abort(msg, null, 0);
74
			} else {
75
				File file = new File(expandedLocation);
76
				if (file.isFile()) {
77
					return new Path(expandedLocation);
78
				} 
79
				
80
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidLocation__0_, new Object[] { configuration.getName()});
81
				abort(msg, null, 0);
82
			}
83
		}
84
		// execution will not reach here
85
		return null;
86
	}
60
	}
87
	
61
	
88
	/**
62
	/**
Lines 95-101 Link Here
95
	 * @throws CoreException if unable to access the associated attribute
69
	 * @throws CoreException if unable to access the associated attribute
96
	 */
70
	 */
97
	public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
71
	public static boolean getCaptureOutput(ILaunchConfiguration configuration) throws CoreException {
98
	    return configuration.getAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
72
	    return ExternalToolsCoreUtil.getCaptureOutput(configuration);
99
	}
73
	}
100
74
101
	/**
75
	/**
Lines 113-131 Link Here
113
	 * file system
87
	 * file system
114
	 */
88
	 */
115
	public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
89
	public static IPath getWorkingDirectory(ILaunchConfiguration configuration) throws CoreException {
116
		String location = configuration.getAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) null);
90
		return ExternalToolsCoreUtil.getWorkingDirectory(configuration);
117
		if (location != null) {
118
			String expandedLocation = getStringVariableManager().performStringSubstitution(location);
119
			if (expandedLocation.length() > 0) {
120
				File path = new File(expandedLocation);
121
				if (path.isDirectory()) {
122
					return new Path(expandedLocation);
123
				} 
124
				String msg = NLS.bind(ExternalToolsLaunchConfigurationMessages.ExternalToolsUtil_invalidDirectory__0_, new Object[] { expandedLocation, configuration.getName()});
125
				abort(msg, null, 0);
126
			}
127
		}
128
		return null;
129
	}
91
	}
130
92
131
	/**
93
	/**
Lines 139-154 Link Here
139
	 * configuration attribute, or if unable to resolve any variables
101
	 * configuration attribute, or if unable to resolve any variables
140
	 */
102
	 */
141
	public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
103
	public static String[] getArguments(ILaunchConfiguration configuration) throws CoreException {
142
		String args = configuration.getAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, (String) null);
104
		return ExternalToolsCoreUtil.getArguments(configuration);
143
		if (args != null) {
144
			String expanded = getStringVariableManager().performStringSubstitution(args);
145
			return parseStringIntoList(expanded);
146
		}
147
		return null;
148
	}
149
150
	private static IStringVariableManager getStringVariableManager() {
151
		return VariablesPlugin.getDefault().getStringVariableManager();
152
	}
105
	}
153
	
106
	
154
	/**
107
	/**
Lines 163-169 Link Here
163
	 * @throws CoreException if unable to access the associated attribute
116
	 * @throws CoreException if unable to access the associated attribute
164
	 */
117
	 */
165
	public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
118
	public static boolean isBuilderEnabled(ILaunchConfiguration configuration) throws CoreException {
166
		return configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_ENABLED, true);
119
		return ExternalToolsCoreUtil.isBuilderEnabled(configuration);
167
	}
120
	}
168
	
121
	
169
	/**
122
	/**
Lines 173-184 Link Here
173
	 * @throws CoreException if an exception occurs while retrieving the resources
126
	 * @throws CoreException if an exception occurs while retrieving the resources
174
	 */
127
	 */
175
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
128
	public static IResource[] getResourcesForBuildScope(ILaunchConfiguration configuration) throws CoreException {
176
		String scope = configuration.getAttribute(IExternalToolConstants.ATTR_BUILDER_SCOPE, (String) null);
129
		return ExternalToolsCoreUtil.getResourcesForBuildScope(configuration);
177
		if (scope == null) {
178
			return null;
179
		}
180
	
181
		return RefreshTab.getRefreshResources(scope);
182
	}
130
	}
183
	
131
	
184
	/**
132
	/**
Lines 193-203 Link Here
193
	 * @return the array of arguments
141
	 * @return the array of arguments
194
	 */
142
	 */
195
	public static String[] parseStringIntoList(String arguments) {
143
	public static String[] parseStringIntoList(String arguments) {
196
		if (arguments == null || arguments.length() == 0) {
144
		return ExternalToolsCoreUtil.parseStringIntoList(arguments);
197
			return new String[0];
198
		}
199
		String[] res= DebugPlugin.parseArguments(arguments);
200
		return res;		
201
	}	
145
	}	
202
	
146
	
203
}
147
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/menu/ExternalToolMenuDelegate.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.menu;
11
package org.eclipse.ui.externaltools.internal.menu;
12
12
13
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
13
import org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction;
14
import org.eclipse.debug.ui.actions.AbstractLaunchToolbarAction;
14
import org.eclipse.jface.action.IAction;
15
import org.eclipse.jface.action.IAction;
15
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
16
16
17
/**
17
/**
18
 * This action delegate is responsible for producing the
18
 * This action delegate is responsible for producing the
(-)External Tools Base/org/eclipse/ui/externaltools/internal/menu/OpenExternalToolsConfigurations.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.menu;
11
package org.eclipse.ui.externaltools.internal.menu;
12
12
13
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
13
import org.eclipse.debug.ui.actions.OpenLaunchDialogAction;
14
import org.eclipse.debug.ui.actions.OpenLaunchDialogAction;
14
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
15
15
16
/**
16
/**
17
 * Opens the launch config dialog on the external tools launch group.
17
 * Opens the launch config dialog on the external tools launch group.
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/BuilderUtils.java (-216 / +16 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-75 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.model;
11
package org.eclipse.ui.externaltools.internal.model;
12
12
13
import java.util.HashMap;
14
import java.util.Map;
13
import java.util.Map;
15
import java.util.StringTokenizer;
16
14
15
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
16
import org.eclipse.core.externaltools.internal.model.BuilderCoreUtils;
17
import org.eclipse.core.resources.ICommand;
17
import org.eclipse.core.resources.ICommand;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IFolder;
18
import org.eclipse.core.resources.IFolder;
20
import org.eclipse.core.resources.IProject;
19
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IncrementalProjectBuilder;
23
import org.eclipse.core.resources.ResourcesPlugin;
24
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
25
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.IConfigurationElement;
26
import org.eclipse.core.runtime.IExtensionPoint;
22
import org.eclipse.core.runtime.IExtensionPoint;
27
import org.eclipse.core.runtime.IPath;
28
import org.eclipse.core.runtime.IStatus;
29
import org.eclipse.core.runtime.NullProgressMonitor;
30
import org.eclipse.core.runtime.Path;
31
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.Platform;
32
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.DebugPlugin;
33
import org.eclipse.debug.core.ILaunchConfiguration;
25
import org.eclipse.debug.core.ILaunchConfiguration;
34
import org.eclipse.debug.core.ILaunchConfigurationType;
26
import org.eclipse.debug.core.ILaunchConfigurationType;
35
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
27
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
36
import org.eclipse.debug.core.ILaunchManager;
37
import org.eclipse.jface.dialogs.MessageDialog;
28
import org.eclipse.jface.dialogs.MessageDialog;
38
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.swt.widgets.Shell;
39
import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration;
40
30
41
/**
31
/**
42
 * Utility methods for working with external tool project builders.
32
 * Utility methods for working with external tool project builders.
43
 */
33
 */
44
public class BuilderUtils {
34
public class BuilderUtils {
45
46
	public static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle"; //$NON-NLS-1$
47
48
	/**
49
	 * Constant used to find a builder using the 3.0-interim format
50
	 */
51
	public static final String BUILDER_FOLDER_NAME= ".externalToolBuilders"; //$NON-NLS-1$
52
	/**
53
	 * Constant used to represent the current project in the 3.0-final format.
54
	 */
55
	public static final String PROJECT_TAG= "<project>"; //$NON-NLS-1$
56
	
57
	public static final String VERSION_1_0= "1.0"; //$NON-NLS-1$
58
	public static final String VERSION_2_1= "2.1"; //$NON-NLS-1$
59
	// The format shipped up to and including Eclipse 3.0 RC1
60
	public static final String VERSION_3_0_interim= "3.0.interim"; //$NON-NLS-1$
61
	// The format shipped in Eclipse 3.0 final
62
	public static final String VERSION_3_0_final= "3.0"; //$NON-NLS-1$
63
	
35
	
64
	// Extension point constants.
36
	// Extension point constants.
65
	private static final String TAG_CONFIGURATION_MAP= "configurationMap"; //$NON-NLS-1$
37
	private static final String TAG_CONFIGURATION_MAP = "configurationMap"; //$NON-NLS-1$
66
	private static final String TAG_SOURCE_TYPE= "sourceType"; //$NON-NLS-1$
38
	private static final String TAG_SOURCE_TYPE = "sourceType"; //$NON-NLS-1$
67
	private static final String TAG_BUILDER_TYPE= "builderType"; //$NON-NLS-1$
39
	private static final String TAG_BUILDER_TYPE = "builderType"; //$NON-NLS-1$	
68
    
69
    private static final String BUILD_TYPE_SEPARATOR = ","; //$NON-NLS-1$
70
    private static final int[] DEFAULT_BUILD_TYPES= new int[] {
71
                                    IncrementalProjectBuilder.INCREMENTAL_BUILD,
72
                                    IncrementalProjectBuilder.FULL_BUILD};
73
40
74
	/**
41
	/**
75
	 * Returns a launch configuration from the given ICommand arguments. If the
42
	 * Returns a launch configuration from the given ICommand arguments. If the
Lines 81-122 Link Here
81
	 * <code>null</code> if not possible.
48
	 * <code>null</code> if not possible.
82
	 */
49
	 */
83
	public static ILaunchConfiguration configFromBuildCommandArgs(IProject project, Map commandArgs, String[] version) {
50
	public static ILaunchConfiguration configFromBuildCommandArgs(IProject project, Map commandArgs, String[] version) {
84
		String configHandle = (String) commandArgs.get(LAUNCH_CONFIG_HANDLE);
51
		return BuilderCoreUtils.configFromBuildCommandArgs(project, commandArgs, version);
85
		if (configHandle == null) {
86
			// Probably an old-style (Eclipse 1.0 or 2.0) external tool. Try to migrate.
87
			version[0]= VERSION_1_0;
88
			return ExternalToolMigration.configFromArgumentMap(commandArgs);
89
		}
90
		ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
91
		ILaunchConfiguration configuration= null;
92
		if (configHandle.startsWith(PROJECT_TAG)) {
93
			version[0]= VERSION_3_0_final;
94
			IPath path= new Path(configHandle);
95
			IFile file= project.getFile(path.removeFirstSegments(1));
96
			if (file.exists()) {
97
				configuration= manager.getLaunchConfiguration(file);
98
			}
99
		} else {
100
		    // Try treating the handle as a file name.
101
			// This is the format used in 3.0 RC1.
102
			IPath path= new Path(BUILDER_FOLDER_NAME).append(configHandle);
103
			IFile file= project.getFile(path);
104
			if (file.exists()) {
105
				version[0]= VERSION_3_0_interim;
106
				configuration= manager.getLaunchConfiguration(file);
107
			} else {
108
				try {
109
					// Treat the configHandle as a memento. This is the format
110
					// used in Eclipse 2.1.
111
					configuration = manager.getLaunchConfiguration(configHandle);
112
				} catch (CoreException e) {
113
				}
114
				if (configuration != null) {
115
					version[0]= VERSION_2_1;
116
				}
117
			}
118
		}
119
		return configuration;
120
	}
52
	}
121
53
122
	/**
54
	/**
Lines 144-176 Link Here
144
	}
76
	}
145
	
77
	
146
	public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException {
78
	public static void configureTriggers(ILaunchConfiguration config, ICommand newCommand) throws CoreException {
147
		newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, false);
79
		BuilderCoreUtils.configureTriggers(config, newCommand);
148
		newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, false);
149
		newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, false);
150
		newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, false);
151
		String buildKinds= config.getAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String)null);
152
		int[] triggers= BuilderUtils.buildTypesToArray(buildKinds);
153
		for (int i = 0; i < triggers.length; i++) {
154
			switch (triggers[i]) {
155
				case IncrementalProjectBuilder.FULL_BUILD:
156
					newCommand.setBuilding(IncrementalProjectBuilder.FULL_BUILD, true);
157
					break;
158
				case IncrementalProjectBuilder.INCREMENTAL_BUILD:
159
					newCommand.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, true);
160
					break;
161
				case IncrementalProjectBuilder.AUTO_BUILD:
162
					newCommand.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, true);
163
					break;
164
				case IncrementalProjectBuilder.CLEAN_BUILD:
165
					newCommand.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, true);
166
					break;
167
			}
168
		}
169
		if (!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false)) {
170
			ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
171
			copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
172
			copy.doSave();
173
		}
174
	}
80
	}
175
81
176
	/**
82
	/**
Lines 184-190 Link Here
184
	 * @return whether the given config represents an unmigrated builder
90
	 * @return whether the given config represents an unmigrated builder
185
	 */
91
	 */
186
	public static boolean isUnmigratedConfig(ILaunchConfiguration config) {
92
	public static boolean isUnmigratedConfig(ILaunchConfiguration config) {
187
		return config.isWorkingCopy() && ((ILaunchConfigurationWorkingCopy) config).getOriginal() == null;
93
		return BuilderCoreUtils.isUnmigratedConfig(config);
188
	}
94
	}
189
95
190
	/**
96
	/**
Lines 194-230 Link Here
194
	 * @return the configured build command
100
	 * @return the configured build command
195
	 */
101
	 */
196
	public static ICommand toBuildCommand(IProject project, ILaunchConfiguration config, ICommand command) throws CoreException {
102
	public static ICommand toBuildCommand(IProject project, ILaunchConfiguration config, ICommand command) throws CoreException {
197
		Map args= null;
103
		return BuilderCoreUtils.toBuildCommand(project, config, command);
198
		if (isUnmigratedConfig(config)) {
199
			// This config represents an old external tool builder that hasn't
200
			// been edited. Try to find the old ICommand and reuse the arguments.
201
			// The goal here is to not change the storage format of old, unedited builders.
202
			ICommand[] commands= project.getDescription().getBuildSpec();
203
			for (int i = 0; i < commands.length; i++) {
204
				ICommand projectCommand = commands[i];
205
				String name= ExternalToolMigration.getNameFromCommandArgs(projectCommand.getArguments());
206
				if (name != null && name.equals(config.getName())) {
207
					args= projectCommand.getArguments();
208
					break;
209
				}
210
			}
211
		} else {
212
			if (config instanceof ILaunchConfigurationWorkingCopy) {
213
				ILaunchConfigurationWorkingCopy workingCopy= (ILaunchConfigurationWorkingCopy) config;
214
				if (workingCopy.getOriginal() != null) {
215
					config= workingCopy.getOriginal();
216
				}
217
			}
218
			args= new HashMap();
219
			// Launch configuration builders are stored with a project-relative path
220
			StringBuffer buffer= new StringBuffer(PROJECT_TAG);
221
			// Append the project-relative path (workspace path minus first segment)
222
			buffer.append('/').append(config.getFile().getFullPath().removeFirstSegments(1));
223
			args.put(LAUNCH_CONFIG_HANDLE, buffer.toString());
224
		}
225
		command.setBuilderName(ExternalToolBuilder.ID);
226
		command.setArguments(args);
227
		return command;
228
	}
104
	}
229
	
105
	
230
	/**
106
	/**
Lines 233-239 Link Here
233
	 * if an extension has been specified to explicitly declare the mapping.
109
	 * if an extension has been specified to explicitly declare the mapping.
234
	 */
110
	 */
235
	public static ILaunchConfigurationType getConfigurationDuplicationType(ILaunchConfiguration config) throws CoreException {
111
	public static ILaunchConfigurationType getConfigurationDuplicationType(ILaunchConfiguration config) throws CoreException {
236
		IExtensionPoint ep= Platform.getExtensionRegistry().getExtensionPoint(IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS); 
112
		IExtensionPoint ep= Platform.getExtensionRegistry().getExtensionPoint(ExternalToolsPlugin.PLUGIN_ID, IExternalToolConstants.EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS); 
237
		IConfigurationElement[] elements = ep.getConfigurationElements();
113
		IConfigurationElement[] elements = ep.getConfigurationElements();
238
		String sourceType= config.getType().getIdentifier();
114
		String sourceType= config.getType().getIdentifier();
239
		String builderType= null;
115
		String builderType= null;
Lines 258-272 Link Here
258
	 * <code>null</code> if the folder could not be created
134
	 * <code>null</code> if the folder could not be created
259
	 */
135
	 */
260
	public static IFolder getBuilderFolder(IProject project, boolean create) {
136
	public static IFolder getBuilderFolder(IProject project, boolean create) {
261
		IFolder folder = project.getFolder(BUILDER_FOLDER_NAME);
137
		return BuilderCoreUtils.getBuilderFolder(project, create);
262
		if (!folder.exists() && create) {
263
			try {
264
				folder.create(true, true, new NullProgressMonitor());
265
			} catch (CoreException e) {
266
				return null;
267
			}
268
		}
269
		return folder;
270
	}
138
	}
271
139
272
	/**
140
	/**
Lines 302-323 Link Here
302
	 * new launch configuration
170
	 * new launch configuration
303
	 */
171
	 */
304
	public static ILaunchConfiguration migrateBuilderConfiguration(IProject project, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
172
	public static ILaunchConfiguration migrateBuilderConfiguration(IProject project, ILaunchConfigurationWorkingCopy workingCopy) throws CoreException {
305
		workingCopy.setContainer(getBuilderFolder(project, true));
173
		return BuilderCoreUtils.migrateBuilderConfiguration(project, workingCopy);
306
		// Before saving, make sure the name is valid
307
		String name= workingCopy.getName();
308
		name= name.replace('/', '.');
309
		if (name.charAt(0) == ('.')) {
310
			name = name.substring(1);
311
		}
312
		IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
313
		if (!status.isOK()) {
314
			name = "ExternalTool"; //$NON-NLS-1$
315
		}
316
		name = DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name);
317
		workingCopy.rename(name);
318
		return workingCopy.doSave();
319
	}
174
	}
320
175
	
321
    /**
176
    /**
322
     * Converts the build types string into an array of
177
     * Converts the build types string into an array of
323
     * build kinds.
178
     * build kinds.
Lines 326-386 Link Here
326
     * @return the array of build kinds.
181
     * @return the array of build kinds.
327
     */
182
     */
328
    public static int[] buildTypesToArray(String buildTypes) {
183
    public static int[] buildTypesToArray(String buildTypes) {
329
    	if (buildTypes == null || buildTypes.length() == 0) {
184
    	return BuilderCoreUtils.buildTypesToArray(buildTypes);
330
    		return DEFAULT_BUILD_TYPES;
185
    }	
331
    	}
332
    	
333
    	int count = 0;
334
    	boolean incremental = false;
335
    	boolean full = false;
336
    	boolean auto = false;
337
        boolean clean= false;
338
    
339
    	StringTokenizer tokenizer = new StringTokenizer(buildTypes, BUILD_TYPE_SEPARATOR);
340
    	while (tokenizer.hasMoreTokens()) {
341
    		String token = tokenizer.nextToken();
342
    		if (IExternalToolConstants.BUILD_TYPE_INCREMENTAL.equals(token)) {
343
    			if (!incremental) {
344
    				incremental = true;
345
    				count++;
346
    			}
347
    		} else if (IExternalToolConstants.BUILD_TYPE_FULL.equals(token)) {
348
    			if (!full) {
349
    				full = true;
350
    				count++;
351
    			}
352
    		} else if (IExternalToolConstants.BUILD_TYPE_AUTO.equals(token)) {
353
    			if (!auto) {
354
    				auto = true;
355
    				count++;
356
    			}
357
    		} else if (IExternalToolConstants.BUILD_TYPE_CLEAN.equals(token)) {
358
                if (!clean) {
359
                    clean = true;
360
                    count++;
361
                }
362
            }
363
    	}
364
    
365
    	int[] results = new int[count];
366
    	count = 0;
367
    	if (incremental) {
368
    		results[count] = IncrementalProjectBuilder.INCREMENTAL_BUILD;
369
    		count++;
370
    	}
371
    	if (full) {
372
    		results[count] = IncrementalProjectBuilder.FULL_BUILD;
373
    		count++;
374
    	}
375
    	if (auto) {
376
    		results[count] = IncrementalProjectBuilder.AUTO_BUILD;
377
    		count++;
378
    	}
379
        if (clean) {
380
            results[count] = IncrementalProjectBuilder.CLEAN_BUILD;
381
            count++;
382
        }
383
    
384
    	return results;
385
    }
386
}
186
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolBuilder.java (-288 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Matthew Conway  - Bug 175186
11
 *******************************************************************************/
12
package org.eclipse.ui.externaltools.internal.model;
13
14
15
import java.util.Map;
16
17
import org.eclipse.core.resources.ICommand;
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IProjectDescription;
21
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IResourceDelta;
23
import org.eclipse.core.resources.IResourceDeltaVisitor;
24
import org.eclipse.core.resources.IncrementalProjectBuilder;
25
import org.eclipse.core.runtime.CoreException;
26
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.debug.core.ILaunchConfiguration;
29
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
30
import org.eclipse.debug.core.ILaunchManager;
31
import org.eclipse.osgi.util.NLS;
32
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
33
import org.eclipse.ui.externaltools.internal.registry.ExternalToolMigration;
34
import org.osgi.framework.Bundle;
35
36
/**
37
 * This project builder implementation will run an external tool during the
38
 * build process. 
39
 */
40
public final class ExternalToolBuilder extends IncrementalProjectBuilder {
41
	private final class IgnoreTeamPrivateChanges implements IResourceDeltaVisitor {
42
		private boolean[] fTrueChange;
43
		private IgnoreTeamPrivateChanges(boolean[] trueChange) {
44
			super();
45
			fTrueChange= trueChange;
46
		}
47
		public boolean visit(IResourceDelta visitDelta) throws CoreException {
48
			IResource resource= visitDelta.getResource();
49
			if (resource instanceof IFile) {
50
				fTrueChange[0]= true;
51
				return false;
52
			}
53
			return true;
54
		}
55
	}
56
57
	public static final String ID = "org.eclipse.ui.externaltools.ExternalToolBuilder"; //$NON-NLS-1$;
58
59
	private static String buildType = IExternalToolConstants.BUILD_TYPE_NONE;
60
	
61
	private static IProject buildProject= null;
62
    private static IResourceDelta buildDelta= null;
63
	
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
66
	 */
67
	protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {		
68
		if (ExternalToolsPlugin.getDefault().getBundle().getState() != Bundle.ACTIVE) {
69
			return null;
70
		}
71
		
72
		ILaunchConfiguration config= BuilderUtils.configFromBuildCommandArgs(getProject(), args, new String[1]);
73
        if (config == null) {
74
            throw ExternalToolsPlugin.newError(ExternalToolsModelMessages.ExternalToolBuilder_0, null);
75
        }
76
		IProject[] projectsWithinScope= null;
77
		IResource[] resources = ExternalToolsUtil.getResourcesForBuildScope(config);
78
		if (resources != null) {
79
			projectsWithinScope= new IProject[resources.length];
80
			for (int i = 0; i < resources.length; i++) {
81
				projectsWithinScope[i]= resources[i].getProject();
82
			}
83
		}
84
        boolean kindCompatible= commandConfiguredForKind(config, kind);
85
        if (kindCompatible && configEnabled(config)) {
86
            doBuildBasedOnScope(resources, kind, config, monitor);
87
        }
88
        
89
		return projectsWithinScope;
90
	}
91
92
    private boolean commandConfiguredForKind(ILaunchConfiguration config, int kind) {
93
        try {
94
            if (!(config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
95
                ICommand command= getCommand();
96
                //adapt the builder command to make use of the 3.1 support for setting command build kinds
97
                //this will only happen once for builder/command defined before the support existed
98
                BuilderUtils.configureTriggers(config, command);
99
                IProjectDescription desc= getProject().getDescription();
100
                ICommand[] commands= desc.getBuildSpec();
101
                int index= getBuilderCommandIndex(commands, command);
102
                if (index != -1) {
103
                    commands[index]= command;
104
                    desc.setBuildSpec(commands);
105
                    getProject().setDescription(desc, null);
106
                    ILaunchConfigurationWorkingCopy copy= config.getWorkingCopy();
107
                    copy.setAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, true);
108
                    copy.doSave();
109
                }
110
                return command.isBuilding(kind);
111
            }
112
        } catch (CoreException e) {
113
           ExternalToolsPlugin.getDefault().log(e);
114
           return true;
115
        }
116
        return true;
117
    }
118
    
119
    private int getBuilderCommandIndex(ICommand[] buildSpec, ICommand command) {
120
        Map commandArgs= command.getArguments();
121
        if (commandArgs == null) {
122
            return -1;
123
        }
124
        String handle= (String) commandArgs.get(BuilderUtils.LAUNCH_CONFIG_HANDLE);
125
        if (handle == null) {
126
            return -1;
127
        }
128
        for (int i = 0; i < buildSpec.length; ++i) {
129
            ICommand buildSpecCommand= buildSpec[i];
130
            if (ID.equals(buildSpecCommand.getBuilderName())) {
131
                Map buildSpecArgs= buildSpecCommand.getArguments();
132
                if (buildSpecArgs != null) {
133
                    String buildSpecHandle= (String) buildSpecArgs.get(BuilderUtils.LAUNCH_CONFIG_HANDLE);
134
                    if (handle.equals(buildSpecHandle)) {
135
                        return i;
136
                    }
137
                }
138
            }
139
        }
140
        return -1;
141
    }
142
143
	/**
144
	 * Returns whether the given builder config is enabled or not.
145
	 * 
146
	 * @param config the config to examine
147
	 * @return whether the config is enabled
148
	 */
149
	private boolean configEnabled(ILaunchConfiguration config) {
150
		try {
151
			return ExternalToolsUtil.isBuilderEnabled(config);
152
		} catch (CoreException e) {
153
			ExternalToolsPlugin.getDefault().log(e);
154
		}
155
		return true;
156
	}
157
158
	private void doBuildBasedOnScope(IResource[] resources, int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
159
		boolean buildForChange = true;
160
		if (kind != FULL_BUILD) { //scope not applied for full builds
161
			if (resources != null && resources.length > 0) {
162
				buildForChange = buildScopeIndicatesBuild(resources);
163
			}
164
		}
165
166
		if (buildForChange) {
167
			launchBuild(kind, config, monitor);
168
		}
169
	}
170
	
171
	private void launchBuild(int kind, ILaunchConfiguration config, IProgressMonitor monitor) throws CoreException {
172
		monitor.subTask(NLS.bind(ExternalToolsModelMessages.ExternalToolBuilder_Running__0_____1, new String[] { config.getName()}));
173
		buildStarted(kind);
174
		// The default value for "launch in background" is true in debug core. If
175
		// the user doesn't go through the UI, the new attribute won't be set. This means
176
		// that existing Ant builders will try to run in the background (and likely conflict with
177
		// each other) without migration.
178
		config= ExternalToolMigration.migrateRunInBackground(config);
179
		config.launch(ILaunchManager.RUN_MODE, monitor);
180
		buildEnded();
181
	}
182
183
	/**
184
	 * Returns the build type being performed if the
185
	 * external tool is being run as a project builder.
186
	 * 
187
	 * @return one of the <code>IExternalToolConstants.BUILD_TYPE_*</code> constants.
188
	 */
189
	public static String getBuildType() {
190
		return buildType;
191
	}
192
	
193
	/**
194
	 * Returns the project that is being built and has triggered the current external
195
	 * tool builder. <code>null</code> is returned if no build is currently occurring.
196
	 * 
197
	 * @return project being built or <code>null</code>.
198
	 */
199
	public static IProject getBuildProject() {
200
		return buildProject;
201
	}
202
203
    /**
204
     * Returns the <code>IResourceDelta</code> that is being built and has triggered the current external
205
     * tool builder. <code>null</code> is returned if no build is currently occurring.
206
     * 
207
     * @return resource delta for the build or <code>null</code>
208
     */
209
    public static IResourceDelta getBuildDelta() {
210
        return buildDelta;
211
    }
212
    
213
	/**
214
	 * Stores the currently active build kind and build project when a build begins
215
	 * @param buildKind
216
	 */
217
	private void buildStarted(int buildKind) {
218
		switch (buildKind) {
219
			case IncrementalProjectBuilder.INCREMENTAL_BUILD :
220
				buildType = IExternalToolConstants.BUILD_TYPE_INCREMENTAL;
221
				buildDelta = getDelta(getProject());
222
				break;
223
			case IncrementalProjectBuilder.FULL_BUILD :
224
				buildType = IExternalToolConstants.BUILD_TYPE_FULL;
225
				break;
226
			case IncrementalProjectBuilder.AUTO_BUILD :
227
				buildType = IExternalToolConstants.BUILD_TYPE_AUTO;
228
				buildDelta = getDelta(getProject());
229
				break;
230
            case IncrementalProjectBuilder.CLEAN_BUILD :
231
                buildType = IExternalToolConstants.BUILD_TYPE_CLEAN;
232
                break;
233
			default :
234
				buildType = IExternalToolConstants.BUILD_TYPE_NONE;
235
				break;
236
		}
237
		buildProject= getProject();
238
	}
239
	
240
	/**
241
	 * Clears the current build kind, build project and build delta when a build finishes.
242
	 */
243
	private void buildEnded() {
244
		buildType= IExternalToolConstants.BUILD_TYPE_NONE;
245
		buildProject= null;
246
        buildDelta= null;
247
	}
248
	
249
	private boolean buildScopeIndicatesBuild(IResource[] resources) {
250
		for (int i = 0; i < resources.length; i++) {
251
			IResourceDelta delta = getDelta(resources[i].getProject());
252
			if (delta == null) {
253
				//project just added to the workspace..no previous build tree
254
				return true;
255
			} 
256
			IPath path= resources[i].getProjectRelativePath();
257
			IResourceDelta change= delta.findMember(path);
258
			if (change != null) {
259
				final boolean[] trueChange= new boolean[1];
260
				trueChange[0]= false;
261
				try {
262
					change.accept(new IgnoreTeamPrivateChanges(trueChange));
263
				} catch (CoreException e) {
264
					ExternalToolsPlugin.getDefault().log("Internal error resolving changed resources during build", e); //$NON-NLS-1$
265
				}
266
				
267
				return trueChange[0]; //filtered out team private changes
268
			}
269
		}
270
		return false;
271
	}
272
    
273
    protected void clean(IProgressMonitor monitor) throws CoreException {
274
	    ICommand command= getCommand();
275
        ILaunchConfiguration config= BuilderUtils.configFromBuildCommandArgs(getProject(), command.getArguments(), new String[1]);
276
    	if (!configEnabled(config)) {
277
	    	return;
278
	    }
279
        
280
        if ((!config.getAttribute(IExternalToolConstants.ATTR_TRIGGERS_CONFIGURED, false))) {
281
            //old behavior
282
            super.clean(monitor);
283
            return;
284
        }
285
	
286
		launchBuild(IncrementalProjectBuilder.CLEAN_BUILD, config, monitor);
287
    }
288
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsImages.java (-1 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import java.net.MalformedURLException;
14
import java.net.MalformedURLException;
15
import java.net.URL;
15
import java.net.URL;
16
16
17
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.resource.CompositeImageDescriptor;
19
import org.eclipse.jface.resource.CompositeImageDescriptor;
19
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.resource.ImageDescriptor;
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 15-22 Link Here
15
	private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.internal.model.ExternalToolsModelMessages";//$NON-NLS-1$
15
	private static final String BUNDLE_NAME = "org.eclipse.ui.externaltools.internal.model.ExternalToolsModelMessages";//$NON-NLS-1$
16
    
16
    
17
	public static String ImageDescriptorRegistry_Allocating_image_for_wrong_display_1;
17
	public static String ImageDescriptorRegistry_Allocating_image_for_wrong_display_1;
18
	public static String ExternalToolBuilder_Running__0_____1;
19
	public static String ExternalToolBuilder_0;
20
	public static String BuilderUtils_5;
18
	public static String BuilderUtils_5;
21
	public static String BuilderUtils_6;
19
	public static String BuilderUtils_6;
22
	public static String BuilderUtils_7;
20
	public static String BuilderUtils_7;
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsModelMessages.properties (-3 / +1 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2005 IBM Corporation and others.
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 10-17 Link Here
10
###############################################################################
10
###############################################################################
11
11
12
ImageDescriptorRegistry_Allocating_image_for_wrong_display_1=Allocating image for wrong display
12
ImageDescriptorRegistry_Allocating_image_for_wrong_display_1=Allocating image for wrong display
13
ExternalToolBuilder_Running__0_____1=Running {0}...
14
ExternalToolBuilder_0=The builder launch configuration could not be found.
15
BuilderUtils_5=Command Error
13
BuilderUtils_5=Command Error
16
BuilderUtils_6=An error occurred while saving the build commands of the project
14
BuilderUtils_6=An error occurred while saving the build commands of the project
17
BuilderUtils_7=\ [Builder]
15
BuilderUtils_7=\ [Builder]
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ExternalToolsPlugin.java (-9 / +127 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-28 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.model;
11
package org.eclipse.ui.externaltools.internal.model;
12
12
13
14
import java.net.MalformedURLException;
13
import java.net.MalformedURLException;
15
import java.net.URL;
14
import java.net.URL;
16
15
16
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.Status;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.ILaunch;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.ILaunchConfigurationType;
24
import org.eclipse.debug.core.ILaunchListener;
25
import org.eclipse.debug.core.ILaunchManager;
26
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.resource.ImageDescriptor;
27
import org.eclipse.jface.resource.ImageDescriptor;
21
import org.eclipse.jface.resource.ImageRegistry;
28
import org.eclipse.jface.resource.ImageRegistry;
22
import org.eclipse.swt.widgets.Display;
29
import org.eclipse.swt.widgets.Display;
23
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.IWindowListener;
24
import org.eclipse.ui.IWorkbenchPage;
32
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.IWorkbenchWindow;
33
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.PlatformUI;
35
import org.eclipse.ui.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages;
26
import org.eclipse.ui.plugin.AbstractUIPlugin;
36
import org.eclipse.ui.plugin.AbstractUIPlugin;
27
import org.osgi.framework.Bundle;
37
import org.osgi.framework.Bundle;
28
import org.osgi.framework.BundleContext;
38
import org.osgi.framework.BundleContext;
Lines 30-44 Link Here
30
/**
40
/**
31
 * External tools plug-in class
41
 * External tools plug-in class
32
 */
42
 */
33
public final class ExternalToolsPlugin extends AbstractUIPlugin {
43
public final class ExternalToolsPlugin extends AbstractUIPlugin implements
44
		ILaunchListener {
45
	
46
	public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$
47
	
34
	/**
48
	/**
35
	 * Status representing no problems encountered during operation.
49
	 * Status representing no problems encountered during operation.
36
	 */
50
	 */
37
	public static final IStatus OK_STATUS = new Status(IStatus.OK, IExternalToolConstants.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
51
	public static final IStatus OK_STATUS = new Status(IStatus.OK, PLUGIN_ID, 0, "", null); //$NON-NLS-1$
38
52
		
39
	private static ExternalToolsPlugin plugin;
53
	private static ExternalToolsPlugin plugin;
40
	
54
41
	private static final String EMPTY_STRING= ""; //$NON-NLS-1$
55
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
56
57
	private static IWindowListener fWindowListener;
58
59
	private static ILaunchManager launchManager;
60
61
	/**
62
	 * A window listener that warns the user about any running programs when the
63
	 * workbench closes. Programs are killed when the VM exits.
64
	 */
65
	private class ProgramLaunchWindowListener implements IWindowListener {
66
		public void windowActivated(IWorkbenchWindow window) {
67
		}
68
69
		public void windowDeactivated(IWorkbenchWindow window) {
70
		}
71
72
		public void windowClosed(IWorkbenchWindow window) {
73
			IWorkbenchWindow windows[] = PlatformUI.getWorkbench()
74
					.getWorkbenchWindows();
75
			if (windows.length > 1) {
76
				// There are more windows still open.
77
				return;
78
			}
79
			ILaunchManager manager = DebugPlugin.getDefault()
80
					.getLaunchManager();
81
			ILaunchConfigurationType programType = manager
82
					.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
83
			if (programType == null) {
84
				return;
85
			}
86
			ILaunch launches[] = manager.getLaunches();
87
			ILaunchConfigurationType configType;
88
			ILaunchConfiguration config;
89
			for (int i = 0; i < launches.length; i++) {
90
				try {
91
					config = launches[i].getLaunchConfiguration();
92
					if (config == null) {
93
						continue;
94
					}
95
					configType = config.getType();
96
				} catch (CoreException e) {
97
					continue;
98
				}
99
				if (configType.equals(programType)) {
100
					if (!launches[i].isTerminated()) {
101
						MessageDialog
102
								.openWarning(
103
										window.getShell(),
104
										ExternalToolsProgramMessages.ProgramLaunchDelegate_Workbench_Closing_1,
105
										ExternalToolsProgramMessages.ProgramLaunchDelegate_The_workbench_is_exiting);
106
						break;
107
					}
108
				}
109
			}
110
		}
111
112
		public void windowOpened(IWorkbenchWindow window) {
113
		}
114
	}
42
115
43
	/**
116
	/**
44
	 * Create an instance of the External Tools plug-in.
117
	 * Create an instance of the External Tools plug-in.
Lines 63-76 Link Here
63
		if (message == null) {
136
		if (message == null) {
64
			message= EMPTY_STRING; 
137
			message= EMPTY_STRING; 
65
		}		
138
		}		
66
		return new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception);
139
		return new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception);
67
	}
140
	}
68
141
69
	/**
142
	/**
70
	 * Returns a new <code>CoreException</code> for this plug-in
143
	 * Returns a new <code>CoreException</code> for this plug-in
71
	 */
144
	 */
72
	public static CoreException newError(String message, Throwable exception) {
145
	public static CoreException newError(String message, Throwable exception) {
73
		return new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, message, exception));
146
		return new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, 0, message, exception));
74
	}
147
	}
75
148
76
	/**
149
	/**
Lines 164-167 Link Here
164
			super.stop(context);
237
			super.stop(context);
165
		}
238
		}
166
	}
239
	}
240
241
	public void start(BundleContext context) throws Exception {
242
		super.start(context);
243
		// Listen to launches to lazily create "launch processors"
244
		launchManager = DebugPlugin.getDefault().getLaunchManager();
245
		ILaunch[] launches = launchManager.getLaunches();
246
		if (launches.length > 0) {
247
			if (fWindowListener == null) {
248
				fWindowListener = new ProgramLaunchWindowListener();
249
				PlatformUI.getWorkbench().addWindowListener(fWindowListener);
250
			}
251
		} else {
252
			// if no launches, wait for first launch to initialize processors
253
			launchManager.addLaunchListener(this);
254
		}
255
	}
256
257
	public void launchAdded(ILaunch launch) {
258
		ILaunchConfiguration launchConfiguration = launch
259
				.getLaunchConfiguration();
260
		try {
261
			ILaunchConfigurationType launchConfigurationType = launchConfiguration
262
					.getType();
263
			if (launchConfigurationType
264
					.getIdentifier()
265
					.equals(
266
							IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE)) {
267
				if (fWindowListener == null) {
268
					fWindowListener = new ProgramLaunchWindowListener();
269
					PlatformUI.getWorkbench()
270
							.addWindowListener(fWindowListener);
271
				}
272
			}
273
		} catch (CoreException e) {
274
			log(e);
275
		}
276
	}
277
278
	public void launchChanged(ILaunch launch) {
279
280
	}
281
282
	public void launchRemoved(ILaunch launch) {
283
		launchManager.removeLaunch(launch);
284
	}
167
}
285
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/IExternalToolConstants.java (-231 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     dakshinamurthy.karra@gmail.com - bug 165371
11
 *******************************************************************************/
12
package org.eclipse.ui.externaltools.internal.model;
13
14
/**
15
 * Defines the constants available for client use.
16
 * <p>
17
 * This interface is not intended to be extended or implemented by clients.
18
 * </p>
19
 */
20
public interface IExternalToolConstants {
21
	/**
22
	 * Plugin identifier for external tools (value <code>org.eclipse.ui.externaltools</code>).
23
	 */
24
	public static final String PLUGIN_ID = "org.eclipse.ui.externaltools"; //$NON-NLS-1$;
25
26
	// ------- Extensions Points -------
27
	/**
28
	 * Extension point to declare the launch configuration type that should be
29
	 * created when duplicating an existing configuration as a project builder.
30
	 */
31
	public static final String EXTENSION_POINT_CONFIGURATION_DUPLICATION_MAPS = "configurationDuplicationMaps"; //$NON-NLS-1$
32
	// ------- Refresh Variables -------
33
	/**
34
	 * Variable that expands to the workspace root object (value <code>workspace</code>).
35
	 */
36
	public static final String VAR_WORKSPACE = "workspace"; //$NON-NLS-1$
37
	/**
38
	 * Variable that expands to the project resource (value <code>project</code>).
39
	 */
40
	public static final String VAR_PROJECT = "project"; //$NON-NLS-1$
41
	/**
42
	 * Variable that expands to the container resource (value <code>container</code>).
43
	 */
44
	public static final String VAR_CONTAINER = "container"; //$NON-NLS-1$
45
	/**
46
	 * Variable that expands to a resource (value <code>resource</code>).
47
	 */
48
	public static final String VAR_RESOURCE = "resource"; //$NON-NLS-1$
49
	/**
50
	 * Variable that expands to the working set object (value <code>working_set</code>).
51
	 */
52
	public static final String VAR_WORKING_SET = "working_set"; //$NON-NLS-1$
53
	// ------- Tool Types -------
54
	/**
55
	 * External tool type for programs such as executables, batch files, 
56
	 * shell scripts, etc (value <code>programType</code>).
57
	 */
58
	public static final String TOOL_TYPE_PROGRAM = "programType"; //$NON-NLS-1$;
59
60
	// ------- Build Types -------
61
	/**
62
	 * Build type indicating an incremental project build request for
63
	 * the external tool running as a builder (value <code>incremental</code>).
64
	 */
65
	public static final String BUILD_TYPE_INCREMENTAL = "incremental"; //$NON-NLS-1$
66
67
	/**
68
	 * Build type indicating a full project build request for
69
	 * the external tool running as a builder (value <code>full</code>).
70
	 */
71
	public static final String BUILD_TYPE_FULL = "full"; //$NON-NLS-1$
72
73
	/**
74
	 * Build type indicating an automatic project build request for
75
	 * the external tool running as a builder (value <code>auto</code>).
76
	 */
77
	public static final String BUILD_TYPE_AUTO = "auto"; //$NON-NLS-1$
78
	
79
	/**
80
	 * Build type indicating a clean project build request for
81
	 * the external tool running as a builder (value <code>clean</code>).
82
	 */
83
	public static final String BUILD_TYPE_CLEAN = "clean"; //$NON-NLS-1$
84
85
	/**
86
	 * Build type indicating no project build request for
87
	 * the external tool running as a builder (value <code>none</code>).
88
	 */
89
	public static final String BUILD_TYPE_NONE = "none"; //$NON-NLS-1$
90
91
	// ------- Images -------
92
93
	/**
94
	 * Main tab image.
95
	 */
96
	public static final String IMG_TAB_MAIN = PLUGIN_ID + ".IMG_TAB_MAIN"; //$NON-NLS-1$
97
98
	/**
99
	 * Build tab image
100
	 */
101
	public static final String IMG_TAB_BUILD = PLUGIN_ID + ".IMG_TAB_BUILD"; //$NON-NLS-1$
102
103
	// ------- Launch configuration types --------
104
	/**
105
	 * Program launch configuration type identifier.
106
	 */
107
	public static final String ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"; //$NON-NLS-1$
108
	
109
	/**
110
	 * Program builder launch configuration type identifier. Program project
111
	 * builders are of this type.
112
	 */
113
	public static final String ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"; //$NON-NLS-1$	
114
	
115
	// ------- Launch configuration category --------
116
	/**
117
	 * Identifier for external tools launch configuration category. Launch
118
	 * configuration types for external tools that appear in the external tools
119
	 * launch configuration dialog should belong to this category.
120
	 */
121
	public static final String ID_EXTERNAL_TOOLS_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools"; //$NON-NLS-1$
122
	/**
123
	 * Identifier for external tools launch configuration builders category.
124
	 * Launch configuration types that can be added as project builders should
125
	 * belong to this category.
126
	 */
127
	public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_CATEGORY = "org.eclipse.ui.externaltools.builder"; //$NON-NLS-1$
128
129
	// ------- Launch configuration groups --------
130
	/**
131
	 * Identifier for external tools launch configuration group. The external
132
	 * tools launch configuration group corresponds to the external tools
133
	 * category in run mode.
134
	 */
135
	public static final String ID_EXTERNAL_TOOLS_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup"; //$NON-NLS-1$
136
	/**
137
	 * Identifier for external tools launch configuration group
138
	 */
139
	public static final String ID_EXTERNAL_TOOLS_BUILDER_LAUNCH_GROUP = "org.eclipse.ui.externaltools.launchGroup.builder"; //$NON-NLS-1$
140
141
	// ------- Common External Tool Launch Configuration Attributes -------
142
143
	/**
144
	 * Boolean attribute indicating if external tool output should be captured.
145
	 * Default value is <code>false</code>.
146
	 * @deprecated since 3.1 Replaced by <code>org.eclipse.debug.core.DebugPlugin.ATTR_CAPTURE_OUTPUT</code>
147
	 */
148
	public static final String ATTR_CAPTURE_OUTPUT = PLUGIN_ID + ".ATTR_CAPTURE_OUTPUT"; //$NON-NLS-1$
149
	/**
150
	 * String attribute identifying the location of an external. Default value
151
	 * is <code>null</code>. Encoding is tool specific.
152
	 */
153
	public static final String ATTR_LOCATION = PLUGIN_ID + ".ATTR_LOCATION"; //$NON-NLS-1$
154
155
	/**
156
	 * Boolean attribute indicating if the user should be prompted for
157
	 * arguments before running a tool. Default value is <code>false</code>.
158
	 * THIS ATTRIBUTE IS NOT USED.
159
	 */
160
	public static final String ATTR_PROMPT_FOR_ARGUMENTS = PLUGIN_ID + ".ATTR_PROMPT_FOR_ARGUMENTS"; //$NON-NLS-1$
161
	
162
	/**
163
	 * String attribute identifying the scope of resources that should trigger an 
164
	 * external tool to run. Default value is <code>null</code>
165
	 * indicating that the builder will be triggered for all changes.
166
	 */
167
	public static final String ATTR_BUILDER_SCOPE = PLUGIN_ID + ".ATTR_BUILD_SCOPE"; //$NON-NLS-1$
168
		
169
	/**
170
	 * String attribute containing an array of build kinds for which an
171
	 * external tool builder should be run.
172
	 */
173
	public static final String ATTR_RUN_BUILD_KINDS = PLUGIN_ID + ".ATTR_RUN_BUILD_KINDS"; //$NON-NLS-1$
174
	
175
	/**
176
	 * Boolean attribute indicating if the console should be shown on external
177
	 * tool output. Default value is <code>false</code>.
178
	 */
179
	public static final String ATTR_SHOW_CONSOLE = PLUGIN_ID + ".ATTR_SHOW_CONSOLE"; //$NON-NLS-1$
180
181
	/**
182
	 * String attribute containing the arguments that should be passed to the
183
	 * tool. Default value is <code>null</code>, and encoding is tool specific.
184
	 */
185
	public static final String ATTR_TOOL_ARGUMENTS = PLUGIN_ID + ".ATTR_TOOL_ARGUMENTS"; //$NON-NLS-1$
186
187
	/**
188
	 * String attribute identifying the working directory of an external tool.
189
	 * Default value is <code>null</code>, which indicates a default working
190
	 * directory, which is tool specific.
191
	 */
192
	public static final String ATTR_WORKING_DIRECTORY = PLUGIN_ID + ".ATTR_WORKING_DIRECTORY"; //$NON-NLS-1$
193
	
194
	/**
195
	 * String attribute identifying whether an external tool builder configuration
196
	 * is enabled. The default value is <code>true</code>, which indicates
197
	 * that the configuration will be executed as appropriate by the builder.
198
	 */
199
	public static final String ATTR_BUILDER_ENABLED = PLUGIN_ID + ".ATTR_BUILDER_ENABLED"; //$NON-NLS-1$
200
	
201
	/**
202
	 * Status code indicating an unexpected internal error.
203
	 */
204
	public static final int ERR_INTERNAL_ERROR = 150;
205
206
	/**
207
	 * String attribute identifying a non-external tool builder launch configuration that is disabled
208
	 * The value is the name of the disabled builder.
209
	 */
210
	public static final String ATTR_DISABLED_BUILDER = PLUGIN_ID + ".ATTR_DISABLED_BUILDER";		 //$NON-NLS-1$
211
	
212
	/**
213
	 * boolean attribute identifying that an external tool builder has been configured for triggering
214
	 * using the <code>ICommand.setBuilding(int)</code> mechanism
215
	 * @since 3.1
216
	 */
217
	public static final String ATTR_TRIGGERS_CONFIGURED = PLUGIN_ID + ".ATTR_TRIGGERS_CONFIGURED";		 //$NON-NLS-1$
218
219
	/**
220
	 * String attribute identifying the build scope for a launch configuration.
221
	 * <code>null</code> indicates the default workspace build.
222
	 */
223
	public static final String ATTR_BUILD_SCOPE = PLUGIN_ID + ".ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE"; //$NON-NLS-1$
224
225
	/**
226
	 * Attribute identifier specifying whether referenced projects should be 
227
	 * considered when computing the projects to build. Default value is
228
	 * <code>true</code>.
229
	 */
230
	public static final String ATTR_INCLUDE_REFERENCED_PROJECTS = PLUGIN_ID + ".ATTR_INCLUDE_REFERENCED_PROJECTS"; //$NON-NLS-1$
231
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/model/ImageDescriptorRegistry.java (-1 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
(-)External Tools Base/org/eclipse/ui/externaltools/internal/registry/ExternalToolMigration.java (-411 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.registry;
12
13
14
import java.util.ArrayList;
15
import java.util.Map;
16
import java.util.StringTokenizer;
17
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.debug.core.DebugPlugin;
20
import org.eclipse.debug.core.ILaunchConfiguration;
21
import org.eclipse.debug.core.ILaunchConfigurationType;
22
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
import org.eclipse.debug.core.ILaunchManager;
24
import org.eclipse.debug.ui.IDebugUIConstants;
25
import org.eclipse.debug.ui.RefreshTab;
26
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
27
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
28
import org.eclipse.ui.externaltools.internal.ui.ExternalToolsUIMessages;
29
30
/**
31
 * Responsible reading an old external tool format and creating
32
 * and migrating it to create a new external tool.
33
 */
34
public final class ExternalToolMigration {
35
	/**
36
	 * Structure to represent a variable definition within a
37
	 * source string.
38
	 */
39
	public static final class VariableDefinition {
40
		/**
41
		 * Index in the source text where the variable started
42
		 * or <code>-1</code> if no valid variable start tag 
43
		 * identifier found.
44
		 */
45
		public int start = -1;
46
		
47
		/**
48
		 * Index in the source text of the character following
49
		 * the end of the variable or <code>-1</code> if no 
50
		 * valid variable end tag found.
51
		 */
52
		public int end = -1;
53
		
54
		/**
55
		 * The variable's name found in the source text, or
56
		 * <code>null</code> if no valid variable found.
57
		 */
58
		public String name = null;
59
		
60
		/**
61
		 * The variable's argument found in the source text, or
62
		 * <code>null</code> if no valid variable found or if
63
		 * the variable did not specify an argument
64
		 */
65
		public String argument = null;
66
		
67
		/**
68
		 * Create an initialized variable definition.
69
		 */
70
		private VariableDefinition() {
71
			super();
72
		}
73
	}
74
	
75
	/**
76
	 * Variable tag indentifiers
77
	 */
78
	private static final String VAR_TAG_START = "${"; //$NON-NLS-1$
79
	private static final String VAR_TAG_END = "}"; //$NON-NLS-1$
80
	private static final String VAR_TAG_SEP = ":"; //$NON-NLS-1$	
81
	
82
	/**
83
	 * External tool type for Ant build files (value <code>antBuildType</code>).
84
	 */
85
	public static final String TOOL_TYPE_ANT_BUILD = "antBuildType"; //$NON-NLS-1$;
86
	/**
87
	 * Ant builder launch configuration type identifier. Ant project builders
88
	 * are of this type.
89
	 */
90
	public static final String ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE = "org.eclipse.ant.AntBuilderLaunchConfigurationType"; //$NON-NLS-1$
91
		
92
	public static final String RUN_TARGETS_ATTRIBUTE = TOOL_TYPE_ANT_BUILD + ".runTargets"; //$NON-NLS-1$;
93
94
	/**
95
	* String attribute indicating the Ant targets to execute. Default value is
96
	 * <code>null</code> which indicates that the default target is to be
97
	 * executed. Format is a comma separated listing of targets.
98
	 * NOTE: This value is copied here from org.eclipse.ant.ui.internal.IAntLaunchConfigurationConstants.
99
	 * 		Ant no longer resides in External Tools and this plug-in. This value is kept here only
100
	 * 		for migration.
101
	 */
102
	public static final String ATTR_ANT_TARGETS = IExternalToolConstants.PLUGIN_ID + ".ATTR_ANT_TARGETS"; //$NON-NLS-1$
103
	
104
	/*
105
	 * 2.0 External Tool Tags
106
	 */
107
	public static final String TAG_TOOL_TYPE = "!{tool_type}"; //$NON-NLS-1$
108
	public static final String TAG_TOOL_NAME = "!{tool_name}"; //$NON-NLS-1$
109
	public static final String TAG_TOOL_LOCATION = "!{tool_loc}"; //$NON-NLS-1$
110
	public static final String TAG_TOOL_ARGUMENTS = "!{tool_args}"; //$NON-NLS-1$
111
	public static final String TAG_TOOL_DIRECTORY = "!{tool_dir}"; //$NON-NLS-1$
112
	public static final String TAG_TOOL_REFRESH = "!{tool_refresh}"; //$NON-NLS-1$
113
	public static final String TAG_TOOL_SHOW_LOG = "!{tool_show_log}"; //$NON-NLS-1$
114
	public static final String TAG_TOOL_BUILD_TYPES = "!{tool_build_types}"; //$NON-NLS-1$
115
	public static final String TAG_TOOL_BLOCK = "!{tool_block}"; //$NON-NLS-1$
116
117
	// Known kind of tools
118
	private static final String TOOL_TYPE_ANT = "org.eclipse.ui.externaltools.type.ant"; //$NON-NLS-1$
119
	private static final String TOOL_TYPE_PROGRAM = "org.eclipse.ui.externaltools.type.program"; //$NON-NLS-1$
120
121
	/*
122
	 * 2.1 External Tool Keys
123
	 */
124
	public static final String TAG_TYPE = "type"; //$NON-NLS-1$
125
	public static final String TAG_NAME = "name"; //$NON-NLS-1$
126
	public static final String TAG_LOCATION = "location"; //$NON-NLS-1$
127
	public static final String TAG_WORK_DIR = "workDirectory"; //$NON-NLS-1$
128
	public static final String TAG_CAPTURE_OUTPUT = "captureOutput"; //$NON-NLS-1$
129
	public static final String TAG_SHOW_CONSOLE = "showConsole"; //$NON-NLS-1$
130
	public static final String TAG_RUN_BKGRND = "runInBackground"; //$NON-NLS-1$
131
	public static final String TAG_PROMPT_ARGS = "promptForArguments"; //$NON-NLS-1$
132
	public static final String TAG_ARGS = "arguments"; //$NON-NLS-1$
133
	public static final String TAG_REFRESH_SCOPE = "refreshScope"; //$NON-NLS-1$
134
	public static final String TAG_REFRESH_RECURSIVE = "refreshRecursive"; //$NON-NLS-1$
135
	public static final String TAG_RUN_BUILD_KINDS = "runForBuildKinds"; //$NON-NLS-1$
136
	public static final String TAG_EXTRA_ATTR = "extraAttribute"; //$NON-NLS-1$
137
	public static final String TAG_VERSION = "version"; //$NON-NLS-1$
138
139
	private static final String EXTRA_ATTR_SEPARATOR = "="; //$NON-NLS-1$
140
141
	private static final String VERSION_21 = "2.1"; //$NON-NLS-1$;
142
143
	private static final String TRUE = "true"; //$NON-NLS-1$
144
	private static final String FALSE = "false"; //$NON-NLS-1$
145
146
	/**
147
	 * Allows no instances.
148
	 */
149
	private ExternalToolMigration() {
150
		super();
151
	}
152
153
	/**
154
	 * Returns a  launch configuration working copy from the argument map or
155
	 * <code>null</code> if the given map cannot be interpreted as a 2.0 or 2.1
156
	 * branch external tool. The returned working copy will be unsaved and its
157
	 * location will be set to the metadata area.
158
	 */
159
	public static ILaunchConfigurationWorkingCopy configFromArgumentMap(Map args) {
160
		String version = (String) args.get(TAG_VERSION);
161
		if (VERSION_21.equals(version)) {
162
			return configFrom21ArgumentMap(args);
163
		}
164
		return configFrom20ArgumentMap(args);
165
	}
166
167
	public static ILaunchConfigurationWorkingCopy configFrom21ArgumentMap(Map commandArgs) {
168
		String name = (String) commandArgs.get(TAG_NAME);
169
		String type = (String) commandArgs.get(TAG_TYPE);
170
		
171
		ILaunchConfigurationWorkingCopy config = newConfig(type, name);
172
		if (config == null) {
173
			return null;
174
		}
175
		
176
		config.setAttribute(IExternalToolConstants.ATTR_LOCATION, (String) commandArgs.get(TAG_LOCATION));
177
		config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) commandArgs.get(TAG_WORK_DIR));
178
		config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(commandArgs.get(TAG_CAPTURE_OUTPUT)));
179
		config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(commandArgs.get(TAG_SHOW_CONSOLE)));
180
		config.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, TRUE.equals(commandArgs.get(TAG_RUN_BKGRND)));
181
		config.setAttribute(IExternalToolConstants.ATTR_PROMPT_FOR_ARGUMENTS, TRUE.equals(commandArgs.get(TAG_PROMPT_ARGS)));
182
		config.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, (String) commandArgs.get(TAG_REFRESH_SCOPE));
183
		config.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, TRUE.equals(commandArgs.get(TAG_REFRESH_RECURSIVE)));
184
185
		config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, (String) commandArgs.get(TAG_RUN_BUILD_KINDS));
186
		
187
		String args = (String) commandArgs.get(TAG_ARGS);
188
		if (args != null) {
189
			config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, args);
190
		}
191
192
		String extraAttributes = (String) commandArgs.get(TAG_EXTRA_ATTR);
193
		if (extraAttributes != null) {
194
			StringTokenizer tokenizer = new StringTokenizer(extraAttributes, EXTRA_ATTR_SEPARATOR);
195
			while (tokenizer.hasMoreTokens()) {
196
				String key = tokenizer.nextToken();
197
				if (!tokenizer.hasMoreTokens())
198
					break;
199
				String value = tokenizer.nextToken();
200
				if (key.equals(RUN_TARGETS_ATTRIBUTE)) {
201
					// 2.1 implementation only defined 1 "extra attribute"
202
					config.setAttribute(ATTR_ANT_TARGETS, value);
203
				}
204
			}
205
		}
206
		return config;
207
	}
208
209
	/**
210
	 * Creates an external tool from the map.
211
	 */
212
	public static ILaunchConfigurationWorkingCopy configFrom20ArgumentMap(Map args) {
213
		// Update the type...
214
		String type = (String) args.get(TAG_TOOL_TYPE);
215
		if (TOOL_TYPE_ANT.equals(type)) {
216
			type = TOOL_TYPE_ANT_BUILD;
217
		} else if (TOOL_TYPE_PROGRAM.equals(type)){
218
			type = IExternalToolConstants.TOOL_TYPE_PROGRAM;
219
		} else {
220
			return null;
221
		}
222
223
		String name = (String) args.get(TAG_TOOL_NAME);
224
		
225
		ILaunchConfigurationWorkingCopy config = newConfig(type, name);
226
		if (config == null) {
227
			return null;
228
		}
229
230
		// Update the location...
231
		String location = (String) args.get(TAG_TOOL_LOCATION);
232
		config.setAttribute(IExternalToolConstants.ATTR_LOCATION, location);
233
234
		// Update the refresh scope...
235
		String refresh = (String) args.get(TAG_TOOL_REFRESH);
236
		if (refresh != null) {
237
			VariableDefinition varDef = extractVariableDefinition(refresh, 0);
238
			if ("none".equals(varDef.name)) { //$NON-NLS-1$
239
				refresh = null;
240
			}
241
			config.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, refresh);
242
		}
243
244
		// Update the arguments
245
		String arguments = (String) args.get(TAG_TOOL_ARGUMENTS);
246
		if (type.equals(TOOL_TYPE_ANT_BUILD)) {
247
			String targetNames = null;
248
			if (arguments != null) {
249
				int start = 0;
250
				ArrayList targets = new ArrayList();
251
				StringBuffer buffer = new StringBuffer();
252
				VariableDefinition varDef = extractVariableDefinition(arguments, start);
253
				while (varDef.end != -1) {
254
					if ("ant_target".equals(varDef.name) && varDef.argument != null) { //$NON-NLS-1$
255
						targets.add(varDef.argument);
256
						buffer.append(arguments.substring(start, varDef.start));
257
					} else {
258
						buffer.append(arguments.substring(start, varDef.end));
259
					}
260
					start = varDef.end;
261
					varDef = extractVariableDefinition(arguments, start);
262
				}
263
				buffer.append(arguments.substring(start, arguments.length()));
264
				arguments = buffer.toString();
265
	
266
				buffer.setLength(0);
267
				for (int i = 0; i < targets.size(); i++) {
268
					String target = (String) targets.get(i);
269
					if (target != null && target.length() > 0) {
270
						buffer.append(target);
271
						buffer.append(","); //$NON-NLS-1$
272
					}
273
				}
274
				targetNames = buffer.toString();
275
			}
276
			if (targetNames != null && targetNames.length() > 0) {
277
				config.setAttribute(ATTR_ANT_TARGETS, targetNames);
278
			}
279
		}
280
		config.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments);
281
282
		// Collect the rest of the information
283
		config.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG)));
284
		config.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, TRUE.equals(args.get(TAG_TOOL_SHOW_LOG)));
285
		config.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, FALSE.equals(args.get(TAG_TOOL_BLOCK)));
286
		String buildKinds= (String) args.get(TAG_TOOL_BUILD_TYPES);
287
		if (buildKinds != null) {
288
			buildKinds= buildKinds.replace(';', ','); // Replace the old separator with the new
289
		}
290
		config.setAttribute(IExternalToolConstants.ATTR_RUN_BUILD_KINDS, buildKinds);
291
		config.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, (String) args.get(TAG_TOOL_DIRECTORY));
292
		return config;
293
	}
294
295
	/**
296
	 * Returns a new working copy with the given external tool name and external
297
	 * tool type or <code>null</code> if no config could be created.
298
	 */
299
	private static ILaunchConfigurationWorkingCopy newConfig(String type, String name) {
300
		if (type == null || name == null) {
301
			return null;
302
		}
303
		ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
304
		ILaunchConfigurationType configType;
305
		if (TOOL_TYPE_ANT_BUILD.equals(type)) {
306
			configType = manager.getLaunchConfigurationType(ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE);
307
		} else if (IExternalToolConstants.TOOL_TYPE_PROGRAM.equals(type)) {
308
			configType = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE);
309
		} else {
310
			return null;
311
		}
312
		try {
313
			if (configType != null) {
314
				return configType.newInstance(null, name);
315
			}
316
		} catch (CoreException e) {
317
			ExternalToolsPlugin.getDefault().log(e);
318
		}
319
		return null;
320
	}
321
	
322
	/**
323
	 * Returns the tool name extracted from the given command argument map.
324
	 * Extraction is attempted using 2.0 and 2.1 external tool formats.
325
	 */
326
	public static String getNameFromCommandArgs(Map commandArgs) {
327
		String name= (String) commandArgs.get(TAG_NAME);
328
		if (name == null) {
329
			name= (String) commandArgs.get(TAG_TOOL_NAME);
330
		}
331
		return name;
332
	}
333
	
334
	/**
335
	 * Migrate the old RUN_IN_BACKGROUND launch config attribute to the new
336
	 * LAUNCH_IN_BACKGROUND attribute provided by the debug ui plugin.
337
	 * 
338
	 * @param config the config to migrate
339
	 * @return the migrated config
340
	 */
341
	public static ILaunchConfiguration migrateRunInBackground(ILaunchConfiguration config) {
342
		String noValueFlag= "NoValue"; //$NON-NLS-1$
343
		String attr= null;
344
		try {
345
			attr = config.getAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, noValueFlag);
346
		} catch (CoreException e) {
347
			// Exception will occur if the attribute is already set because the attribute is actually a boolean.
348
			// No migration necessary.
349
			return config;
350
		}
351
		if (noValueFlag.equals(attr)) {
352
			//the old constant
353
			String ATTR_RUN_IN_BACKGROUND= IExternalToolConstants.PLUGIN_ID + ".ATTR_RUN_IN_BACKGROUND"; //$NON-NLS-1$
354
			boolean runInBackground= false;
355
			try {
356
				runInBackground = config.getAttribute(ATTR_RUN_IN_BACKGROUND, runInBackground);
357
			} catch (CoreException e) {
358
				ExternalToolsPlugin.getDefault().log(ExternalToolsUIMessages.ExternalToolMigration_37, e);
359
			}
360
			try {
361
				ILaunchConfigurationWorkingCopy workingCopy= config.getWorkingCopy();
362
				workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, runInBackground);
363
				config= workingCopy.doSave();
364
			} catch (CoreException e) {
365
				ExternalToolsPlugin.getDefault().log(ExternalToolsUIMessages.ExternalToolMigration_38, e);
366
			}
367
		}
368
		return config;
369
	}
370
	
371
	/**
372
	 * Extracts a variable name and argument from the given string.
373
	 * 
374
	 * @param text the source text to parse for a variable tag
375
	 * @param start the index in the string to start the search
376
	 * @return the variable definition
377
	 */
378
	public static VariableDefinition extractVariableDefinition(String text, int start) {
379
		VariableDefinition varDef = new VariableDefinition();
380
		
381
		varDef.start = text.indexOf(VAR_TAG_START, start);
382
		if (varDef.start < 0){
383
			return varDef;
384
		}
385
		start = varDef.start + VAR_TAG_START.length();
386
		
387
		int end = text.indexOf(VAR_TAG_END, start);
388
		if (end < 0) {
389
			return varDef;
390
		}
391
		varDef.end = end + VAR_TAG_END.length();
392
		if (end == start) {
393
			return varDef;
394
		}
395
	
396
		int mid = text.indexOf(VAR_TAG_SEP, start);
397
		if (mid < 0 || mid > end) {
398
			varDef.name = text.substring(start, end);
399
		} else {
400
			if (mid > start) {
401
				varDef.name = text.substring(start, mid);
402
			}
403
			mid = mid + VAR_TAG_SEP.length();
404
			if (mid < end) {
405
				varDef.argument = text.substring(mid, end);
406
			}
407
		}
408
		
409
		return varDef;
410
	}	
411
}
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderLabelProvider.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.ui;
11
package org.eclipse.ui.externaltools.internal.ui;
12
12
13
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
13
import org.eclipse.core.resources.ICommand;
14
import org.eclipse.core.resources.ICommand;
14
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
Lines 23-29 Link Here
23
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.swt.graphics.Image;
25
import org.eclipse.swt.graphics.Image;
25
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
26
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
26
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
27
import org.eclipse.ui.externaltools.internal.ui.BuilderPropertyPage.ErrorConfig;
27
import org.eclipse.ui.externaltools.internal.ui.BuilderPropertyPage.ErrorConfig;
28
28
29
29
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/BuilderPropertyPage.java (-6 / +7 lines)
Lines 18-23 Link Here
18
import java.util.List;
18
import java.util.List;
19
import java.util.Map;
19
import java.util.Map;
20
20
21
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
22
import org.eclipse.core.externaltools.internal.model.BuilderCoreUtils;
23
import org.eclipse.core.externaltools.internal.model.ExternalToolBuilder;
21
import org.eclipse.core.resources.ICommand;
24
import org.eclipse.core.resources.ICommand;
22
import org.eclipse.core.resources.IFolder;
25
import org.eclipse.core.resources.IFolder;
23
import org.eclipse.core.resources.IProject;
26
import org.eclipse.core.resources.IProject;
Lines 78-86 Link Here
78
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
81
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
79
import org.eclipse.ui.externaltools.internal.launchConfigurations.IgnoreWhiteSpaceComparator;
82
import org.eclipse.ui.externaltools.internal.launchConfigurations.IgnoreWhiteSpaceComparator;
80
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
83
import org.eclipse.ui.externaltools.internal.model.BuilderUtils;
81
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
82
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
84
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
83
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
84
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
85
import org.eclipse.ui.externaltools.internal.model.IExternalToolsHelpContextIds;
85
import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants;
86
import org.eclipse.ui.externaltools.internal.model.IPreferenceConstants;
86
import org.eclipse.ui.progress.IProgressService;
87
import org.eclipse.ui.progress.IProgressService;
Lines 210-216 Link Here
210
		for (int i = 0; i < commands.length; i++) {
211
		for (int i = 0; i < commands.length; i++) {
211
			String[] version= new String[] {""}; //$NON-NLS-1$
212
			String[] version= new String[] {""}; //$NON-NLS-1$
212
			ILaunchConfiguration config = BuilderUtils.configFromBuildCommandArgs(project, commands[i].getArguments(), version);
213
			ILaunchConfiguration config = BuilderUtils.configFromBuildCommandArgs(project, commands[i].getArguments(), version);
213
			if (BuilderUtils.VERSION_2_1.equals(version[0])) {
214
			if (BuilderCoreUtils.VERSION_2_1.equals(version[0])) {
214
				// Storing the .project file of a project with 2.1 configs, will
215
				// Storing the .project file of a project with 2.1 configs, will
215
				// edit the file in a way that isn't backwards compatible.
216
				// edit the file in a way that isn't backwards compatible.
216
				projectNeedsMigration= true;
217
				projectNeedsMigration= true;
Lines 222-228 Link Here
222
                    if (shell == null) {
223
                    if (shell == null) {
223
                        return;
224
                        return;
224
                    }
225
                    }
225
					IStatus status = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_Exists, new String[]{config.getName()}), null);
226
					IStatus status = new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, 0, NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_Exists, new String[]{config.getName()}), null);
226
					ErrorDialog.openError(getShell(), ExternalToolsUIMessages.BuilderPropertyPage_errorTitle,
227
					ErrorDialog.openError(getShell(), ExternalToolsUIMessages.BuilderPropertyPage_errorTitle,
227
									NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2, new String[]{config.getName()}),
228
									NLS.bind(ExternalToolsUIMessages.BuilderPropertyPage_External_Tool_Builder__0__Not_Added_2, new String[]{config.getName()}),
228
									status);
229
									status);
Lines 232-238 Link Here
232
				}
233
				}
233
			} else {
234
			} else {
234
				String builderID = commands[i].getBuilderName();
235
				String builderID = commands[i].getBuilderName();
235
				if (builderID.equals(ExternalToolBuilder.ID) && commands[i].getArguments().get(BuilderUtils.LAUNCH_CONFIG_HANDLE) != null) {
236
				if (builderID.equals(ExternalToolBuilder.ID) && commands[i].getArguments().get(BuilderCoreUtils.LAUNCH_CONFIG_HANDLE) != null) {
236
					// An invalid external tool entry.
237
					// An invalid external tool entry.
237
					element= new ErrorConfig(commands[i]);
238
					element= new ErrorConfig(commands[i]);
238
				} else {
239
				} else {
Lines 767-773 Link Here
767
		if (e instanceof CoreException) {
768
		if (e instanceof CoreException) {
768
			status[0] = ((CoreException) e).getStatus();
769
			status[0] = ((CoreException) e).getStatus();
769
		} else {
770
		} else {
770
			status[0] = new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, 0, ExternalToolsUIMessages.BuilderPropertyPage_statusMessage, e);
771
			status[0] = new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, 0, ExternalToolsUIMessages.BuilderPropertyPage_statusMessage, e);
771
		}
772
		}
772
		Display.getDefault().asyncExec(new Runnable() {
773
		Display.getDefault().asyncExec(new Runnable() {
773
		    public void run() {
774
		    public void run() {
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved. This
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved. This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 55-62 Link Here
55
	public static String ExternalToolsPreferencePage_Prompt_before_migrating_3;
55
	public static String ExternalToolsPreferencePage_Prompt_before_migrating_3;
56
	public static String ExternalToolsPreferencePage_1;
56
	public static String ExternalToolsPreferencePage_1;
57
57
58
	public static String ExternalToolMigration_37;
59
	public static String ExternalToolMigration_38;
60
	public static String EditCommandDialog_0;
58
	public static String EditCommandDialog_0;
61
	public static String EditCommandDialog_1;
59
	public static String EditCommandDialog_1;
62
	public static String EditCommandDialog_2;
60
	public static String EditCommandDialog_2;
(-)External Tools Base/org/eclipse/ui/externaltools/internal/ui/ExternalToolsUIMessages.properties (-3 / +1 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2006 IBM Corporation and others.
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 50-57 Link Here
50
ExternalToolsPreferencePage_Prompt_before_migrating_3=&Confirm before migrating external tool project builders for edit
50
ExternalToolsPreferencePage_Prompt_before_migrating_3=&Confirm before migrating external tool project builders for edit
51
ExternalToolsPreferencePage_1=C&onfirm before migrating projects to the new format
51
ExternalToolsPreferencePage_1=C&onfirm before migrating projects to the new format
52
52
53
ExternalToolMigration_37=An exception occurred accessing external tool\'s \"run in background\" attribute
54
ExternalToolMigration_38=An exception occurred attempting to migrate external tool\'s \"run in background\" attribute
55
EditCommandDialog_0=Configure Builder
53
EditCommandDialog_0=Configure Builder
56
EditCommandDialog_1=Run this builder:
54
EditCommandDialog_1=Run this builder:
57
EditCommandDialog_2=After a "&Clean"
55
EditCommandDialog_2=After a "&Clean"
(-)External Tools Base/org/eclipse/ui/externaltools/internal/variables/BuildFilesResolver.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 Matthew Conway and others.
2
 * Copyright (c) 2007, 2009 Matthew Conway and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-25 Link Here
13
import java.util.LinkedHashSet;
13
import java.util.LinkedHashSet;
14
import java.util.Set;
14
import java.util.Set;
15
15
16
import org.eclipse.core.externaltools.internal.model.ExternalToolBuilder;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.resources.IResourceDelta;
18
import org.eclipse.core.resources.IResourceDeltaVisitor;
19
import org.eclipse.core.resources.IResourceDeltaVisitor;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.variables.IDynamicVariable;
21
import org.eclipse.core.variables.IDynamicVariable;
21
import org.eclipse.core.variables.IDynamicVariableResolver;
22
import org.eclipse.core.variables.IDynamicVariableResolver;
22
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
23
23
24
public class BuildFilesResolver implements IDynamicVariableResolver
24
public class BuildFilesResolver implements IDynamicVariableResolver
25
{
25
{
(-)External Tools Base/org/eclipse/ui/externaltools/internal/variables/BuildProjectResolver.java (-4 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.variables;
11
package org.eclipse.ui.externaltools.internal.variables;
12
12
13
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
14
import org.eclipse.core.externaltools.internal.model.ExternalToolBuilder;
13
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IProject;
14
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
Lines 19-26 Link Here
19
import org.eclipse.core.variables.IDynamicVariable;
21
import org.eclipse.core.variables.IDynamicVariable;
20
import org.eclipse.core.variables.IDynamicVariableResolver;
22
import org.eclipse.core.variables.IDynamicVariableResolver;
21
import org.eclipse.osgi.util.NLS;
23
import org.eclipse.osgi.util.NLS;
22
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
24
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
23
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
24
25
25
26
26
public class BuildProjectResolver implements IDynamicVariableResolver {
27
public class BuildProjectResolver implements IDynamicVariableResolver {
Lines 48-54 Link Here
48
	 * @throws CoreException
49
	 * @throws CoreException
49
	 */
50
	 */
50
	protected void abort(String message, Throwable exception) throws CoreException {
51
	protected void abort(String message, Throwable exception) throws CoreException {
51
		throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, message, exception));
52
		throw new CoreException(new Status(IStatus.ERROR, ExternalToolsPlugin.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, message, exception));
52
	}
53
	}
53
	
54
	
54
	/**
55
	/**
(-)External Tools Base/org/eclipse/ui/externaltools/internal/variables/BuildTypeResolver.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.variables;
11
package org.eclipse.ui.externaltools.internal.variables;
12
12
13
import org.eclipse.core.externaltools.internal.model.ExternalToolBuilder;
13
import org.eclipse.core.variables.IDynamicVariable;
14
import org.eclipse.core.variables.IDynamicVariable;
14
import org.eclipse.core.variables.IDynamicVariableResolver;
15
import org.eclipse.core.variables.IDynamicVariableResolver;
15
import org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder;
16
16
17
17
18
public class BuildTypeResolver implements IDynamicVariableResolver {
18
public class BuildTypeResolver implements IDynamicVariableResolver {
(-)External Tools Base/org/eclipse/ui/externaltools/internal/variables/SystemPathResolver.java (-3 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-27 Link Here
15
import java.util.Map;
15
import java.util.Map;
16
import java.util.StringTokenizer;
16
import java.util.StringTokenizer;
17
17
18
import org.eclipse.core.externaltools.internal.IExternalToolConstants;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.variables.IDynamicVariable;
22
import org.eclipse.core.variables.IDynamicVariable;
22
import org.eclipse.core.variables.IDynamicVariableResolver;
23
import org.eclipse.core.variables.IDynamicVariableResolver;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
25
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
25
26
26
public class SystemPathResolver implements IDynamicVariableResolver {
27
public class SystemPathResolver implements IDynamicVariableResolver {
27
    
28
    
Lines 30-36 Link Here
30
	 */
31
	 */
31
	public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
32
	public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
32
        if (argument == null) {
33
        if (argument == null) {
33
            throw new CoreException(new Status(IStatus.ERROR,  IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, VariableMessages.SystemPathResolver_0, null));
34
            throw new CoreException(new Status(IStatus.ERROR,  ExternalToolsPlugin.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, VariableMessages.SystemPathResolver_0, null));
34
        }
35
        }
35
        Map map= DebugPlugin.getDefault().getLaunchManager().getNativeEnvironment();
36
        Map map= DebugPlugin.getDefault().getLaunchManager().getNativeEnvironment();
36
        String path= (String) map.get("PATH"); //$NON-NLS-1$
37
        String path= (String) map.get("PATH"); //$NON-NLS-1$
(-)META-INF/MANIFEST.MF (-2 / +2 lines)
Lines 10-16 Link Here
10
 org.eclipse.ui.externaltools.internal.menu;x-internal:=true,
10
 org.eclipse.ui.externaltools.internal.menu;x-internal:=true,
11
 org.eclipse.ui.externaltools.internal.model;x-friends:="org.eclipse.ant.ui",
11
 org.eclipse.ui.externaltools.internal.model;x-friends:="org.eclipse.ant.ui",
12
 org.eclipse.ui.externaltools.internal.program.launchConfigurations;x-friends:="org.eclipse.ant.ui",
12
 org.eclipse.ui.externaltools.internal.program.launchConfigurations;x-friends:="org.eclipse.ant.ui",
13
 org.eclipse.ui.externaltools.internal.registry;x-internal:=true,
14
 org.eclipse.ui.externaltools.internal.ui;x-friends:="org.eclipse.ant.ui",
13
 org.eclipse.ui.externaltools.internal.ui;x-friends:="org.eclipse.ant.ui",
15
 org.eclipse.ui.externaltools.internal.variables;x-internal:=true
14
 org.eclipse.ui.externaltools.internal.variables;x-internal:=true
16
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
15
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)";resolution:=optional,
Lines 19-24 Link Here
19
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
18
 org.eclipse.ui;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
19
 org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
21
 org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.debug.ui;bundle-version="[3.2.0,4.0.0)",
22
 org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)"
21
 org.eclipse.core.runtime;bundle-version="[3.1.0,4.0.0)",
22
 org.eclipse.core.externaltools;bundle-version="1.0.0"
23
Bundle-ActivationPolicy: lazy
23
Bundle-ActivationPolicy: lazy
24
Bundle-RequiredExecutionEnvironment: J2SE-1.4
24
Bundle-RequiredExecutionEnvironment: J2SE-1.4
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/BackgroundResourceRefresher.java (-87 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.externaltools.internal.program.launchConfigurations;
12
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
import org.eclipse.core.runtime.jobs.Job;
19
import org.eclipse.debug.core.DebugEvent;
20
import org.eclipse.debug.core.DebugPlugin;
21
import org.eclipse.debug.core.IDebugEventSetListener;
22
import org.eclipse.debug.core.ILaunchConfiguration;
23
import org.eclipse.debug.core.model.IProcess;
24
import org.eclipse.debug.ui.RefreshTab;
25
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
26
27
/**
28
 * Refreshes resources as specified by a launch configuration, when 
29
 * an associated process terminates.
30
 */
31
public class BackgroundResourceRefresher implements IDebugEventSetListener  {
32
33
	private ILaunchConfiguration fConfiguration;
34
	private IProcess fProcess;
35
	
36
	public BackgroundResourceRefresher(ILaunchConfiguration configuration, IProcess process) {
37
		fConfiguration = configuration;
38
		fProcess = process;
39
	}
40
	
41
	/**
42
	 * If the process has already terminated, resource refreshing is done
43
	 * immediately in the current thread. Otherwise, refreshing is done when the
44
	 * process terminates.
45
	 */
46
	public void startBackgroundRefresh() {
47
		synchronized (fProcess) {
48
			if (fProcess.isTerminated()) {
49
				refresh();
50
			} else {
51
				DebugPlugin.getDefault().addDebugEventListener(this);
52
			}
53
		}
54
	}
55
	
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
58
	 */
59
	public void handleDebugEvents(DebugEvent[] events) {
60
		for (int i = 0; i < events.length; i++) {
61
			DebugEvent event = events[i];
62
			if (event.getSource() == fProcess && event.getKind() == DebugEvent.TERMINATE) {
63
				DebugPlugin.getDefault().removeDebugEventListener(this);
64
				refresh();
65
				break;
66
			}
67
		}
68
	}
69
	
70
	/**
71
	 * Submits a job to do the refresh
72
	 */
73
	protected void refresh() {
74
		Job job= new Job(ExternalToolsProgramMessages.BackgroundResourceRefresher_0) {
75
			public IStatus run(IProgressMonitor monitor) {
76
				try {
77
					RefreshTab.refreshResources(fConfiguration, monitor);
78
				} catch (CoreException e) {
79
					ExternalToolsPlugin.getDefault().log(e);
80
					return e.getStatus();
81
				}	
82
				return Status.OK_STATUS;
83
			}
84
		};
85
		job.schedule();
86
	}
87
}
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.java (-3 / +1 lines)
Lines 1-5 Link Here
1
/**********************************************************************
1
/**********************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others. All rights reserved.   This
2
 * Copyright (c) 2000, 2009 IBM Corporation and others. All rights reserved.   This
3
 * program and the accompanying materials are made available under the terms of
3
 * program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
4
 * the Eclipse Public License v1.0 which accompanies this distribution, and is
5
 * available at http://www.eclipse.org/legal/epl-v10.html
5
 * available at http://www.eclipse.org/legal/epl-v10.html
Lines 18-25 Link Here
18
18
19
	public static String ProgramLaunchDelegate_Workbench_Closing_1;
19
	public static String ProgramLaunchDelegate_Workbench_Closing_1;
20
	public static String ProgramLaunchDelegate_The_workbench_is_exiting;
20
	public static String ProgramLaunchDelegate_The_workbench_is_exiting;
21
	public static String ProgramLaunchDelegate_3;
22
	public static String ProgramLaunchDelegate_4;
23
21
24
	public static String ProgramMainTab_Select;
22
	public static String ProgramMainTab_Select;
25
23
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ExternalToolsProgramMessages.properties (-3 / +1 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2000, 2005 IBM Corporation and others.
2
# Copyright (c) 2000, 2009 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
5
# which accompanies this distribution, and is available at
Lines 13-19 Link Here
13
13
14
ProgramLaunchDelegate_Workbench_Closing_1=Workbench Closing
14
ProgramLaunchDelegate_Workbench_Closing_1=Workbench Closing
15
ProgramLaunchDelegate_The_workbench_is_exiting=The workbench is exiting and a program launched from an external tool appears to still be running. These programs will be terminated when the workbench exits. It is recommended that you exit any external programs launched from the workbench before you proceed.\n\nClick OK to continue exiting the workbench.
15
ProgramLaunchDelegate_The_workbench_is_exiting=The workbench is exiting and a program launched from an external tool appears to still be running. These programs will be terminated when the workbench exits. It is recommended that you exit any external programs launched from the workbench before you proceed.\n\nClick OK to continue exiting the workbench.
16
ProgramLaunchDelegate_3=Running {0}...
17
ProgramLaunchDelegate_4=An IProcess could not be created for the launch
18
16
19
ProgramMainTab_Select=&Select a program:
17
ProgramMainTab_Select=&Select a program:
(-)Program Tools Support/org/eclipse/ui/externaltools/internal/program/launchConfigurations/ProgramLaunchDelegate.java (-246 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Keith Seitz (keiths@redhat.com) - environment variables contribution (Bug 27243)
11
 *     dakshinamurthy.karra@gmail.com - bug 165371
12
 *******************************************************************************/
13
package org.eclipse.ui.externaltools.internal.program.launchConfigurations;
14
15
16
import java.io.File;
17
import java.util.HashMap;
18
import java.util.Map;
19
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.debug.core.DebugPlugin;
27
import org.eclipse.debug.core.ILaunch;
28
import org.eclipse.debug.core.ILaunchConfiguration;
29
import org.eclipse.debug.core.ILaunchConfigurationType;
30
import org.eclipse.debug.core.ILaunchManager;
31
import org.eclipse.debug.core.model.IProcess;
32
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
33
import org.eclipse.debug.ui.CommonTab;
34
import org.eclipse.debug.ui.RefreshTab;
35
import org.eclipse.jface.dialogs.MessageDialog;
36
import org.eclipse.osgi.util.NLS;
37
import org.eclipse.ui.IWindowListener;
38
import org.eclipse.ui.IWorkbenchWindow;
39
import org.eclipse.ui.PlatformUI;
40
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsBuildTab;
41
import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil;
42
import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants;
43
44
/**
45
 * Launch delegate for a program.
46
 */
47
public class ProgramLaunchDelegate extends LaunchConfigurationDelegate {
48
49
	private static IWindowListener fWindowListener;
50
51
	/**
52
	 * A window listener that warns the user about any running programs when
53
	 * the workbench closes. Programs are killed when the VM exits.
54
	 */
55
	private class ProgramLaunchWindowListener implements IWindowListener {
56
		public void windowActivated(IWorkbenchWindow window) {
57
		}
58
		public void windowDeactivated(IWorkbenchWindow window) {
59
		}
60
		public void windowClosed(IWorkbenchWindow window) {
61
			IWorkbenchWindow windows[]= PlatformUI.getWorkbench().getWorkbenchWindows();
62
			if (windows.length > 1) {
63
				// There are more windows still open.
64
				return;
65
			}
66
			ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
67
			ILaunchConfigurationType programType= manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
68
			if (programType == null) {
69
				return;
70
			}
71
			ILaunch launches[]= manager.getLaunches();
72
			ILaunchConfigurationType configType;
73
			ILaunchConfiguration config;
74
			for (int i = 0; i < launches.length; i++) {
75
				try {
76
					config= launches[i].getLaunchConfiguration();
77
					if (config == null) {
78
						continue;
79
					}
80
					configType= config.getType();
81
				} catch (CoreException e) {
82
					continue;
83
				}
84
				if (configType.equals(programType)) {
85
					if (!launches[i].isTerminated()) {
86
						MessageDialog.openWarning(window.getShell(), ExternalToolsProgramMessages.ProgramLaunchDelegate_Workbench_Closing_1, ExternalToolsProgramMessages.ProgramLaunchDelegate_The_workbench_is_exiting);
87
						break;
88
					}
89
				}
90
			}
91
		}
92
		public void windowOpened(IWorkbenchWindow window) {
93
		}
94
	}
95
96
	/**
97
	 * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
98
	 */
99
	public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
100
		
101
		if (monitor.isCanceled()) {
102
			return;
103
		}
104
		
105
		// resolve location
106
		IPath location = ExternalToolsUtil.getLocation(configuration);
107
		
108
		if (monitor.isCanceled()) {
109
			return;
110
		}		
111
		
112
		// resolve working directory
113
		IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(configuration);
114
		
115
		if (monitor.isCanceled()) {
116
			return;
117
		}
118
		
119
		// resolve arguments
120
		String[] arguments = ExternalToolsUtil.getArguments(configuration);
121
		
122
		if (monitor.isCanceled()) {
123
			return;
124
		}
125
		
126
		int cmdLineLength = 1;
127
		if (arguments != null) {
128
			cmdLineLength += arguments.length;
129
		}
130
		String[] cmdLine = new String[cmdLineLength];
131
		cmdLine[0] = location.toOSString();
132
		if (arguments != null) {
133
			System.arraycopy(arguments, 0, cmdLine, 1, arguments.length);
134
		}
135
		
136
		File workingDir = null;
137
		if (workingDirectory != null) {
138
			workingDir = workingDirectory.toFile();
139
		}
140
		
141
		if (monitor.isCanceled()) {
142
			return;
143
		}
144
		
145
		String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
146
		
147
		if (monitor.isCanceled()) {
148
			return;
149
		}
150
		
151
		if (fWindowListener == null) {
152
			fWindowListener= new ProgramLaunchWindowListener();
153
			PlatformUI.getWorkbench().addWindowListener(fWindowListener);
154
		}
155
		Process p = DebugPlugin.exec(cmdLine, workingDir, envp);
156
		IProcess process = null;
157
		
158
		// add process type to process attributes
159
		Map processAttributes = new HashMap();
160
		String programName = location.lastSegment();
161
		String extension = location.getFileExtension();
162
		if (extension != null) {
163
			programName = programName.substring(0, programName.length() - (extension.length() + 1));
164
		}
165
		programName = programName.toLowerCase();
166
		processAttributes.put(IProcess.ATTR_PROCESS_TYPE, programName);
167
		
168
		if (p != null) {
169
			monitor.beginTask(NLS.bind(ExternalToolsProgramMessages.ProgramLaunchDelegate_3, new String[] {configuration.getName()}), IProgressMonitor.UNKNOWN);
170
			process = DebugPlugin.newProcess(launch, p, location.toOSString(), processAttributes);
171
		}
172
		if (p == null || process == null) {
173
			if (p != null)
174
				p.destroy();
175
			throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, ExternalToolsProgramMessages.ProgramLaunchDelegate_4, null));
176
		}
177
		process.setAttribute(IProcess.ATTR_CMDLINE, generateCommandLine(cmdLine));
178
		
179
		if (CommonTab.isLaunchInBackground(configuration)) {
180
			// refresh resources after process finishes
181
			if (RefreshTab.getRefreshScope(configuration) != null) {
182
				BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process);
183
				refresher.startBackgroundRefresh();
184
			}				
185
		} else {
186
			// wait for process to exit
187
			while (!process.isTerminated()) {
188
				try {
189
					if (monitor.isCanceled()) {
190
						process.terminate();
191
						break;
192
					}
193
					Thread.sleep(50);
194
				} catch (InterruptedException e) {
195
				}
196
			}
197
			
198
			// refresh resources
199
			RefreshTab.refreshResources(configuration, monitor);
200
		}
201
	}
202
	
203
	private String generateCommandLine(String[] commandLine) {
204
		if (commandLine.length < 1)
205
			return ""; //$NON-NLS-1$
206
		StringBuffer buf= new StringBuffer();
207
		for (int i= 0; i < commandLine.length; i++) {
208
			buf.append(' ');
209
			char[] characters= commandLine[i].toCharArray();
210
			StringBuffer command= new StringBuffer();
211
			boolean containsSpace= false;
212
			for (int j = 0; j < characters.length; j++) {
213
				char character= characters[j];
214
				if (character == '\"') {
215
					command.append('\\');
216
				} else if (character == ' ') {
217
					containsSpace = true;
218
				}
219
				command.append(character);
220
			}
221
			if (containsSpace) {
222
				buf.append('\"');
223
				buf.append(command);
224
				buf.append('\"');
225
			} else {
226
				buf.append(command);
227
			}
228
		}	
229
		return buf.toString();
230
	}	
231
	
232
    /* (non-Javadoc)
233
	 * @see org.eclipse.debug.core.model.LaunchConfigurationDelegate#getBuildOrder(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String)
234
	 */
235
	protected IProject[] getBuildOrder(ILaunchConfiguration configuration, String mode) throws CoreException {
236
		IProject[] projects = ExternalToolsBuildTab.getBuildProjects(configuration, null);
237
		if (projects == null) {
238
			return null ;
239
		}
240
		boolean isRef = ExternalToolsBuildTab.isIncludeReferencedProjects(configuration, null);
241
		if (isRef) {
242
			return computeReferencedBuildOrder(projects);
243
		}
244
		return computeBuildOrder(projects);
245
	}
246
}
(-)plugin.properties (-2 lines)
Lines 26-35 Link Here
26
Action.externalToolsTip = Run Last Tool
26
Action.externalToolsTip = Run Last Tool
27
PropertyPage.externalToolsBuilders = Builders
27
PropertyPage.externalToolsBuilders = Builders
28
28
29
Builder.externalTools = Integrated External Tool Builder
30
PreferencePage.externalToolsPreferences = External Tools
29
PreferencePage.externalToolsPreferences = External Tools
31
30
32
Program.externalTools = Program
33
programLaunchConfigurationTabGroup.description=Run a program
31
programLaunchConfigurationTabGroup.description=Run a program
34
programBuilderLaunchConfigurationTabGroup.description=Create a configuration that will run a program during builds
32
programBuilderLaunchConfigurationTabGroup.description=Create a configuration that will run a program during builds
35
33
(-)plugin.xml (-28 lines)
Lines 99-134 Link Here
99
		</enabledWhen>
99
		</enabledWhen>
100
      </page>
100
      </page>
101
   </extension>
101
   </extension>
102
   <extension
103
         id="ExternalToolBuilder"
104
         name="%Builder.externalTools"
105
         point="org.eclipse.core.resources.builders">
106
      <builder
107
      	isConfigurable= "true">
108
         <run
109
               class="org.eclipse.ui.externaltools.internal.model.ExternalToolBuilder">
110
         </run>
111
      </builder>
112
   </extension>
113
<!-- Launch Configuration Extensions -->
102
<!-- Launch Configuration Extensions -->
114
   <extension
103
   <extension
115
         point="org.eclipse.debug.core.launchConfigurationTypes">
116
      <launchConfigurationType
117
            name="%Program.externalTools"
118
            delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate"
119
            category="org.eclipse.ui.externaltools"
120
            modes="run"
121
            id="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
122
      </launchConfigurationType>
123
      <launchConfigurationType
124
            name="%Program.externalTools"
125
            delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate"
126
            category="org.eclipse.ui.externaltools.builder"
127
            modes="run"
128
            id="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
129
      </launchConfigurationType>
130
   </extension>
131
   <extension
132
         point="org.eclipse.ui.externaltools.configurationDuplicationMaps">
104
         point="org.eclipse.ui.externaltools.configurationDuplicationMaps">
133
      <configurationMap
105
      <configurationMap
134
            sourceType="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"
106
            sourceType="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"

Return to bug 264338