tastle
tastle

Reputation: 83

Redirecting the nexus-staging-maven-plugin to an internal repository

I have a webjars project that I'd like to build snapshots and have them deployed locally (within our infrastructure) but have the releases be managed by webjars.org.

https://github.com/webjars/oscar/blob/15.0.0-RC1/pom.xml

The problem I'm facing is that they need the nexus-staging-maven-plugin defined as part of their release process. So I'd like to keep the POM tailored for them as much as possible, and just make our own deviations via command line (or worst case, profile) if possible.

Typically, if doing this from scratch, you'd probably introduce the staging plugin in a profile, but I don't think I have that option. (I might have to make the modification though and discuss it with them.)

I've never used the staging plugin before, so this is my first exposure and it isn't a pleasant one given what I'm trying to do. I feel like I'm fighting the system.

I thought I had something by specifying:

-DsonatypeOssDistMgmtSnapshotsUrl=http://myurl

and that pushes the artifact at the correct location, but then I can't figure out how to supply credentials. (401 unauthorized) I thought specifying the serverId might work, but no.

-DserverId=public-snapshots

http://books.sonatype.com/nexus-book/reference/staging-deployment.html

I then tried creating a profile, where I'd do something like this:

<profile>
    <id>disable-staging</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.5</version>
                <configuration combine.self="override">
                    <executions>
                        <execution>
                            <id>injected-nexus-deploy</id>
                            <phase>none</phase>
                        </execution>
                    </executions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

but that doesn't help. The effective-pom shows this:

<plugin>
  <groupId>org.sonatype.plugins</groupId>
  <artifactId>nexus-staging-maven-plugin</artifactId>
  <version>1.6.5</version>
  <extensions>true</extensions>
  <executions>
    <execution>
      <id>injected-nexus-deploy</id>
      <phase>deploy</phase>
      <goals>
        <goal>deploy</goal>
      </goals>
      <configuration combine.self="override">
        <executions>
          <execution>
            <id>injected-nexus-deploy</id>
            <phase>none</phase>
          </execution>
        </executions>
      </configuration>
    </execution>
  </executions>
  <configuration combine.self="override">
    <executions>
      <execution>
        <id>injected-nexus-deploy</id>
        <phase>none</phase>
      </execution>
    </executions>
  </configuration>
</plugin>

and I can't unbind the deploy phase.

I'm wondering if anyone has any ideas on what to do in this type of scenario?

Upvotes: 3

Views: 1540

Answers (1)

Florian Albrecht
Florian Albrecht

Reputation: 2324

You can use the Nexus Staging Plugin's property skipNexusStagingDeployMojo to achieve this:

mvn clean package deploy:deploy -DskipNexusStagingDeployMojo=true 
-DaltDeploymentRepository=snapshots::default::https://my.nexus.host/content/repositories/snapshots-local

It is important to explicitly invoke package and then deploy:deploy, as otherwise (when only invoking mvn deploy) the default execution of the maven-deploy-plugin is suppressed by the Nexus Staging Plugin (even with the skip set to true).

Upvotes: 6

Related Questions