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
[modu
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>
Let me assume that you shoudn't skip generating sources for a module. In that case, this would be a simple solution which helps you to handle this scenario :
In the execution part of "maven-source-plugin" under plugins section, set the attach attribute to false. This configuration will generate the sources.jar for your module, but not attached it to the project's artifact list.
The example snippet is here:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${source.plugin.version}</version>
<executions>
<execution>
<id>module1-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
<configuration>
<!-- The below specified attribute 'attach' will disable the sources.jar not included in the artifact list -->
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Deploy plugin maven site:
http://maven.apache.org/plugins/maven-deploy-plugin/index.html
Based on what I am reading there, it looks like you can exclude modules from deployment, but not individual files - at least not yet.
If you look at the goals page:
http://maven.apache.org/plugins/maven-deploy-plugin/plugin-info.html
it does not show any specific configurations of the plugin for what you are looking for. As the goals page is made from the plugin class, by looking at the annotations, I would say that they do not have the ability.
One thing you could do would be to make a different build that does not create the jars you don't want created - i.e. make a different assembly package or the like for that build, and have the build be run when you are trying to deploy specific packages.
Edit: koppernickus has a full description of this, I would recommend you see his post.
Is there any way to exclude [module-name]-1-sources.jar from the deployment process?
Don't generate sources if you don't want to deploy them. So either remove the following (that you must have in your POM) or put it in a profile that you don't use or exclude during release (I wonder when you use sources in that case):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Maven mvn deploy:deploy
deploys all produced artifacts during maven process (default lifecycle). To not deploy [module-name]-1-sources.jar
you should simply(?) not produce one. If you are using maven-source-plugin
to attach source files just don't use it anymore.
If this is not the case you are experiencing please provide more details:
[module-name]-1-sources.jar
artifact (which plugin generate this artifact?)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)