Running ANT targets using .launch file - eclipse

In one of my legacy project ant target is invoved from *.launch file. This file contains <launchConfiguration> tag and one of the attribute name "type" is ant class org.eclipse.ant.ANTLaunchConfigurationType, different parameter are set using this tag. When this launch file is executed in eclipse, one of the ANT target is executed specified in launchConfiguration tag.
I am not able to find any information around this functionality of ANT. Only relevant thread found is, which is unanswered
Running eclipse ant targets from an external command
I am not able to understand how launch files are created and how to set parameter to launchConfiguration tag.

The .launch files are created by Eclipse for every Run Configuration you want to be saved:
Open Eclipse.
Select a build.xml file.
Through the context menu, execute Run as/Ant build.... A dialog appears.
If you want to pass parameters to the Ant script, you have to fulfil the Arguments area (in the Main tab) like this:
-Darg1=value1
-Darg2=value2
...
Then, go to the Common Tab and focus on the Share file field: With the Browse button, select your project. This will create the .launch file into your project, and let it available for further executions. (You should rename it).
Execute Run.
You can edit the .launch configuration in menu Run>External tools>External tools configuration.
Note: Within the Run Configuration, you'd better spend some minutes reading all the parameters available in all the tabs. For example, in the Build tab, you can set if you want a project to be build before your script is executed (If not, unchecking the checkbox may save you a lot of time). Or in the Refresh tab, you can select which project directories you want to be refreshed after the script is executed, etc.

Launch configurations for Ant Builds are created and managed using the 'Run > External Tools > External Tools Configurations...' dialog.
You can import existing .launch files using 'File > Import... > Run/Debug > Launch Configurations'

Related

Include Run Configurations in SVN project in MyEclipse

How can I configure MyEclipse and the SVN plugin (Subclipse 4.3.3) so that my Run Configurations are included in the source code control. Every time a new developer checks out the project, he doesn't have the Run Configurations needed to test the application properly or to do the Maven packaging correctly.
Is there a way?
To share your run/launch configuration, go to the launch configuration (Run > Run Configurations...) tab Common for Save as choose Shared file (instead of Local file).
In addition, you can choose to Display in favorites menu to add it to the drop-down of the corresponding button in the main toolbar.

Run launch file automatically in Eclipse

I would like to have the possibility to run a .launch file without having to navigate to a project and folder and choose that file and right click and choose run.
It would also be nice if I could run tomcat without having to navigate to the server tab as you can see in screenshot
Is there any way I can do this?
.launch files are managed in Eclipse as Run configurations. Normally, .launch files present in an Eclipse project are automatically added to the list of run configurations for the project. These can be accessed through Run | Run Configurations... or using the run menu shortcut
If the launch files are not automatically detected when a project is first imported, running them once should allow Eclipse to detect them.

Eclipse run configuration file exists in workspace

I copied a couple of launch configurations (created by the same eclipse version) from another workspace into my current workspace, but I can't get them to show up on the UI.
And I am sure it is at the right place because it's where the config created in this workspace is located as well (That is, it is at ./.metadata/.plugins/org.eclipse.debug.core/.launches )
How do I get the copied configuration files to show up on the UI?
Don't copy Eclipse configuration files like that. Use the "Export" function in the old workspace and "Import" in the new one.
Use 'File > Export > Run/Debug > Launch Configurations' to export one or more launch configurations.
Use 'File > Import > Run/Debug > Launch Configurations' to import one or more launch configurations.
.metadata isn't meant for human manipulation. You can specify that a launch configuration should live in a workspace as a regular workspace file from the Common tab in most launch configurations, then just copy them across as part of the containing project.

How to Run/Debug a Ant Project in directly in tomcat through Eclipse?

In this project ....
Web.xml is located under Project Folder > web > Web-INF > web.xml
This project is already created by or clients and we are maintaining it.
Actually we do the build using the build.xml script using ant, it will generate a app.war then we will deploy it in tomcat to run.
In the above process there is no way i can debug the code.
More info:
This is not a struts project, it is Spring MVC project
Why don't you add Ant plugin to eclipe and run it through eclipse?
Help: How to run ant project in eclipse
Running Ant buildfiles
To run an Ant buildfile in the Workbench:
In one of the navigation views, select an XML file.
From the file's pop-up menu, select Run Ant.... The launch
configuration dialog
opens.
Select one or more targets from the Targets tab. The order in
which you select the items is the order in which they will run. The
order is displayed in the Target execution order box at the bottom
of the tab. You can change the order of the targets by clicking the
Order... button.
(Optional) Configure options on the other tabs. For
example, on the Main tab, type any required arguments in the
Arguments field.
Click Run.
or Check this answer
Want an eclipse java project to run ant build files automatically

how to export or copy java applet parameters on eclipse

I set a bunch of applet parameters on run/debug configurations on eclipse.
I would like to share these parameters with my co-workers, but I cannot find an easy way to copy these parameters. I looked through the plugin and project files to figure out where these parameters are stored, but I couldn't find them. Does anyone happen to know where these configurations are stored?
thanks in advance...
Launch configurations in Eclipse can be saved in the workspace in one of the projects and committed under source control. When the project is imported in Eclipse, the launch configuration will be found and automatically added in Eclipse.
To store the launch configuration in the workspace:
Run > Run Configurations... > Select the launch configuration > Common tab > Shared file
In the text field, you specify the location, where the configuration to be stored.