chonton / exists-maven-plugin

Check if artifact exists in remote maven repository
Apache License 2.0
47 stars 18 forks source link

Not working if running mvn clean install #10

Closed Jaime97 closed 6 years ago

Jaime97 commented 6 years ago

If you run "mvn clean install" instead of just the install it will upload to the remote, no matters if the name is the same (nor the version or the version name). Any workaround?

chonton commented 6 years ago

I will need a pom that demonstrates this behavior in order to diagnose the problem.

Jaime97 commented 6 years ago

Well the POM belongs to a private project but I'll try to add it the best I can. Be aware that's not exactly the same. I do not think this POM has anything special:

`<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

4.0.0
<groupId>com.company</groupId>
<artifactId>myproject</artifactId>
<version>1.3.6</version>
<packaging>jar</packaging>
<name>Myproject</name>

<dependencies>
</dependencies>

<build>
    <sourceDirectory>src/main/java</sourceDirectory>

    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <projectNameTemplate>MobbLicense-Java</projectNameTemplate>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>
        <plugin>
    <groupId>org.honton.chas</groupId>
    <artifactId>exists-maven-plugin</artifactId>
    <version>0.0.6</version>
    <executions>
      <execution>
        <goals>
          <goal>remote</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
    </plugins>
</build>

<distributionManagement>
    <repository>
        <id>releases</id>
        <name>Releases</name>
        <url>http://myNexus/nexus/content/repositories/releases/</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Snapshots</name>
        <url>http://myNexus/nexus/content/repositories/snapshots/</url>
    </snapshotRepository>
</distributionManagement>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

`

chonton commented 6 years ago

I see no concerns with the attached pom. Are you sure the build is attempting to upload to remote? -- the deploy plugin is attached by default to the deploy phase, which will not be run with 'mvn clean install'

Please run with the -X flag and capture the output. You should see something like the following:

[DEBUG] Configuring mojo org.honton.chas:exists-maven-plugin:0.0.6:remote from plugin realm ClassRealm[plugin>org.honton.chas:exists-maven-plugin:0.0.6, parent: sun.misc.Launcher$AppClassLoader@55f96302]
[DEBUG] Configuring mojo 'org.honton.chas:exists-maven-plugin:0.0.6:remote' with basic configurator -->
[DEBUG]   (f) artifact = exists-deploy-it-0.0.6.jar
[DEBUG]   (f) mavenProject = MavenProject: org.honton.chas:exists-deploy-it:0.0.6 @ /Users/chas/exists-maven-plugin/src/it/deploy/interpolated-pom.xml
[DEBUG]   (f) project = org.honton.chas:exists-deploy-it:0.0.6
[DEBUG]   (f) property = maven.deploy.skip
[DEBUG]   (f) repository = http://myNexus/nexus/content/repositories/releases
[DEBUG]   (f) serverId = with-auth
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@5da7cee2
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@2f74900b
[DEBUG]   (f) skip = false
[DEBUG]   (f) skipIfSnapshot = true
[DEBUG]   (f) snapshotRepository = http://myNexus/nexus/content/repositories/snapshots
[DEBUG]   (f) snapshotServerId = test
[DEBUG]   (f) userProperty = false
[DEBUG] -- end configuration --
[DEBUG] checking for resource at http://localhost:63707/auth/repo/org/honton/chas/exists-deploy-it/0.0.6/exists-deploy-it-0.0.6.jar
http://myNexus/nexus/content/repositories/releases - Session: Opened  
http://myNexus/nexus/content/repositories/releases - Session: Disconnecting  
http://myNexus/nexus/content/repositories/releases - Session: Disconnected
[INFO] setting maven.deploy.skip=false
Jaime97 commented 6 years ago

Sorry, maybe I didn't explain it correctly. I don't mean that when you execute "mvn clean install" it deploys directly (which it doesn't). What I meant was that, after running "mvn clean install" if you run "mvn deploy" it will override the current file at the remote (even if there are no real changes).

chonton commented 6 years ago

Run “mvn verify -X”. Look at debug output for line that starts with “[DEBUG] checking for resource at”.

Is the artifact at the location which the plugin is checking?

Is there an authentication failure?

Jaime97 commented 6 years ago

Ok, solved. It was failing because of a incorrect configuration in Nexus, sorry for the inconvenience.