Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Excluded files from build path get exported to jar(When creating jar file with the Export to runnable jar file wizard, the excluded files are placed in a "src" directory inside the jar)
Excluded files from build path get exported to jar [message #540937] Thu, 17 June 2010 12:51 Go to next message
Ely Schoenfeld is currently offline Ely Schoenfeld
Messages: 4
Registered: June 2010
Junior Member
Hello all.

I've been searching the web (eclipse bugs and forums) but haven't been able to find a solution.

In my souce tree I have some files that I use to generate some java classes during development. I don't want these files to get into the jar file.

Normally, those files get copied into to the "bin" directory tree everytime the project gets built.

I found a way to prevent this by adding some exclusion patterns:
Quote:
...go to the project->Properties->Java Build Path. Select Source tab, expand the source folder, you will see (Exclusion filters), click on it and then the "Edit" button.


Now, imagine I have a folder with some source files

src/com/mitalteli/cfd/extracted/
    somethinig.bat
    class1.java
    class2.java


If I don't put any exclusions, and run the "Export to runnable jar file wizard", the generated jar contets are:

com
    |->mitalteli
        |->cfd
            |->extracted
                something.bat
                class1.class
                class2.class
META-INF
    |->MANIFEST.MF


Ofcourse I don't want the "something.bat" there.

So I added the following exclusions:
**/*.bat
**/*.swp
**/*.xjb


Now, when I export it again, the jar contets are:

com
    |->mitalteli
        |->cfd
            |->extracted
                class1.class
                class2.class
META-INF
    |->MANIFEST.MF
src
    |->com
        |->mitalteli
            |->cfd
                |->extracted
                    something.bat


It's very wierd. As you can see, the "excluded" file is taken off the main file structure, but is then placed in a "src" direcotry.

Is this a bug? I mean. If some files are excluded from the build path, they shouldn't be added to the jar file. Am I right?

Does anybody has any pointers in order to fix this?

Any help would be very appreciated.

Ely.

[Updated on: Thu, 17 June 2010 12:54]

Report message to a moderator

Re: Excluded files from build path get exported to jar [message #541129 is a reply to message #540937] Fri, 18 June 2010 08:42 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6850
Registered: July 2009
Location: Ottawa
Senior Member

My guess is that's deliberate, if you are generating source. What if
you don't generate source into your jar?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Excluded files from build path get exported to jar [message #541174 is a reply to message #540937] Fri, 18 June 2010 10:30 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
Ely wrote:
> Hello all.
>
> I've been searching the web (eclipse bugs and forums) but haven't been
> able to find a solution.
>
> In my souce tree I have some files that I use to generate some java
> classes during development. I don't want these files to get into the
> jar file.
>
> Normally, those files get copied into to the "bin" directory tree
> everytime the project gets built.
>
> I found a way to prevent this by adding some exclusion patterns:
> Quote:
>> ...go to the project->Properties->Java Build Path. Select Source tab,
>> expand the source folder, you will see (Exclusion filters), click on
>> it and then the "Edit" button.
>
>
> Now, imagine I have a folder with some source files
>
> src/com/mitalteli/cfd/extracted/
> somethinig.bat
> class1.java
> class2.java
>
> If I don't put any exclusions, and run the "Export to runnable jar
> file wizard", the generated jar contets are:
>
> com
> |->mitalteli
> |->cfd
> |->extracted
> something.bat
> class1.class
> class2.class
> META-INF
> |->MANIFEST.MF
>
> Ofcourse I don't want the "something.bat" there.
> So I added this:
> **/*.bat
> **/*.swp
> **/*.xjb
>
> Now, when I add the exclusions and export it again, the jar contets are:
>
> com
> |->mitalteli
> |->cfd
> |->extracted
> class1.class
> class2.class
> META-INF
> |->MANIFEST.MF
> src
> |->com
> |->mitalteli
> |->cfd
> |->extracted
> something.bat
>
> It's very wierd. As you can see, the "excluded" file is taken off the
> main file structure, but is then placed in a "src" direcotry.
>
> Is this a bug? I mean. If some files are excluded from the build path,
> they shouldn't be added to the jar file. Am I right?
No, you are wrong. Build path means it's used to to execute but
'something.bat' might be a simple file that's read by your code. The
exporter cannot have any clue about this. If you want to control this
then you'd better use the 'JAR file' exporter where you can select the
individual resources.

Dani
>
> Does anybody has any pointers in order to fix this?
>
> Any help would be very appreciated.
>
> Ely.
Re: Excluded files from build path get exported to jar [message #541509 is a reply to message #541129] Mon, 21 June 2010 08:30 Go to previous messageGo to next message
Ely Schoenfeld is currently offline Ely Schoenfeld
Messages: 4
Registered: June 2010
Junior Member
Quote:
My guess is that's deliberate, if you are generating source. What if
you don't generate source into your jar?

PW

--
Paul Webster


Thank you for answering Paul.

Well... There is no "src" directory unles I add the exclusion rules. I was searching for an option to disable source inclusion in the jar, but couldn't find it.

Do you happen to know where is it if it exists?

Thanks in advance.

Ely.

EDIT: I've just found the eclipse 3.1 has a checkbox for including the source in the jar. Bit I'm Using the Eclipse IDE for Java EE Developers version 1.2.1 and that's why it doesn't have one. (I guess)

[Updated on: Mon, 21 June 2010 09:28]

Report message to a moderator

Re: Excluded files from build path get exported to jar [message #541514 is a reply to message #541174] Mon, 21 June 2010 08:41 Go to previous message
Ely Schoenfeld is currently offline Ely Schoenfeld
Messages: 4
Registered: June 2010
Junior Member
Hello Dani.

Thank you for taking the time to answering my questions.

Quote:
> Is this a bug? I mean. If some files are excluded from the build path,
> they shouldn't be added to the jar file. Am I right?
No, you are wrong. Build path means it's used to to execute but
'something.bat' might be a simple file that's read by your code. The
exporter cannot have any clue about this. If you want to control this
then you'd better use the 'JAR file' exporter where you can select the
individual resources.

Dani


Hmmm....

I'm not sure I agree. I don't understand why you say the "build" path has any thing to do with the application execution.

As far as I can tell, the "build path" is used to find all the resources needed to complile-link-pack a project wen converting it to executable. Isn't it right? Not the execution itself.

For instance, if you see the eclipse's help, you will find:

Java Build Path
The options in this page indicate the build path settings for a Java project. 
...
The build class path is a list of paths visible to the compiler when building the project.


That's exactly why I was thinking that if I make an exclusion there, those files shouldn't be added to the final jar, as they shouldn't be used when building it.

If there is no other way, I'll find a way to build my jar manually. But I hope there is a better way.

Any other ideas?

Ely.

EDIT: No, I wasn't entirely right. You are right when you say that those files could be used by the application while running, and that's why the jar creation couldn't know if it had to include them or not.
But I still don't know why it creates a src directory when those files are excluded from the building process.

[Updated on: Mon, 21 June 2010 09:00]

Report message to a moderator

Previous Topic:change locale at runtime
Next Topic:ActionDelegateHandlerProxy and isEnabled
Goto Forum:
  


Current Time: Wed Apr 16 18:58:51 EDT 2014

Powered by FUDForum. Page generated in 0.01586 seconds