Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to compile to other directory besides workspace?
How to compile to other directory besides workspace? [message #290203] Fri, 19 August 2005 18:10 Go to next message
Eclipse UserFriend
Originally posted by: root.aol.com

Just learning eclipse.

I want to be able to compile to both my workspace classes dir, and my
tomcat/webapps/web/web-inf/classes directory.

Is this possiable?

TIA
Re: How to compile to other directory besides workspace? [message #290210 is a reply to message #290203] Fri, 19 August 2005 21:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

There's no 'workspace' classes dir. There's only the build folder associated with a project. Each project has its own build directory/ies.

You don't just have to have one directory though; you can set up individual folders for specific source folders. So if you wanted to create a web/web-inf/classes directlory, you could do.

The folder still needs to be installed relative to the project (as opposed to an absolute path) -- however, it is possible to create virtual 'symlinks' to other external paths in your directory; they're called 'linked folders'.

See http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.user/reference/ref-14b.htm for more infor about linked folders.

What you can't do is compile one source folder to two identical build folders, which sounds like what you are trying to do. However, you can easily put together an Ant build file that copies the project classes folder to an external location. You can even hook up the ant build file so that it's run whenever the project is rebuilt, but ideally, you'd only want to do it when you want to install new changes.
Re: How to compile to other directory besides workspace? [message #290212 is a reply to message #290210] Fri, 19 August 2005 21:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: root.aol.com

> See
> http://help.eclipse.org/help31/index.jsp?topic=/org.eclipse. platform.doc.user/reference/ref-14b.htm
> for more infor about linked folders.
>
> What you can't do is compile one source folder to two identical build
> folders, which sounds like what you are trying to do. However, you can
> easily put together an Ant build file that copies the project classes
> folder to an external location. You can even hook up the ant build file so
> that it's run whenever the project is rebuilt, but ideally, you'd only
> want to do it when you want to install new changes.


No all I want to do is this..

Take C:\workspace\project1\src\
build it to
C:\workspace\project1\classes\
and
C:\Tomcat\webapp\project1\WEB-INF\classes\

Not the same folder at all.

I created a new "linked resource" that is a directory. How do I make it
build to this directory? In the Java Build Path all I see is "default output
folder", browse only takes me to the workspace directory.
Re: How to compile to other directory besides workspace? [message #290217 is a reply to message #290212] Sat, 20 August 2005 09:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

> > What you can't do is compile one source folder to
> two identical build
> > folders, which sounds like what you are trying to
> do.
>
> No all I want to do is this..
>
> Take C:\workspace\project1\src\
> build it to
> C:\workspace\project1\classes\
> and
> C:\Tomcat\webapp\project1\WEB-INF\classes\

So the contents of c:\workspace\project1\classes are copied verbatim into c:\Tomcat\webapp\project1\WEB-INF\classes\ ? Or do you want some classes to go into one build location and others to go into another?

There can only be one build location for a source folder in Eclipse. Thus, it is not possible to have 'src\A.java' building into both 'classes\A.class' and 'other\A.class' using Eclipse out-of-the box. What you can do is one of the following:

o Make the build folder `other\A.class'. It's not necessary to have stuff build into a folder called 'classes' in Eclipse; that's just the default name out of the box.

o Create a resource link, so that 'classes' is (in effect) a link/shortcut to 'other'. That way, it will appear that you have 2 directories with the same contents, although there will actually only be 1 directory

o Run a post-processor to copy the files from 'classes' to 'other' after a project build has been done. The easiest way would probably be to write an Ant script to copy the files, probably using the 'copy' task. http://ant.apache.org/manual/CoreTasks/copy.html Furthermore, since Ant is built-in to Eclipse, you can easily run this from within Eclipse. And if you get really into it, you can hook up the Ant build file with an Eclipse Builder so that it happens automatically on a full build.

You need to decide which one of these approaches works best for you. My suggestion would be to get rid of your project's classes directory, and set it up as a resource link to the tomcat directory instead; that way, they get compiled right into your Tomcat area.
Re: How to compile to other directory besides workspace? [message #290317 is a reply to message #290217] Tue, 23 August 2005 14:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: root.aol.com

"Alex Blewitt" <automatic@javalobby.org> wrote in message
news:12701147.1124531092817.JavaMail.root@cp1.javalobby.org...
>> > What you can't do is compile one source folder to
>> two identical build
>> > folders, which sounds like what you are trying to
>> do.
>>
>> No all I want to do is this..
>>
>> Take C:\workspace\project1\src\
>> build it to
>> C:\workspace\project1\classes\
>> and
>> C:\Tomcat\webapp\project1\WEB-INF\classes\
>
> So the contents of c:\workspace\project1\classes are copied verbatim into
> c:\Tomcat\webapp\project1\WEB-INF\classes\ ? Or do you want some classes
> to go into one build location and others to go into another?
>
> There can only be one build location for a source folder in Eclipse. Thus,
> it is not possible to have 'src\A.java' building into both
> 'classes\A.class' and 'other\A.class' using Eclipse out-of-the box. What
> you can do is one of the following:
>
> o Make the build folder `other\A.class'. It's not necessary to have stuff
> build into a folder called 'classes' in Eclipse; that's just the default
> name out of the box.
>
> o Create a resource link, so that 'classes' is (in effect) a link/shortcut
> to 'other'. That way, it will appear that you have 2 directories with the
> same contents, although there will actually only be 1 directory
>
> o Run a post-processor to copy the files from 'classes' to 'other' after a
> project build has been done. The easiest way would probably be to write an
> Ant script to copy the files, probably using the 'copy' task.
> http://ant.apache.org/manual/CoreTasks/copy.html Furthermore, since Ant is
> built-in to Eclipse, you can easily run this from within Eclipse. And if
> you get really into it, you can hook up the Ant build file with an Eclipse
> Builder so that it happens automatically on a full build.
>
> You need to decide which one of these approaches works best for you. My
> suggestion would be to get rid of your project's classes directory, and
> set it up as a resource link to the tomcat directory instead; that way,
> they get compiled right into your Tomcat area.


Ok I am fine with the last, but I couldn't figure out how to make a resource
link a build target? Any help?
Re: How to compile to other directory besides workspace? [message #290333 is a reply to message #290317] Wed, 24 August 2005 04:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse3.rizzoweb.com

Scott Phelps wrote:
> "Alex Blewitt" <automatic@javalobby.org> wrote in message
>>You need to decide which one of these approaches works best for you. My
>>suggestion would be to get rid of your project's classes directory, and
>>set it up as a resource link to the tomcat directory instead; that way,
>>they get compiled right into your Tomcat area.
>
> Ok I am fine with the last, but I couldn't figure out how to make a resource
> link a build target? Any help?

Where you specify the Java Build Path you define what the build output
directory is. Use the linked folder as the build output location.

HTH,
Eric
Re: How to compile to other directory besides workspace? [message #290341 is a reply to message #290317] Wed, 24 August 2005 10:37 Go to previous message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

> > My
> > suggestion would be to get rid of your project's
> > classes directory, and set it up as a resource
> > link to the tomcat directory instead; that way,
> > they get compiled right into your Tomcat area.
>
> Ok I am fine with the last, but I couldn't figure out
> how to make a resource
> link a build target? Any help?

In your Java project, change the default output folder to something else initially. (Project -> Properties -> Java Build Path -> Default Output Folder). So instead of "MyProject/classes" it could be "MyProject/orange".

Then create a new Folder (File -> New -> Other -> Simple -> Folder) called 'classes', in your project. Instead of clicking 'Finish' straight away, click on the 'Advanced' tab, and select the checkbox 'Link to folder in the file system'. Then put the full path of where you want it to be linked to, such as 'C:\Tomcat\webapp\project1\WEB-INF\classes\'

Once that's created (you'll see the folder in there, with a link icon, and should be able to browse the contents) you can change the default build folder back to 'MyProject/classes' again.
Previous Topic:XMLRootElementContentDescriber with schema
Next Topic:Debuging in Eclipse 3.1
Goto Forum:
  


Current Time: Thu Apr 25 23:01:10 GMT 2024

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

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

Back to the top