Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:01:47+00:00 2026-05-25T10:01:47+00:00

short: I need to filter all .java files and every META-INF folder from a

  • 0

short: I need to filter all .java files and every META-INF folder from a set of jars and package the class files and resources from that jars into one single jar.
I currently use the maven-assembly-plugin, but would try something else as long as it can easily be integrated into a maven build process.

long: I use maven to manage different stages of development for my tool. basic stage is freeware, second has some more features, third stage is all features)

That works fine so far, I use profiles to add the different source directories to the classpath and the sources are neatly compiled into the project.jar.

  • First problem: The .java sources included into the project via the profiles end up in the project.jar.

Then I use the maven-assembly-plugin to construct a final.jar that also contains the dependencies and in the end use launch4j to produce an executable for windows (the current target platform).

  • Second problem: The various META-INF parts from the dependency jars mix in the final.jar and I would want them all to be skipped.

I have searched for examples of the assembly.xml using the <exclude> tag, but did not find any that used my combination of dependencySet and <exclude>*.java</exclude>. I’m not even positive that I can do that.

Here is my assembly.xml:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
    <id>jar-with-dependencies</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <dependencySets>
        <dependencySet>
            <outputDirectory>/</outputDirectory>
            <useProjectArtifact>true</useProjectArtifact>
            <unpack>true</unpack>
            <scope>runtime</scope>
            <useDefaultExcludes>true</useDefaultExcludes>
            <!--<useTransitiveFiltering>true</useTransitiveFiltering>-->
            <!--<useStrictFiltering>true</useStrictFiltering>-->
            <excludes>
                <exclude>META-INF</exclude>
                <exclude>**/*.java</exclude>
                <exclude>*.java</exclude>
                <exclude>*:sources</exclude>
            </excludes>
        </dependencySet>
    </dependencySets>
</assembly>

My research so far:

I have googled with example assembly.xml exclude java but could not find examples that covered my problem. (I have also googled a lot the past days but did not save all I found)
I have read http://maven.apache.org/plugins/maven-assembly-plugin/advanced-descriptor-topics.html but could not apply that knowledge to my problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:01:48+00:00Added an answer on May 25, 2026 at 10:01 am

    Okay, so I figured it out for me.

    first: to filter out java and other source files from source parts that were included using profiles I use:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>de.steamnet.oneClickWonder.awt.OCWController</mainClass>
                        </manifest>
                    </archive>
                    <excludes>
                        <exclude>**/*.java</exclude>
                        <exclude>**/*.form</exclude>
                    </excludes>
                </configuration>
            </plugin>
    

    The task of filtering the META-INF from the dependencies has gone away when I started using an installer so now I can just deliver mulitple jars with their own META-INF.

    So, as Michael-O stated this approach (using profiles to include additional source parts) may not be the correct one to do but it is very handy and I stick to it. With the excludes tag from the jar plugin the troubles with source files being added to the final jar also goes away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a short code snippet to get a directory listing from an HTTP
I have a linux filter to extract all lines from an xcode project that
I need to find all short PHP tags. The regex for it <\?(?!php) but
So, long story short, I need to use another Java compiler than what came
I have an array of shorts (short[]) that I need to write out to
So I have an app which plays many short sound clips. I need to
I have a homework assignment where I need to take input from a file
I'm building a website in django that needs to extract key words from short
Long story short, I need to sort an array of objects using usort, and
I need to filter or sort the warnings in problems,Tasks view based on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.