Bug 412809 - Add support for the include task (was: Ant include tag shows errors for files outside of Eclipse project)
Summary: Add support for the include task (was: Ant include tag shows errors for files...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement with 5 votes (vote)
Target Milestone: 4.14 M3   Edit
Assignee: Alexander Blaas CLA
QA Contact:
URL:
Whiteboard: 4.14 M2
Keywords: plan
: 434187 (view as bug list)
Depends on: 549810 560724
Blocks:
  Show dependency tree
 
Reported: 2013-07-11 18:05 EDT by Daniel Moore CLA
Modified: 2020-03-04 07:57 EST (History)
9 users (show)

See Also:


Attachments
Patch for bug 412809: Support for include task added (30.23 KB, patch)
2019-07-16 13:21 EDT, Alexander Blaas CLA
no flags Details | Diff
patched plugin-jar tested with eclipse oxygen 3 (4.7.3) and 2019-03 (4.11.0) (1.02 MB, application/x-java-archive)
2019-07-16 13:40 EDT, Alexander Blaas CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Moore CLA 2013-07-11 18:05:48 EDT
To Reproduce:
1) Specific ant file "build.xml"

    <project name="Specific">

        <include file="../../../common.xml" as="common" />

        <!-- Error Here -->
        <target name="deploy" depends="common.deploy"/>

    </project>

2) Ant common build file "common.xml" located in a higher directory, outside of the Eclipse project folder:

    <project name="common">
        <target name="deploy">
            <echo>test</echo>
        </target>
    </project>

Expected:
No errors in editor

Actual:
 - Editor displays error at above-marked line : "Target shared.deploy does not exist in this project"
 - "deploy" target in "build.xml" works with command line ant

Note: removing the "as" attribute on the <include> and all the "common" prefixes doesn't seem to fix the problem.  Using the <import> tag, however, does seem to make the error disappear.
Comment 1 Daniel Moore CLA 2013-07-11 20:25:16 EDT
I made a mistake in my listing of the error.  It should be "Target common.deploy does not exist in this project".  

The issue is that <import> tags seem to allow you to import files outside of an Eclipse project without error, but <include> tags cause an error.
Comment 2 Michael Rennie CLA 2013-08-08 10:40:32 EDT
Thanks for the bug report Daniel. The reason this does not work is that we have not added support for the include task yet - I know, I know, it came out in Ant 1.8.x, but there has been no committer time to work on it.

I'm going to try and make time to get this done in M2.
Comment 3 Michael Rennie CLA 2014-05-06 09:55:12 EDT
*** Bug 434187 has been marked as a duplicate of this bug. ***
Comment 4 Michael Breu CLA 2018-09-28 05:36:42 EDT
Hello,

I don't know, when the milestone M2 is planned :-) .

However we're quite suffering from this problems, too, and I hate to get red marks on my projects for non-errors

How difficult would it be to provide as a workaround an option to switch off ant target checking in this project? I did not find anything.

Would help me alot.

Thank you

Michael
Comment 5 Sarika Sinha CLA 2018-09-28 07:03:48 EDT
No one currently working on this and this not planned for any release right now. We will seek help from the community to provide a quality patch to solve this.
Comment 6 alexandre cailliaud CLA 2019-06-09 08:26:31 EDT
Hello

This bug creates a lot of error markers on my project (150 markers ^^ )

Does it planned for this year to correct this bug ?

Best regards
Comment 7 Sarika Sinha CLA 2019-06-09 23:33:28 EDT
Not for 4.13 but will see if we can do something for 4.14 for December release.

If anyone from community can come forward it will be great.
Comment 8 Alexander Blaas CLA 2019-07-16 13:21:53 EDT
Created attachment 279293 [details]
Patch for bug 412809: Support for include task added

The attached patch should fix the wrong error reports caused by the include-tasks.

Short description of the solution:

