7

We have project with lot of precanned test files, so obviously the test-jar file is very big. Since no one uses test jar(at least in out project), we don't gain any benefit by uploading it.

When we run the maven deploy command, I want it to only upload the project jar file and not the test jar file. Is there a way to achieve that?

Ravi
  • 1,082
  • 4
  • 15
  • 24
  • It seems to me that by default my test classes are not bundled into test-jar. Do you have a specific configuration? – YMomb Nov 24 '11 at 05:50
  • FYI close question to not deploy "-sources.jar" see [here](http://stackoverflow.com/questions/2580969/how-do-i-exclude-the-sources-jar-in-mvn-deploy) – boly38 Jul 31 '15 at 08:34

2 Answers2

7

Actually the test jar files do not get built by default. It is likely that you are building them explicitly using attached tests. If so, you can remove that config from your project and you should be good to go.

Look for a section like the following and you can remove the same.

 <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-jar-plugin</artifactId>
   <version>2.2</version>
   <executions>
     <execution>
       <goals>
         <goal>test-jar</goal>
       </goals>
     </execution>
   </executions>
 </plugin>

Tests will continue to run on your project without the above.

declension
  • 4,110
  • 22
  • 25
Raghuram
  • 51,854
  • 11
  • 110
  • 122
0

Placing your test files in src\test\java should have the desired results. See Maven directory layout for the convention. You will derive the most benefit from using Maven if you follow such a project organization. Most plugins assume that you have structured your project files in this manner.

Sri Sankaran
  • 8,120
  • 4
  • 38
  • 47
  • We do follow this structure, we have all our test files in src\test\resources\.... That's how they become part of the test-jar. – Ravi Nov 23 '11 at 17:22