Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exclude the sources jar in mvn deploy?

When I run "mvn deploy:deploy", maven deploys 4 jar files to my internal remote repository.

They are:

[module-name]-1.jar
[module-name]-1.pom
[module-name]-1-sources.jar
[module-name]-1-tests.jar

There are actually more files, such as md5 and sha1 files, being deployed. But for simplicity, I just skip these files here.

Is there any way to exclude [module-name]-1-sources.jar from the deployment process?

One way I can think of is to use "mvn deploy:deploy-file", which allows me to pinpoint which jar to deploy. But since I have a few dozen modules to deploy, it'll be nice if I can configure the deployment file exclusion in pom.xml. Otherwise, I'll have to write a script to deploy.

Thanks,
Richard

like image 473
Richard Avatar asked Apr 05 '10 20:04

Richard


People also ask

What is Maven sources jar?

The “maven-source” plugin is used to pack your source code and deploy along with your project. This is extremely useful, for developers who use your deployed project and also want to attach your source code for debugging.

What is the difference between mvn install and mvn deploy?

mvn:install copies your packaged Maven module to your local repository (by default, in ~/. m2/repository ), to be accessed by other local Maven builds. mvn:deploy uploads your packaged Maven module to another (usually remote) repository, to be accessed by other, not necessarily local, Maven builds.

What is the use of mvn deploy command in Maven?

mvn deploy This command is used to deploy the artifact to the remote repository. The remote repository should be configured properly in the project pom. xml file distributionManagement tag. The server entries in the maven settings.

What happens on mvn deploy?

deploy:deploy is used to automatically install the artifact, its pom and the attached artifacts produced by a particular project. Most if not all of the information related to the deployment is stored in the project's pom. deploy:deploy-file is used to install a single artifact along with its pom.


2 Answers

As of version 2.2 of the maven-source-plugin you can skip source generation with a config option without having to put the plugin in a profile in your parent pom:

  <!-- Do not generate a source jar -->
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>2.2.1</version>
    <configuration>
      <skipSource>true</skipSource>
    </configuration>
  </plugin>
like image 82
Matt F Avatar answered Sep 19 '22 11:09

Matt F


If you don't want modify your POM, you can skip sources jar creation by adding an enviroment variable to command line:

-Dsource.skip (for maven-source-plugin up to version 2.4, see 2.4 doc)

or

-Dmaven.source.skip (for maven-source-plugin version 3.0.0+, see 3.0.1 doc or the latest one)

like image 38
Pino Avatar answered Sep 21 '22 11:09

Pino