How do I move only the current file from Eclipse and / or Ant?

I am working on a small team of web application developers. We edit JSPs in Eclipse on our own machines and then push them to a shared application server to test the changes. I have an Ant script that will take ALL JSPs on my computer and push them to the application server, but will only overwrite the JSPs if the ones on my computer are "new". This works well in most cases, but not in all cases. Our update method does not save the day / time the file was modified, so it is possible that Updating on my machine will now set the day / time of the file, not when it was last modified. If someone else worked on this file 1 hour ago (but haven't made any changes yet), then the old file on my PC will have a newer date. So when I run Ant script,it overwrites its changes in the older file.

What I'm looking for is an easy way to just move the file that I'm currently working on. Is there a way to specify the "current" file in an Ant script? Or an easy way to move the current file to Eclipse? Perhaps a good plugin for this kind of thing? I could go to Windows Explorer to move the file separately, but I'd rather do it from within Eclipse.

+1


source to share


5 answers


Add a target to the ant file to copy a single jsp using the command line property definition in @matt b description.

Create a new external tool run profile and use the "Line Substitution Settings" to pass a link to the active file in the editor ( resource_name

).



See Eclipse Help | Java Development User Guide | Links | Settings | Run / Debug | Running | Replacing a string

+1


source


How does Ant know which file was "current"? He does not know.

You can pass the filename to your Ant script (by taking advantage of the fact that any arguments you pass to Ant with -D

are automatically parameters in your script) ..

ant -Dfile = update myfile.jsp

and your script looks something like this ...



<copy file=${myfile} todir="blah"/>

      

... but it will probably hurt to keep typing the filename on the command line.

To be honest, the type of problem you described is inevitable when multiple developers are using the environment. I believe the best approach for you and your team in the long run is to have each developer work / test an instance of the local application server before the code is pushed. This removes all the headaches, bottlenecks, and scheduling issues when sharing an application server with other people.

0


source


You should use the control source every time you have a lot of people working on the same thing (well, you should use it anytime independently, but that's a different story). This way, when conflicts like this arise, the tool will know and force someone to perform the merge so that no one gets lost. The test server can then run on a clean checkout from the source, and each developer can also test the complete application locally, because all changes will be instantly available to them through the source repository.

0


source


I suggest you use control source. I prefer Subversion. You can use CruiseControl to automatically create an assembly when someone commits new code.

-1


source


The antrunner4e plugin is exactly what you are looking for - see http://sourceforge.net/projects/antrunner4e/

-1


source







All Articles