The org.eclipse.ant.ui-implementation (and the underlying ant-implementation) is able to handle import-tasks (AntImportNode), but not include-tasks. I added the missing node-type (AntIncludeNode) and "registered" the new node-type at the node-selection-functionality (AntModel).
Furthermore the new node type needs to handle target-prefixes correctly on included files (according to the documentation at https://ant.apache.org/manual/Tasks/include.html). This functionality is also part of this proposed patch and should allow to use "multi-hierarchical" includes with/without aliases (i.e. "includes inside includes" with/without using the "as"-property).


Provided tests:

I extended the test-file AntUtilTests and provided several test-build-files and the following tests:
- Simple include-hierarchy (1-level) without using aliases
- Simple include-hierarchy (1-level) with using aliases (the test-case which was initially added on this bug-description)
- Complex include-hierarchy (4-level) without using aliases
- Complex include-hierarchy (4-level) with using aliases
- Complex include-hierarchy (4-level) with and without using aliases


Open issues:

1.) The different task-types seem to have an image associated (see IAntUIConstants.java). I made a new entry for the include-task, but used the image-identifier of the import-task. If this is not desired, please add the correct image and change the identifier).

2.) Include-tasks can be defined with or without custom alias (i.e. by setting the "as"-property). If no alias is set, the identifier to identify a certain target within an included build-file is the project-name. I couldn't find the project-name of the included file where the desired target is located: Every AntTaskNode contains a reference to the project via getTask().getProject(), but this project seems to be always the top-level-project (and not the project where the target is located).
Hence my course of action to extract the project-name is to "reparse" the build-file (I got the build-file by calling getIFile()-method of AntElementNode), where the target is located (i.e. by extracting the <project name="projectName">-tag). If I have overseen a more elegant way, please adjust this also.


Further notes:

I had problems to generate the attached patch-file (eclipse didn't include all changes in the patch-file at the first try). I hope I could have fixed this problem and attached the correct and complete patch-file. If not, please let me know and I'll try it again ;)

Kind regards,

Alex
Comment 9 Alexander Blaas CLA 2019-07-16 13:40:15 EDT
Created attachment 279294 [details]
patched plugin-jar tested with eclipse oxygen 3 (4.7.3) and 2019-03 (4.11.0)

If you don't want to wait for the new release, you can patch your current eclipse-installation with the attached jar:

1.) Navigate to the eclipse-installation-folder and enter the folder "plugins".
2.) Backup the jar "org.eclipse.ant_ui_<the_current_version_number>" (if something goes wrong).
3.) Change the name of the attached jar by renaming it with the name of the "org.eclipse.ant_ui"-jar that is used by your current eclipse-installation (i.e. replacing the "_versionNumber"-suffix with the correct version-number).
4.) Copy the correctly renamed jar into the mentioned "plugin"-folder and replace the current "org.eclipse.ant_ui_<the_current_version_number>"-jar.
5.) Restart eclipse.

This temporary fix was tested with eclipse oxygen 3 (4.7.3) and eclipse 2019-03 (4.11.0).

