| Summary: | [launching] [builders] Ant Builder doesn't build with Target set to <default> | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Filip Jirsák <Filip.Jirsak> | ||||||||||
| Component: | Ant | Assignee: | Michael Rennie <Michael_Rennie> | ||||||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | alexander.tress.atr, autophile, curtis.windatt.public, daniel_megert, darin.eclipse, Darin_Swanson, markus.kell.r, Michael_Rennie, noobs.temp, sptaszkiewicz | ||||||||||
| Version: | 3.1.1 | Flags: | markus.kell.r:
review+
|
||||||||||
| Target Milestone: | 3.7 M6 | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows XP | ||||||||||||
| Whiteboard: | |||||||||||||
| Bug Depends on: | |||||||||||||
| Bug Blocks: | 335860, 335861, 335967, 340864 | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Filip Jirsák
*** Bug 223894 has been marked as a duplicate of this bug. *** looks like the fix to bug 63685 might be the culprit here. when no targets were selected we used to make the following call: setTargetsForUser(text, DEFAULT_TARGET_SELECTED, null); this was subsequently changed to short-circuit doing nothing. Created attachment 165391 [details]
Patch
removing as RC1 candidate. Evaluating the impact of the patch and other considerations, this is much too large to consider now. The main two reasons being: 1. the patch will cause all existing - previously valid - configurations now have errors, which is regression, and 2. we cannot start adding in additional Ant targets suddenly, this can have a dramatic performance impact on existing Ant builders. Given the previous comment this doesn't look like a 3.6.x fix. This should first be put into 3.7 to gather feedback before anything is released into 3.6.x. This is working for me in 3.7
Steps:
* Create a new Java project called "xyz" with default settings
* Create a class in the "src" folder falled "Hello"
* Create a build.xml file in the root of the project with these contents:
<?xml version="1.0" encoding="UTF-8"?>
<project name="project-builder" default="default">
<description>
Builder
</description>
<target name="default" description="description">
<echo>DEFAULT</echo>
</target>
<target name="fullBuild">
<echo>FULL</echo>
</target>
<target name="incrementalBuild">
<echo>INCREMENTAL</echo>
</target>
<target name="autoBuild">
<echo>AUTO</echo>
</target>
<target name="clean">
<echo>CLEAN</echo>
</target>
</project>
* Select the project's Builder properties
* Add a new Ant builder that references the given build file
* By default the default targets are selected for "After a clean" (Full build) and "Manual build"
* Press OK
* Turn off auto build
* Modify the source file
* Press CTRL-B, the default target runs
* Select "Project > Clean" (select just the project "xyz", press OK
* Default target runs
(In reply to comment #6) > This is working for me in 3.7 This is not working for me in I20101116-0800 using the following: <?xml version="1.0" encoding="UTF-8"?> <project name="project" default="default"> <target name="default"> <echo>DEFAULT</echo> </target> <target name="inc"> <echo>INC</echo> </target> <target name="clean"> <echo>CLEAN</echo> </target> <target name="full"> <echo>FULL</echo> </target> <target name="auto"> <echo>AUTO</echo> </target> </project> in file builder.ent Steps 1. create the aforementioned file 2. create a new builder for the desired project, and point it to the build file created in step 1. Do not change to any other tabs or do anything, just click OK to create the new builder. 3. turn off auto-build 4. Press Ctrl+B you get: Buildfile: /home/mrennie/workspaces/workspace/P3/builder.ent default: [echo] DEFAULT BUILD SUCCESSFUL Total time: 145 milliseconds 5. Project > Clean, nothing happens 6. Project > Build Project, nothing happens (In reply to comment #7) > This is not working for me in I20101116-0800 This works very strangely in 3.6.2 (M20101117-1123) as well. Using the steps from comment #7, I get nothing happening after a Clean, and only sometimes do I get anything for a full build / project build. It seems that there may be a selection problem, because if I do the following I can always get build output for full / project build 1. select the project, Project > Clean... 2. Project > Build project, you get: Buildfile: /home/mrennie/workspaces/workspace-3.6.1/AntTest/builder.ent default: [echo] DEFAULT BUILD SUCCESSFUL Total time: 137 milliseconds 3. Project > Clean, Project > Build project, nothing happens NB: if you go to the package / project explorer and re-select (the already selected) project before step 3, then it will work. No idea whether related or not, but thought I mention it here: bug 323588. There is also bug 207883 that seems to be quite similar to this one. > (In reply to comment #8) > > This works very strangely in 3.6.2 (M20101117-1123) as well. I tested this again in a fresh workspace. I think there is a lot of confusion around how the build framework works that makes this appear to not work. Steps 1. create a new workspace 2. create a new project 3. create builder.ent as mentioned in comment #7 4. turn off autobuild 5. add builder.ent to the project as an Ant builder. Don't change any of the settings, press OK At this point the project has no previous built state 6. Ctrl+B ( or Project > Build Project) - default target runs [OK] 7. Project > Clean, select the project, uncheck 'start build immediately' - nothing happens [OK] 8. Ctrl+B (or Project > Build Project) - default target run [OK] 9. Project > Clean , select project, check 'start build immediately' - default target runs [OK] 10. Ctrl+B (or Project > Build Project) - nothing happens, because the project is built (has a built state) [OK] 11. Create a class file as mentioned in comment #6 12. edit the class, save, Ctrl+b (or Project > Build Project) default target runs [OK] I think the confusion comes in when a user tries to get the Ant builder to run when there is a built state for the project - meaning the project has already been built and no changes have been made to it since the last time the builder ran. In this case all build commands will do nothing except for Project > Clean, even then if 'start build immediately' is unchecked the clean build command will do nothing. These are the expected results. I am wondering now if I fell victim to the same problem in comment #7 step 5: > 5. Project > Clean, nothing happens where I forgot to check on 'start build immediately' I am getting the feeling that trying to get the Ant builder to run successively without cleaning the project or making changes to it is what is throwing people off. I did find a failing case: steps from comment #11 with a change to step 5: 5a. go to the targets tab and remove the default target from the After a Clean section Once this has been done the Project > Build Project command will not do anything regardless of cleans between build attempts. However the Ctrl+B (Project > Build All) will still work. The problem is that Project > Build Project triggers an incremental build (build trigger == 10), so if there are no changes in the project, even cleaning it ahead of time will not cause a build. The problem appears to be in the code AntBuilderTargetsTab#performApply(..). In there we only set the INCREMENTAL build trigger for manual builds and I don't see any history describing why. I would assume we would set the FULL *and* INCREMENTAL triggers. Darin S, do you recall any history on why we only set INCREMENTAL for a trigger kind on Manual as opposed to INCREMENTAL *and* FULL? Created attachment 184083 [details] proposed fix This patch fixes up AntBuilderTargetsTab and ExternalToolsBuilderTab to set the FULL kind for Manual as well as INCREMENTAL. It fixes the use case mentioned in the previous comment and does not always cause a full build (what we want) - it only causes a full build when a clean has been done since the last build, incremental building works as it did before. The only related bug to the handling of the build types is bug 63685. applied patch to HEAD for 3.7M5 *** Bug 160895 has been marked as a duplicate of this bug. *** *** Bug 196811 has been marked as a duplicate of this bug. *** *** Bug 335998 has been marked as a duplicate of this bug. *** Reopening. The proposed fix, while it does cause the correct build kind to occur, causes a UI quirk as outlined in bug 335998. Created attachment 188199 [details] update This patch changes the solution a bit, so that the launch configuration backing the builder is no longer affected - no longer causing bug 335998. Instead of adding the 'full' build kind to the configuration, this patch moves the solution to BuilderCoreUtils#configureTriggers(...), where we actually write out the build command for the project based on what is in the configuration. So now when we are configuring the build command, if the clean targets are not to be used (config value is null and 'full' is not set as a build kind) and we have manual targets specified (default or specific), we add an entry in the build command that it should answer 'yes' to running for full builds, and a build argument so we know where to collect the targets from when the builder actually runs. Created attachment 188608 [details]
patch + regression tests
This is an updated patch that has regression tests for the new behavior.
The tests can be found in BuilderCoreUtilsTests in the Ant UI test bundle.
applied patch with tests to HEAD Markus, please review. I also updated the test script to highlight expected results from the target build kinds: http://wiki.eclipse.org/Ant/Test_Script#External_Tools In HEAD, bug 335998 is still present. Just start with a new builder with "after clean" and "manual" set to default target, and then remove the "after clean" target. When you edit the build again, the "after clean" target is set to default. I also noticed that the Project > Clean... command is not available when the workspace only contains a project with an ant builder whose "during a clean" target is not configured. In that case, the "after clean" target is never executed. But as soon as I add another builder, the Clean... action becomes available. The first build after a clean then executes the "after clean" target. That looks a bit strange. I would expect that either Clean... is always enabled, or that the "after clean" target is always disabled, as long as no "during a clean" target has been configured. Checking the patch + commit, I found that part of the fix was not included (the changes to AntBuildersTargetTab specifically) - perhaps I was stung by bug 294650. I have committed these missing changes to HEAD. I've checked the changes in HEAD of ExternalToolBuilder, BuilderCoreUtils, AntBuilderTargetsTab, ExternalToolsBuilderTab. The behavior seems right to me and the changes look good, except for a possible NPE in BuilderCoreUtils#configureTriggers(..): "newCommand.getArguments()" can return null, so for complete safety, you have to insert this before calling args.put(..): if (args == null) args = new HashMap(1); (In reply to comment #25) > "newCommand.getArguments()" can return null, so for complete safety, you have > to insert this before calling args.put(..): > > if (args == null) > args = new HashMap(1); Good idea. I have added the suggested null check to HEAD. Thanks for verifying Markus. |