diff --git a/WHATSNEW b/WHATSNEW
index 0c91e8e45..88f54d7a1 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -40,6 +40,9 @@ Fixed bugs:
* fix for junit4 issue introducted since beta2.
Bugzilla report 40682.
+* Error in duplicate project name with and .
+ Bugzilla report 39920.
+
Other changes:
--------------
diff --git a/docs/manual/CoreTasks/import.html b/docs/manual/CoreTasks/import.html
index 533eb0956..63ec92f61 100644
--- a/docs/manual/CoreTasks/import.html
+++ b/docs/manual/CoreTasks/import.html
@@ -79,6 +79,10 @@ property of the main buildfile.
Note that "builddocs" is not the filename, but the name attribute
present in the imported project tag.
+
+ If import file does not have a name attribute, the ant.file.projectname
+ property will not be set.
+
Resolving files against the imported file
diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
index 78fa690fc..0450bf25f 100644
--- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
+++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
@@ -738,7 +738,7 @@ public class ProjectHelper2 extends ProjectHelper {
}
}
- if (context.getBuildFile() != null) {
+ if (context.getBuildFile() != null && nameAttributeSet) {
project.setUserProperty("ant.file."
+ context.getCurrentProjectName(),
context.getBuildFile().toString());