Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven create jar file with both .class and .java files

Tags:

java

maven

gwt

I'm looking for a way to create jar files containing both .class and .java files for GWT modules. Anyone knows how that could be achieved?

like image 303
Niclas Avatar asked Nov 24 '10 07:11

Niclas


People also ask

Can I add jars to Maven 2 build classpath without installing them?

Maven install plugin has command line usage to install a jar into the local repository, POM is optional but you will have to specify the GroupId, ArtifactId, Version and Packaging (all the POM stuff). -1, sometimes you just want to add a jar file without the trouble of installing it.


1 Answers

Edit your resources section in your pom.xml.

<build>
  ...
  <resources>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>**/*.java</include>
        <include>**/*.gwt.xml</include>
      </includes>
    </resource>
  </resources>
  ...
</build>

You can also edit the maven-jar-plugin to exclude them from the final JAR.

<plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
      <!-- but be sure to exclude the source from the final jar file -->
      <excludes>
        <exclude>**/*.java</exclude>
        <exclude>**/*.gwt.xml</exclude>
      </excludes>
    </configuration>
</plugin>
like image 160
Valdis R Avatar answered Oct 07 '22 17:10

Valdis R