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 6067809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:38:54+00:00 2026-05-23T09:38:54+00:00

In my Maven project there is one module (core) that has a few resources

  • 0

In my Maven project there is one module (core) that has a few resources for its classes. When running classes inside the module its able to get its own resources. Everything works fine.

Where stuff breaks is when another module which depends on the core tries to run that class. The folder that Java is looking for resources in is this module, not the core module. So the class fails.

In short: How can I access the resources of a dependency?


I’ve experimented with trying to do this by declaring in Core’s JAR Manifest Class-Path: .. However when listing the resources available with JSHookLoader.class.getClassLoader().getResources(""); (JSHookLoader is in Core if it means anything), I get:

Resource: W:\programming\quackbot-hg\impl\target\classes
File rebel.xml

Resource: W:\programming\maven-repo\org\quackbot\core\3.5-SNAPSHOT
File core-3.5-SNAPSHOT.jar
File core-3.5-SNAPSHOT.pom
File maven-metadata-local.xml
File _maven.repositories

This of course complicates things as I expected the JAR itself to be in the Classpath, not the directory the JAR is in

Any suggestions?


Coming back to this project I still have this issue. Other guides have talked about using maven-assembly-plugin and the remote resources plugin, but thats a lot of pain as all modules have to include the monster plugin XML.

Why don’t I simplify the question to this: How can I add a dependencies JAR to the resource list?

  1. core.jar has some resources in it under the folder /resources. Running core.jar I can see /resources in the resource list.
  2. impl.jar depends on core.jar. Upon running it though /resources isn’t in the resource list and therefore causes havoc.

This should be simple enough, but how can I do it? I’ve spend hours trying to figure out a simple clean way to do it but to no avail.

  • 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-23T09:38:55+00:00Added an answer on May 23, 2026 at 9:38 am

    After lots of searching I finally stumbled upon a solution.

    My solution takes the core module and unpacks it with the Maven Dependency Plugin, making sure to exclude the META-INF folder and the org folder which is where the compiled classes are. The reason I’m excluding what I don’t want instead of explicitly stating what I do want is so new resources can be added easily without me having to update my POM all the time.

    The reason I’m not using the assembly plugin or the remote resources plugin is because they use dedicated resource modules. I don’t think I should have to make a core module and a core-resources module, with the core-resources module only containing logback and hibernate configuration files + some other stuff.

    Here is a copy of what I’m using to do this

        <build>
            <plugins>
                <!--Extract core's resources-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.2</version>
                    <executions>
                        <execution>
                            <id>unpack</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>unpack-dependencies</goal>
                            </goals>
                            <configuration>
                                <includeGroupIds>${project.groupId}</includeGroupIds>
                                <includeArtifactIds>core</includeArtifactIds>
                                <excludeTransitive>true</excludeTransitive>
                                <overWrite>true</overWrite>
                                <outputDirectory>${project.build.directory}/core-resources</outputDirectory>
                                <excludes>org/**,META-INF/**,rebel.xml</excludes>
                                <overWriteReleases>true</overWriteReleases>
                                <overWriteSnapshots>true</overWriteSnapshots>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            <!--New resource locations-->
            <resources>
                <resource>
                    <filtering>false</filtering>
                    <directory>${project.build.directory}/core-resources</directory>
                </resource>
                <resource>
                    <filtering>false</filtering>
                    <directory>${basedir}/src/main/resources</directory>
                </resource>
            </resources>
        </build> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a multi-module Maven-3 project, where one of sub-modules is used as <dependency>
I have a maven project that has a set of library dependancies that are
We have a multi-module maven project that uses a profile that defines a buildnumber-maven-plugin
I have a maven project that has both code and documentation (pdf files). When
I have a Maven project that was built a few years back, and now
Imagine a multi-modules Maven project, such as the following one: parent +- core +-
I have a multi-module maven project. In every module there are unit tests. When
I have a maven multi-module project. In one module, we create 2 ZIP files
I have a Maven project with JavaScript code. There is a special javascript compiler
I have a maven project that was generated by Spring Roo. Now I am

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.