Kind regards,
Alex
Comment 10 Paul Pazderski CLA 2019-07-16 14:46:40 EDT
(In reply to alex bl from comment #8)
> Further notes:
> 
> I had problems to generate the attached patch-file (eclipse didn't include
> all changes in the patch-file at the first try). I hope I could have fixed
> this problem and attached the correct and complete patch-file. If not,
> please let me know and I'll try it again ;)
> 
> Kind regards,
> 
> Alex

Unfortunately patches are only accepted as Gerrit changes this days. For instructions how to create them see 
https://wiki.eclipse.org/Platform/How_to_Contribute#Creating_a_Gerrit_review_or_a_patch 
or
https://wiki.eclipse.org/Platform-releng/Git_Workflows#Gerrit_workflow_for_a_committer

Good luck. :D (and of cause ask if you need help)
Comment 11 Andrey Loskutov CLA 2019-07-16 17:58:34 EDT
Alex, you should also sign ECA agreement https://www.eclipse.org/legal/ECA.php (do you see red ECA icon next to your name in bugzilla?). This is precondition for contributing.
Comment 12 Sarika Sinha CLA 2019-07-17 00:10:37 EDT
Thanks Alex for stepping up!
Comment 13 Alexander Blaas CLA 2019-08-03 13:51:20 EDT
(In reply to Paul Pazderski from comment #10)
> 
> Unfortunately patches are only accepted as Gerrit changes this days. For
> instructions how to create them see 
> https://wiki.eclipse.org/Platform/
> How_to_Contribute#Creating_a_Gerrit_review_or_a_patch 
> or
> https://wiki.eclipse.org/Platform-releng/
> Git_Workflows#Gerrit_workflow_for_a_committer
> 
> Good luck. :D (and of cause ask if you need help)

I'm pretty sure that I followed all the instructions described at these links :)
But my attempt to push my changes is rejected:

An error happened while checking if user has a signed agreement
Processing changes: refs: 1
Processing changes: refs: 1, done


I signed the ECA agreement a couple of hours ago and I used the correct e-mail-address (the one associated with my eclipse user account).

Any ideas what's going wrong here?
Comment 14 Andrey Loskutov CLA 2019-08-03 14:51:51 EDT
(In reply to Alexander Blaas from comment #13)
> (In reply to Paul Pazderski from comment #10)
> > 
> > Unfortunately patches are only accepted as Gerrit changes this days. For
> > instructions how to create them see 
> > https://wiki.eclipse.org/Platform/
> > How_to_Contribute#Creating_a_Gerrit_review_or_a_patch 
> > or
> > https://wiki.eclipse.org/Platform-releng/
> > Git_Workflows#Gerrit_workflow_for_a_committer
> > 
> > Good luck. :D (and of cause ask if you need help)
> 
> I'm pretty sure that I followed all the instructions described at these
> links :)
> But my attempt to push my changes is rejected:
> 
> An error happened while checking if user has a signed agreement
> Processing changes: refs: 1
> Processing changes: refs: 1, done
> 
> 
> I signed the ECA agreement a couple of hours ago and I used the correct
> e-mail-address (the one associated with my eclipse user account).
> 
> Any ideas what's going wrong here?

Sure you were using "olaf.dev17" at gmail.com account? It is shown "green" in bugzilla, so it should be OK for Gerrit too. Try again, may be Gerrit has its usual "weekend" instabilities phase again?
Comment 15 Alexander Blaas CLA 2019-08-04 04:32:14 EDT
(In reply to Andrey Loskutov from comment #14)
> (In reply to Alexander Blaas from comment #13)
> > (In reply to Paul Pazderski from comment #10)
> > > 
> > > Unfortunately patches are only accepted as Gerrit changes this days. For
> > > instructions how to create them see 
> > > https://wiki.eclipse.org/Platform/
> > > How_to_Contribute#Creating_a_Gerrit_review_or_a_patch 
> > > or
> > > https://wiki.eclipse.org/Platform-releng/
> > > Git_Workflows#Gerrit_workflow_for_a_committer
> > > 
> > > Good luck. :D (and of cause ask if you need help)
> > 
> > I'm pretty sure that I followed all the instructions described at these
> > links :)
> > But my attempt to push my changes is rejected:
> > 
> > An error happened while checking if user has a signed agreement
> > Processing changes: refs: 1
> > Processing changes: refs: 1, done
> > 
> > 
> > I signed the ECA agreement a couple of hours ago and I used the correct
> > e-mail-address (the one associated with my eclipse user account).
> > 
> > Any ideas what's going wrong here?
> 
> Sure you were using "olaf.dev17" at gmail.com account? It is shown "green"
> in bugzilla, so it should be OK for Gerrit too. Try again, may be Gerrit has
> its usual "weekend" instabilities phase again?

Yes, that's the e-mail I used in the "Signed-off-by"-line, as author and committer. I tried to insert another e-mail, just for fun. Then I got a proper error: "The email address does not match your user account. The following addresses are currently registered: olaf.dev17 at gmail.com".
I retried it several times (the last attempt was a couple of minutes ago), but got the same result. I'll try it again after the weekend.
Comment 16 Sarika Sinha CLA 2019-08-05 02:26:17 EDT
Please try again and if does not work, please create a bug with Eclipse Community-> webmaster. He can look into the issue.
Comment 17 Sarika Sinha CLA 2019-08-19 04:57:29 EDT
Moving the bug to RC1.
Hopefully we will have the issue resolved soon.
Comment 18 Eclipse Genie CLA 2019-08-21 12:23:28 EDT
New Gerrit change created: https://git.eclipse.org/r/148074
Comment 19 Eclipse Genie CLA 2019-08-21 12:33:42 EDT
New Gerrit change created: https://git.eclipse.org/r/148076
Comment 20 Eclipse Genie CLA 2019-08-21 12:47:57 EDT
New Gerrit change created: https://git.eclipse.org/r/148077
Comment 21 Eclipse Genie CLA 2019-08-22 06:50:38 EDT
New Gerrit change created: https://git.eclipse.org/r/148124
Comment 22 Eclipse Genie CLA 2019-08-22 07:09:15 EDT
New Gerrit change created: https://git.eclipse.org/r/148125
Comment 23 Eclipse Genie CLA 2019-08-22 07:20:30 EDT
New Gerrit change created: https://git.eclipse.org/r/148126
Comment 24 Paul Pazderski CLA 2019-08-22 07:25:31 EDT
Alexander you can and should reuse your changes instead of creating new ones i.e. you should amend changes and repush the commit.
If you upload a commit with the same Change-Id in the commit message as a previous commit Gerrit will reuse the same change and show the new commit as new patchset and also will trigger a new build.
E.g. for your incomplete https://git.eclipse.org/r/#/c/148124/ you could amend your local with the missing pom.xml change and then push it again with the same Change-Id: I0187b10ba1d983ff6b1bd5b10ab956cae1b1a3e8 and Gerrit had updated this one instead of creating https://git.eclipse.org/r/148125.
Comment 25 Paul Pazderski CLA 2019-08-22 07:27:47 EDT
PS: anyone who wants to review the change? I'm not experienced with the Eclipse Ant code and not even use Ant very often so anyone other than me might be a better reviewer.
Comment 26 Sarika Sinha CLA 2019-08-22 08:00:09 EDT
I will review the change tomorrow, please create one Gerrit with complete changes.
Some quick observations:
1. We don't need to add in forceQualifierUpdate, we can increase the bundle version
2. Why do we need an update in css files?
Comment 27 Alexander Blaas CLA 2019-08-23 07:53:28 EDT
(In reply to Paul Pazderski from comment #24)
> Alexander you can and should reuse your changes instead of creating new ones
> i.e. you should amend changes and repush the commit.
> If you upload a commit with the same Change-Id in the commit message as a
> previous commit Gerrit will reuse the same change and show the new commit as
> new patchset and also will trigger a new build.
> E.g. for your incomplete https://git.eclipse.org/r/#/c/148124/ you could
> amend your local with the missing pom.xml change and then push it again with
> the same Change-Id: I0187b10ba1d983ff6b1bd5b10ab956cae1b1a3e8 and Gerrit had
> updated this one instead of creating https://git.eclipse.org/r/148125.

Didn't know that. Thanks for the information.

(In reply to Sarika Sinha from comment #26)
> I will review the change tomorrow, please create one Gerrit with complete
> changes.
> Some quick observations:
> 1. We don't need to add in forceQualifierUpdate, we can increase the bundle
> version
> 2. Why do we need an update in css files?

I'm sorry, I couldn't answer earlier.
Is there a way to delete the unnecessary gerrit changes?

The css files: These changes were part of a merge-commit. They have nothing to do with my patch.
Comment 28 Paul Pazderski CLA 2019-08-23 08:07:09 EDT
(In reply to Alexander Blaas from comment #27)
> Is there a way to delete the unnecessary gerrit changes?

How to remove them here you already figured out yourself. In the changes you can "Abandon" them. That counts as deleted.
Comment 29 Eclipse Genie CLA 2019-08-23 08:24:15 EDT
New Gerrit change created: https://git.eclipse.org/r/148220
Comment 30 Alexander Blaas CLA 2019-08-23 08:47:36 EDT
(In reply to Paul Pazderski from comment #28)
> (In reply to Alexander Blaas from comment #27)
> > Is there a way to delete the unnecessary gerrit changes?
> 
> How to remove them here you already figured out yourself. In the changes you
> can "Abandon" them. That counts as deleted.

Ok, thanks. The final gerrit change should be ready for review :-)
Comment 31 Sarika Sinha CLA 2019-08-24 09:09:49 EDT
(In reply to Alexander Blaas from comment #30)
> 
> Ok, thanks. The final gerrit change should be ready for review :-)

I have provided the comments on the Gerrit.
Comment 32 Sarika Sinha CLA 2019-08-27 03:16:36 EDT
Moving to 4.14 M1.
Comment 34 Sarika Sinha CLA 2019-10-15 00:28:06 EDT
Thanks Alexander!

Please add an entry to N&N , then we can resolve the bug.
Comment 35 Alexander Blaas CLA 2019-10-15 16:34:39 EDT
(In reply to Sarika Sinha from comment #34)
> Thanks Alexander!
> 
> Please add an entry to N&N , then we can resolve the bug.

Sure, no problem. How, respectively, where can I do that?
Comment 36 Sarika Sinha CLA 2019-10-15 23:38:50 EDT
(In reply to Alexander Blaas from comment #35)
> (In reply to Sarika Sinha from comment #34)
> > Thanks Alexander!
> > 
> > Please add an entry to N&N , then we can resolve the bug.
> 
> Sure, no problem. How, respectively, where can I do that?

Repo is : www.eclipse.org/eclipse/news.git
You can add an entry in Platform for 4.14.
Checkout the Instructions first available in the repo.
Comment 37 Eclipse Genie CLA 2019-10-16 04:59:27 EDT
New Gerrit change created: https://git.eclipse.org/r/151143
Comment 38 Alexander Blaas CLA 2019-10-16 05:02:47 EDT
(In reply to Sarika Sinha from comment #36)
> 
> Repo is : www.eclipse.org/eclipse/news.git
> You can add an entry in Platform for 4.14.
> Checkout the Instructions first available in the repo.

Thanks for the information. I added the new entry as suggested.
Comment 40 Sarika Sinha CLA 2019-10-16 05:41:15 EDT
Thanks!
Comment 41 Eclipse Genie CLA 2019-10-18 00:52:18 EDT
New Gerrit change created: https://git.eclipse.org/r/151279
Comment 42 Sarika Sinha CLA 2019-10-18 01:03:22 EDT
We have test failures in ant ui
https://download.eclipse.org/eclipse/downloads/drops4/I20191016-1800/testResults.php
Comment 44 Sarika Sinha CLA 2019-10-20 23:04:17 EDT
@Alexander,
We have all the new tests failing on Windows, can you look into it?
https://download.eclipse.org/eclipse/downloads/drops4/I20191019-1800/testresults/html/org.eclipse.ant.tests.ui_ep414I-unit-win32-java8_win32.win32.x86_64_8.0.html
Comment 45 Alexander Blaas CLA 2019-10-21 03:52:33 EDT
(In reply to Sarika Sinha from comment #44)
> @Alexander,
> We have all the new tests failing on Windows, can you look into it?
> https://download.eclipse.org/eclipse/downloads/drops4/I20191019-1800/
> testresults/html/org.eclipse.ant.tests.ui_ep414I-unit-win32-java8_win32.
> win32.x86_64_8.0.html

Sure. I'll have a look.
Comment 46 Alexander Blaas CLA 2019-10-21 05:51:40 EDT
(In reply to Sarika Sinha from comment #44)
> @Alexander,
> We have all the new tests failing on Windows, can you look into it?
> https://download.eclipse.org/eclipse/downloads/drops4/I20191019-1800/
> testresults/html/org.eclipse.ant.tests.ui_ep414I-unit-win32-java8_win32.
> win32.x86_64_8.0.html

Issue found and resolved (a non-uniform way to retrieve file-paths which resulted in different hash-map keys on windows).

Before I push the fix:

The performance-test still fails: It seems that it takes much more time on windows than on linux...

Are you aware of such a "general performance-issue" on windows? If not, may I should review my solution.
Comment 47 Sarika Sinha CLA 2019-10-21 06:21:35 EDT
(In reply to Alexander Blaas from comment #46)
> (In reply to Sarika Sinha from comment #44)
> > @Alexander,
> > We have all the new tests failing on Windows, can you look into it?
> > https://download.eclipse.org/eclipse/downloads/drops4/I20191019-1800/
> > testresults/html/org.eclipse.ant.tests.ui_ep414I-unit-win32-java8_win32.
> > win32.x86_64_8.0.html
> 
> Issue found and resolved (a non-uniform way to retrieve file-paths which
> resulted in different hash-map keys on windows).
> 
> Before I push the fix:
> 
> The performance-test still fails: It seems that it takes much more time on
> windows than on linux...
> 
> Are you aware of such a "general performance-issue" on windows? If not, may
> I should review my solution.

We have seen some issues on Windows, I can't deny that. But it will be good if you can review the solution also. 
In the worst case we will have need to have a higher threshold for win only in the test.
Comment 48 Eclipse Genie CLA 2019-10-21 11:07:51 EDT
New Gerrit change created: https://git.eclipse.org/r/151398
Comment 49 Alexander Blaas CLA 2019-10-21 11:25:01 EDT
(In reply to Sarika Sinha from comment #47)
> (In reply to Alexander Blaas from comment #46)
> > (In reply to Sarika Sinha from comment #44)
> > > @Alexander,
> > > We have all the new tests failing on Windows, can you look into it?
> > > https://download.eclipse.org/eclipse/downloads/drops4/I20191019-1800/
> > > testresults/html/org.eclipse.ant.tests.ui_ep414I-unit-win32-java8_win32.
> > > win32.x86_64_8.0.html
> > 
> > Issue found and resolved (a non-uniform way to retrieve file-paths which
> > resulted in different hash-map keys on windows).
> > 
> > Before I push the fix:
> > 
> > The performance-test still fails: It seems that it takes much more time on
> > windows than on linux...
> > 
> > Are you aware of such a "general performance-issue" on windows? If not, may
> > I should review my solution.
> 
> We have seen some issues on Windows, I can't deny that. But it will be good
> if you can review the solution also. 
> In the worst case we will have need to have a higher threshold for win only
> in the test.

The performance issue seems not to be caused by the bugfix: Neither the construction of the property holder (i.e. storing the parsed project-names) nor the target-prefix-construction (i.e. either querying the property holder or retrieving the project-alias-properties and combining them: All the code executed at AntIncludeNode.java between lines 50 and 60) have an execution time of >5ms.

As you suggested, I added an OS-dependend treshold (for win 15s just to be sure, for all other OS the 7.5s remain).
Comment 51 Sarika Sinha CLA 2019-10-22 01:42:59 EDT
(In reply to Alexander Blaas from comment #49)
> 
> The performance issue seems not to be caused by the bugfix: Neither the
> construction of the property holder (i.e. storing the parsed project-names)
> nor the target-prefix-construction (i.e. either querying the property holder
> or retrieving the project-alias-properties and combining them: All the code
> executed at AntIncludeNode.java between lines 50 and 60) have an execution
> time of >5ms.
> 
> As you suggested, I added an OS-dependend treshold (for win 15s just to be
> sure, for all other OS the 7.5s remain).

Thanks! Where you able to trace the culprit method or file where the time was spent?
We can create a separate bug to work on that.
Comment 52 Alexander Blaas CLA 2019-10-22 04:10:16 EDT
(In reply to Sarika Sinha from comment #51)
> (In reply to Alexander Blaas from comment #49)
> > 
> > The performance issue seems not to be caused by the bugfix: Neither the
> > construction of the property holder (i.e. storing the parsed project-names)
> > nor the target-prefix-construction (i.e. either querying the property holder
> > or retrieving the project-alias-properties and combining them: All the code
> > executed at AntIncludeNode.java between lines 50 and 60) have an execution
> > time of >5ms.
> > 
> > As you suggested, I added an OS-dependend treshold (for win 15s just to be
> > sure, for all other OS the 7.5s remain).
> 
> Thanks! Where you able to trace the culprit method or file where the time
> was spent?
> We can create a separate bug to work on that.

I just reviewed the code belonging to this bugfix. But I'll open a new bug report to investigate that.
Comment 53 Sarika Sinha CLA 2019-11-19 04:03:58 EST
Build id: I20191118-0600