tags:

views:

459

answers:

3

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

A: 

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.

aperkins
+1  A: 

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:

  1. how do you generate [module-name]-1-sources.jar artifact (which plugin generate this artifact?)
  2. why do you need to generate sources but you don't need deploy them to the repository?
koppernickus
@koppernickus we keep sources in the release repo but not the snapshot repo. This might actually be a common practice in industries where versions of products need to be audited by outside entities.
sal
@sal Please consider using mvn-release-plugin (http://maven.apache.org/plugins/maven-release-plugin/) for any artifacts being released to non-snapshot repository. The process looks like follows:1. for snapshots (assuming that this is the most often case): just do "mvn clean install" -> remove source as attached artifact.2. for release (assuming this is rarely used): execute mvn release:prepare and then mvn:performAnyways - if you need slightly different ("heavier") process for releases than snapshots at leat try this plugin. In our case it works very well.
koppernickus
@koppernickus This was in response of question 2. We do use a deploy profile with the release plugin that automates the process. And yes, it is heavy. But the auditing process is _much_ heavier.
sal
We want to provide the binary jars for a third party to build, but we don't want to provide our source code.
Richard
+1  A: 

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>
Pascal Thivent
That's correct. I could remove the maven source plugin from the parent pom.xml. However, I would like to do this. I'd like to keep the maven source plugin in the parent POM. But provide a profile to disable the source plugin. This will be ideal, but not sure if it's doable. I'll give it a try.
Richard
@Richard I don't think you can "disable" a plugin in a profile so you'll have to do it the other way: put the `maven-source-plugin` declaration in a profile (activated by default for example) and remove the profile during release: `mvn -P!my-profile deploy`
Pascal Thivent