2

My jardesc was working great until yesterday when I converted my project to maven.

Now for some reason when I create a jar file containing code and packages: org.javacode and org.resource, I get the following folders in jar file:

org/javacode src/org/resource

It seem to work fine for java packages but for those packages that contain image resources it creates an additional src folder at the root.

How can I fix this?

Edit 1: Here is the pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Energy3D</groupId>
  <artifactId>Energy3D</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <resources>
      <resource>
        <directory>src</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
        <groupId>com.ardor3d</groupId>
        <artifactId>ardor3d-jogl</artifactId>
        <version>0.9-SNAPSHOT</version>
        <type>bundle</type>
    </dependency>
    <dependency>
        <groupId>com.ardor3d</groupId>
        <artifactId>ardor3d-lwjgl</artifactId>
        <version>0.9-SNAPSHOT</version>
        <type>bundle</type>
    </dependency>
  </dependencies>
</project>

Edit 2:

Also here is the relevant part of jardesc (the gui package is correctly placed in org/concord/energy3d/gui however the images package is mistakenly placed in src/org/concord/energy3d/resources/images when jar file is created):

<javaElement handleIdentifier="=Energy3D/src&lt;org.concord.energy3d.gui"/>
<javaElement handleIdentifier="=Energy3D/src&lt;org.concord.energy3d.resources.images"/>
4

1 に答える 1

0

You are not following the Maven conventions.

  • Your sources need to be underneath: src/main/java

  • Your resources need to be underneath: src/main/resources

  • Your test sources need to be underneath: src/test/java

  • Your test resources need to be underneath: src/test/resources

Maven's first rule is convention over configuration. You are focusing on the configuration bit, instead of following the convention. If you don't follow the convention, the plugins will not find things where they expect them. This will lead to them not doing what you want, so I recommend you address this properly.

Also, remove this part from your pom.xml:

<sourceDirectory>src</sourceDirectory>
<resources>
  <resource>
    <directory>src</directory>
    <excludes>
      <exclude>**/*.java</exclude>
    </excludes>
  </resource>
</resources>
于 2013-03-04T11:27:45.457 に答える