git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1481662 13f79535-47bb-0310-9956-ffa450edef68master
@@ -4,6 +4,9 @@ Changes from Ant 1.9.0 TO current | |||||
Changes that could break older environments: | Changes that could break older environments: | ||||
------------------------------------------- | ------------------------------------------- | ||||
* Users who have their own ProjectHelper implementation will need to change it because the import and include tasks | |||||
will now default the targetPrefix to ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX. | |||||
Users using the default ProjectHelper2 with ant need not worry about this change done to fix Bugzilla Report 54940. | |||||
Fixed bugs: | Fixed bugs: | ||||
@@ -21,6 +24,11 @@ Fixed bugs: | |||||
* Fixed loading of external dependencies in JUnit task. | * Fixed loading of external dependencies in JUnit task. | ||||
Bugzilla Report 54835. | Bugzilla Report 54835. | ||||
* Target rewriting for nested "include" only works when "as" is specified. | |||||
See also "Changes that could break older environments" | |||||
Bugzilla Report 54940. | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -71,6 +71,12 @@ public class ProjectHelper { | |||||
*/ | */ | ||||
public static final String PROJECTHELPER_REFERENCE = MagicNames.REFID_PROJECT_HELPER; | public static final String PROJECTHELPER_REFERENCE = MagicNames.REFID_PROJECT_HELPER; | ||||
/** | |||||
* constant to denote use project name as target prefix | |||||
* @since Ant 1.9.1 | |||||
*/ | |||||
public static final String USE_PROJECT_NAME_AS_TARGET_PREFIX = "USE_PROJECT_NAME_AS_TARGET_PREFIX"; | |||||
/** | /** | ||||
* Configures the project with the contents of the specified build file. | * Configures the project with the contents of the specified build file. | ||||
* | * | ||||
@@ -732,12 +732,10 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
project.setName(value); | project.setName(value); | ||||
project.addReference(value, project); | project.addReference(value, project); | ||||
} else if (isInIncludeMode()) { | } else if (isInIncludeMode()) { | ||||
if (!"".equals(value) | |||||
&& (getCurrentTargetPrefix() == null | |||||
|| getCurrentTargetPrefix().length() == 0) | |||||
) { | |||||
if (!"".equals(value) && getCurrentTargetPrefix()!= null && getCurrentTargetPrefix().endsWith(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX)) { | |||||
String newTargetPrefix = getCurrentTargetPrefix().replace(ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX, value); | |||||
// help nested include tasks | // help nested include tasks | ||||
setCurrentTargetPrefix(value); | |||||
setCurrentTargetPrefix(newTargetPrefix); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -64,7 +64,7 @@ import java.util.Vector; | |||||
public class ImportTask extends Task { | public class ImportTask extends Task { | ||||
private String file; | private String file; | ||||
private boolean optional; | private boolean optional; | ||||
private String targetPrefix; | |||||
private String targetPrefix = ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX; | |||||
private String prefixSeparator = "."; | private String prefixSeparator = "."; | ||||
private final Union resources = new Union(); | private final Union resources = new Union(); | ||||
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); | ||||
@@ -199,7 +199,7 @@ public class ImportTask extends Task { | |||||
return; | return; | ||||
} | } | ||||
// nested invokations are possible like an imported file | |||||
// nested invocations are possible like an imported file | |||||
// importing another one | // importing another one | ||||
String oldPrefix = ProjectHelper.getCurrentTargetPrefix(); | String oldPrefix = ProjectHelper.getCurrentTargetPrefix(); | ||||
boolean oldIncludeMode = ProjectHelper.isInIncludeMode(); | boolean oldIncludeMode = ProjectHelper.isInIncludeMode(); | ||||
@@ -209,7 +209,9 @@ public class ImportTask extends Task { | |||||
if (isInIncludeMode() && oldPrefix != null | if (isInIncludeMode() && oldPrefix != null | ||||
&& targetPrefix != null) { | && targetPrefix != null) { | ||||
prefix = oldPrefix + oldSep + targetPrefix; | prefix = oldPrefix + oldSep + targetPrefix; | ||||
} else if (targetPrefix != null) { | |||||
} else if (isInIncludeMode()) { | |||||
prefix = targetPrefix; | |||||
} else if (!ProjectHelper.USE_PROJECT_NAME_AS_TARGET_PREFIX.equals(targetPrefix)) { | |||||
prefix = targetPrefix; | prefix = targetPrefix; | ||||
} else { | } else { | ||||
prefix = oldPrefix; | prefix = oldPrefix; | ||||
@@ -0,0 +1,22 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!-- | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
--> | |||||
<project name="w"> | |||||
<echo>${ant.file.w}</echo> | |||||
<include file="x.xml"/> | |||||
<target name="ww" depends="x.xx, x.y.yy, x.y.z.zz"/> | |||||
</project> |
@@ -0,0 +1,22 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!-- | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
--> | |||||
<project name="x"> | |||||
<echo>${ant.file.x}</echo> | |||||
<include file="y.xml"/> | |||||
<target name="xx" depends="y.yy, y.z.zz"/> | |||||
</project> |
@@ -0,0 +1,22 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!-- | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
--> | |||||
<project name="y"> | |||||
<echo>${ant.file.y}</echo> | |||||
<include file="z.xml" as="z"/> | |||||
<target name="yy" depends="z.zz"/> | |||||
</project> |
@@ -0,0 +1,21 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!-- | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
--> | |||||
<project name="z"> | |||||
<echo>${ant.file.z}</echo> | |||||
<target name="zz"/> | |||||
</project> |
@@ -18,9 +18,9 @@ | |||||
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> | <project default="antunit" xmlns:au="antlib:org.apache.ant.antunit"> | ||||
<import file="../antunit-base.xml" /> | <import file="../antunit-base.xml" /> | ||||
<include> | |||||
<file file="importtests/a.xml"/> | |||||
</include> | |||||
<include> | |||||
<file file="importtests/a.xml"/> | |||||
</include> | |||||
<include file="importtests/b.xml" as="c"/> | <include file="importtests/b.xml" as="c"/> | ||||
<target name="testNoExplicitPrefix" depends="a.a"> | <target name="testNoExplicitPrefix" depends="a.a"> | ||||
@@ -50,4 +50,9 @@ | |||||
<!-- really only tests that the targets have the expected names by | <!-- really only tests that the targets have the expected names by | ||||
forcing an exception if the dependencies don't exist --> | forcing an exception if the dependencies don't exist --> | ||||
<target name="testNesting" depends="nested.b::b, nested.aa"/> | <target name="testNesting" depends="nested.b::b, nested.aa"/> | ||||
<target name="testNoExplicitPrefixNested"> | |||||
<ant target="x.y.z.zz" antfile="importtests/w.xml"/> | |||||
</target> | |||||
</project> | </project> |