Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Dynamic Web Project set up(Workspace/project in separate dir from web content)
Dynamic Web Project set up [message #900099] Sat, 04 August 2012 00:25 Go to next message
Aaron Robinson is currently offline Aaron RobinsonFriend
Messages: 3
Registered: August 2012
Junior Member
I've inherited a few web apps that have set in stone SVN structures and the current devs are using an old Intellij version. Difficult to upgrade without cost and therefore sign off pain.

So I want to create dynamic web projects in Eclispe so that I can hot deploy to Tomact. The issue I face is telling the project to take different files from different places.

The Java is easy - I just removed the existing src folder and added a new one pointing to the Java folder on the file system.

Most of the web app content follows the J2EE web app deployment structure but some doesn't so I need a way of telling the project where to get each file set (JSP, JS) and config files (web.xml, struts.xml) and where to put them.

I can import but this brings the files in my project space - I don't want this - I want to update the files in the location they were checked out to. I can import virtually but this means that I can't then add files or remove them.

I was hoping to keep the project workspace completely independent of the checked out code, so .project, .classpath, class files etc don't end up in SVN. I know I can just point a new project at the SVN check out dir and that there are options to send the Java classes outside of the workspace but this doesn't help me with the other Eclipse files and I think I would lose the benefits of the dynamic web project woudln't I if things aren't ni the folders the project expects.

The objective is to leverage the dynamic web project functionality but keep Eclipse and the codebase completely independent.

Is this possible?
Re: Dynamic Web Project set up [message #900157 is a reply to message #900099] Sat, 04 August 2012 19:00 Go to previous messageGo to next message
Aaron Robinson is currently offline Aaron RobinsonFriend
Messages: 3
Registered: August 2012
Junior Member
** Part Solved **

Creating a new dynamic web project from existing source.

There are a number of different ways that you can tell your project about the files you want to use in your project. The usual approach is to create a new project and then start creating files. Another common way is to create an Eclipse project off the back of existing code. There are a few ways you can do this. You can tell Eclipse to use the directory the existing files are in (by deselecting the 'Use Default Location' when creating the project). Any files you create from hereonin go in there. This is typically what you'd do when creating an Eclipse project for the first time from existing code. The second option is to import files into your project (right click on the project->Import->Import->File System then just select the files you want). This copies the files you specify into your workspace so you may not want this. In the typical scenario you will have checked a project out so the last thing you want to do is copy the files somewhere else to change them. The third option is to link to folders and files. This allows you to share files between projects. When you do this, you are free to change the file contents in your project so take care. You can't create new files in these linkied folders though. No matter where you bring other files from, when you create files they will go in your workspace, nowhere else.

When creating a new dynamic web project it creates two source areas, one for the Java and one for web content. Unless you uncheck the 'Use Default Location' it will create these folders in your workspace. If you want to work with (as in add files, remove files, change the dir structure etc) existing source you need to uncheck this and specify the directory under which your Java and web content exists. Eclipse defaults the Java source directory to 'src' and the web content to 'Web Resources'. Unless you change these you'll just end up with two new directories added to your existing code base. You can change your Java src directory during project creation or after in the build path options. In the version of Eclipse I'm using you have to specify the web content directory in 'content directory' in the 'Web Module' dialog in the project creation wizard. I haven't found a way to change this after the project has been created (unless you edit Eclipse project files directly). Set these to the names of your existing Java source and web content directories. As your directories already exist nothing will happen.

The next issue you may hit is that the web content in the existing source code isn't in WAR structure. In my case the projects I inherited had top level conf, java and web directories. Conf has web.xml, struts.xml etc (which need to go in WEB-XML). The web folder had the tld files in a tld folder yet the JSPs expected to find them in the root context. So the ant file that pulled everything together did some magic. This is fine if you want to use ant to build and deploy but Eclipse offers a very cool hot deployment option to a server of your choice. Just register a server in Eclipse and then select it when you create the project. You can run your project in any target server, see the console and run a web browser from within Eclipse. This is much nicer and quicker than working with ant and a broswer independently. This is what IDEs are all about.

In order to be able to leverage this though you need to tell Eclipse how to deploy your non WAR format file structure in WAR format. You do this in the project properties->Deployment Assembly. By default it has an entry for your Java and your web content. All you do is specify where to put what. In my case I had to tell it to put the files in conf into WEB-INF and to put the tld files in root.

When you're done making changes to the deployment assembly you can see the final structure in your workspace. Shame you can't see this from the IDE: - .metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\

You can export the war at any time by right clicking on the project and exporting it.

The only things I've failed to do are keep the Eclipse .project, .setting etc files and the Java class files away from the svn working directory. It's not that big a deal but it would be nice to be able to not pollute it with files the IDE needs and of course there is always a risk they get checked in.

Anyone know how to do this?

[Updated on: Sat, 04 August 2012 19:13]

Report message to a moderator

Re: Dynamic Web Project set up [message #972598 is a reply to message #900157] Mon, 05 November 2012 19:01 Go to previous message
Simon McClenahan is currently offline Simon McClenahanFriend
Messages: 1
Registered: July 2009
Junior Member
Quote:
In order to be able to leverage this though you need to tell Eclipse how to deploy your non WAR format file structure in WAR format. You do this in the project properties->Deployment Assembly. By default it has an entry for your Java and your web content. All you do is specify where to put what. In my case I had to tell it to put the files in conf into WEB-INF and to put the tld files in root.


I don't see this Deployment Assembly configuration anywhere.

Quote:
Version: 4.2.1
Build id: M20120914-1800
Previous Topic:Problem generating Bottom Up CXF 2.x
Next Topic:How to have a tomcat server added that is already running/started outside of eclipse?
Goto Forum:
  


Current Time: Fri Apr 19 00:24:53 GMT 2024

Powered by FUDForum. Page generated in 0.01966 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top