473,416 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Related to adding java source to test jar in Maven

I couldnt get a forum here which catered to Maven, so am putting it here.

Using my pom.xml i was able to generate the jar for src/main/java (say app.jar) as well as for src/test/java (say app-test.jar). I was also able to include my java sources as part of the app.jar (i.e. have both my .class as well as my .java files in the jar).

However for my app-test.jar, i'm not able to include my .class files in it.

This is my pom.xml:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4.   <modelVersion>4.0.0</modelVersion>
  5.  
  6.   <groupId>com.mycompany.app</groupId>
  7.   <artifactId>my-app</artifactId>
  8.   <version>1.0-SNAPSHOT</version>
  9.   <packaging>jar</packaging>
  10.  
  11.   <name>my-app</name>
  12.   <url>http://maven.apache.org</url>
  13.  
  14.   <properties>
  15.     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  16.   </properties>
  17.  
  18.   <dependencies>
  19.     <dependency>
  20.       <groupId>junit</groupId>
  21.       <artifactId>junit</artifactId>
  22.       <version>3.8.1</version>
  23.       <scope>test</scope>
  24.     </dependency>
  25.   </dependencies>
  26.  
  27.   <build>
  28.     <resources>
  29.       <resource>
  30.         <directory>src/main/java</directory>
  31.       </resource>      
  32.     </resources>
  33.     <plugins>
  34.      <plugin>
  35.        <groupId>org.apache.maven.plugins</groupId>
  36.        <artifactId>maven-jar-plugin</artifactId>
  37.        <version>2.3.1</version>
  38.        <executions>
  39.          <execution>
  40.            <phase>package</phase> 
  41.            <goals>             
  42.              <goal>test-jar</goal>
  43.            </goals>
  44.            <configuration>
  45.             <includes>
  46.                 <include>src/test/java</include>
  47.             </includes>
  48.            </configuration>
  49.          </execution>
  50.        </executions>
  51.      </plugin>
  52.     </plugins>
  53.   </build>
  54.  
  55. </project>
  56.  
Any help would be appreciated.

Thanks.
May 26 '10 #1
0 2125

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jimbo | last post by:
wasn't sure i should put this here or in comp.lang.java.misc (or even comp.lang.misc) but I was wondering what is the consensus for line length for java code? i always thought 80 chars/line was...
0
by: news.dsl.pipex.com | last post by:
Greetings, I'm trying to find out how in the source you set the version/vendor/title information so that it can be read at runtime. All I've found is mention of ClassLoader in relation to...
9
by: FISH | last post by:
Ever have one of those days when you're not sure if it's you who's gone mad, or the rest of the world? I have an Open Source project on SourceForge for communication with YSMG - Yahoo's IM...
1
by: Peter Verdon | last post by:
For the last two years, I've been using Eclipse as my Java IDE, and I'm very happy with it. I've just switched from Linux to Mac, and while Eclipse itself works even better, I have a problem with...
2
by: Edward Berard | last post by:
I am looking for tools that will analyze Java source code: -> I am primarily looking for metrics tools, e.g., tools that will tell me things like - Total lines of code - Total blank lines...
0
by: Petterson Mikael | last post by:
Hi, I am using Solaris 8 and JDK1.4.1 I will generate java source files from XML. I am thinking of using JAXB package. As input I have my XML and DTD. I setup "Java Web Services Developer Pack...
2
Saghar
by: Saghar | last post by:
Hi, Could somebody help me about this topic? I want to know how we can call and execute a non-java source file in a java application. For example, a simple Java application is run, there is an...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
1
by: cwj | last post by:
Can anybody tell me some tools that can transfer java source code to cpp source code?
1
by: sreekandan | last post by:
I need Java source code to implement SMTP client side program...So kindly send me the source code for that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.