0

I have a java project done with Eclipse and Maven with this estructure folder: enter image description here

Ok, when i make a Maven install to create the .jar take this structure folder:

enter image description here

So that the hierarchy is not the same and links to the images and css do not work.

I show you the code of pom.xml

enter code here

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.wepall palle 0.4.0 com.thoughtworks.xstream xstream com.thoughtworks.xstream xstream 1.4.9 palle

        <!-- download source code in Eclipse, best practice -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>false</downloadJavadocs>
            </configuration>
        </plugin>

        <!-- Set a compiler level -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>${jdk.version}</source>
                <target>${jdk.version}</target>
            </configuration>
        </plugin>

        <!-- Maven Assembly Plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <!-- get all project dependencies -->
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <!-- MainClass in mainfest make a executable jar -->
                <archive>
                    <manifest>
                        <mainClass>com.wepall.palle.MainApp</mainClass>
                    </manifest>
                </archive>

            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <!-- bind to the packaging phase -->
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

Any ideas?

thanks a lot!! Best regards

wepall
  • 11
  • 2
  • Could you be a Little more specific??? – J. Pichardo May 24 '16 at 14:34
  • Yes, sorry, mi problem is about the herarky folder of the .jar, I explain you, – wepall May 24 '16 at 15:52
  • When I make the .jar does not make the hierarchy that has the project, the original structure of src is src\main\java\com\wepall\palle and src\main\resources and the final is that is inside the java´s folder and the resource´s folder are in the same folder, in root. When what it would have to be a java´s folder and inside a com folder (with classes), and other resources and inside the folders css, Images, lib, Projects, RobotFiles. – wepall May 24 '16 at 16:22
  • Why? because the classes that I use images and css are 5 jumps backwards (../../../../../resources/fondo.css) view-> palle-> wepall-> com-> java -> main and then resouces -> CSS-> fondo.css. – wepall May 24 '16 at 16:22

2 Answers2

0

I think that you should create a war instead of a jar, because you are talking about css and images and jars should not contains that kind of files (see jar vs war).

In maven you only need to change the <packaging> of the project inside the POM.

Marco Stramezzi
  • 2,143
  • 4
  • 17
  • 37
0

You should add a build section to your pom.xml:

<build>
        <directory>${basedir}/target</directory>
        <resources>
            <resource>
                <targetPath>${basedir}/target/resources</targetPath>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
        </resources>
</build>

Further Reference: POM Reference (Build Section)

J. Pichardo
  • 3,077
  • 21
  • 37
  • Thank you very much for the reply, with this code now the target is well constructed, but not the .jar, the resources is not inside on the .jar – wepall May 25 '16 at 06:34
  • Solved! with the same code but with: ${basedir}/target/classes/resources now the jar has the same folder´s hierarchy than the project. Thanks a lot for your help!!!! – wepall May 25 '16 at 08:49