GithubHelp home page GithubHelp logo

Comments (13)

chonton avatar chonton commented on September 25, 2024

Please run mvn with '-X' option. This will enable debugging output. What values are being passed to the plugin?

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

Based on your suggestion, I've tweaked my calls but still no luck:

mvn -X org.honton.chas:exists-maven-plugin:remote -Dexists.failIfExists=true -Dexists.skipIfSnapshot=false
...
[DEBUG] Configuring mojo 'org.honton.chas:exists-maven-plugin:0.6.0:remote' with basic configurator -->
[DEBUG]   (f) artifact = mock-java-shared-library-0.0.1-SNAPSHOT.jar
[DEBUG]   (f) cmpChecksum = false
[DEBUG]   (f) failIfExists = true
[DEBUG]   (f) failIfNotExists = false
[DEBUG]   (f) failIfNotMatch = true
[DEBUG]   (f) mavenProject = MavenProject: com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT @ C:\Code\mock\Bitbucket\mock-java-shared-library\pom.xml
[DEBUG]   (f) project = com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT
[DEBUG]   (f) property = maven.deploy.skip
[DEBUG]   (f) repository = https://artifact.nurocorinternal.com/repository/maven-releases
[DEBUG]   (f) serverId = com.nurocor.repo.releases
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@6f952d6c
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@5965844d
[DEBUG]   (f) skip = false
[DEBUG]   (f) skipIfSnapshot = false
[DEBUG]   (f) snapshotRepository = https://artifact.nurocorinternal.com/repository/maven-snapshots
[DEBUG]   (f) snapshotServerId = com.nurocor.repo.snapshots
[DEBUG]   (f) userProperty = false
[DEBUG] -- end configuration --
[DEBUG] Checking for artifact at https://artifact.nurocorinternal.com/repository/maven-snapshots/com/nurocor/mock/mock-java-shared-library/0.0.1-SNAPSHOT/mock-java-shared-library-0.0.1-SNAPSHOT.jar
[DEBUG] no server configuration
[INFO] com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT does not exist

However, I know the file does exist in our Nexus repo:
image

The problem seems to be that it is checking the wrong URL for the JAR file since it is getting a timestamp attached.

from exists-maven-plugin.

chonton avatar chonton commented on September 25, 2024

Have you configured the plugin with per-execution configuration or global confguration?

          <plugin>
            <groupId>org.honton.chas</groupId>
            <artifactId>exists-maven-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>remote</goal>
                </goals>
                <configuration>
                  <!-- per-execution configuration -->
                </configuration>
              </execution>
            </executions>
            <configuration>
                <!-- global configuration -->
            </configuration>
          </plugin>     

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

Neither. As I said in the post, I'm making this call purely from a CLI with no POM configuration at all.

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

Looks like this is probably a duplicate of #26.

 Checking for artifact at https://artifact.nurocorinternal.com/repository/maven-snapshots/com/nurocor/mock/mock-java-shared-library/0.0.1-SNAPSHOT/mock-java-shared-library-0.0.1-SNAPSHOT.jar

That is not the URL to the artifact.

from exists-maven-plugin.

chonton avatar chonton commented on September 25, 2024

Probably. Snapshots are difficult to deal with. How do we determine if a particular snapshot is current? Each deploy of a snapshot creates a new timestamped suffix. What timestamp should we use? If we use latest timestamp in remote repository, what local timestamp to use?

You may wish to experiment with hash comparison instead. (Which introduces its own set of problems.)

from exists-maven-plugin.

chonton avatar chonton commented on September 25, 2024

For your use case, perhaps knowledge that any snapshot version exists is sufficient?

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

Yes, that would be a fair statement.

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

It also seems that you cannot override the fact that the pom version lists as a SNAPSHOT. For example, I tried this:

mvn -X build-helper:parse-version org.honton.chas:exists-maven-plugin:remote -Dexists.failIfExists=true -Dexists.artifact='${project.artifactId}-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}.{project.packaging}'
...
[DEBUG] Configuring mojo 'org.honton.chas:exists-maven-plugin:0.6.0:remote' with basic configurator -->
[DEBUG]   (f) artifact = 'mock-java-shared-library-0.0.1.jar'
[DEBUG]   (f) cmpChecksum = false
[DEBUG]   (f) failIfExists = true
[DEBUG]   (f) failIfNotExists = false
[DEBUG]   (f) failIfNotMatch = true
[DEBUG]   (f) mavenProject = MavenProject: com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT @ C:\Code\mock\Bitbucket\mock-java-shared-library\pom.xml
[DEBUG]   (f) project = com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT
[DEBUG]   (f) property = maven.deploy.skip
[DEBUG]   (f) repository = https://artifact.nurocorinternal.com/repository/maven-releases
[DEBUG]   (f) serverId = com.nurocor.repo.releases
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@7d070ef5
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@7a55f148
[DEBUG]   (f) skip = false
[DEBUG]   (f) skipIfSnapshot = true
[DEBUG]   (f) snapshotRepository = https://artifact.nurocorinternal.com/repository/maven-snapshots
[DEBUG]   (f) snapshotServerId = com.nurocor.repo.snapshots
[DEBUG]   (f) userProperty = false
[DEBUG] -- end configuration --
[DEBUG] skipping -SNAPSHOT

Even though my pom.xml lists the project as a SNAPSHOT, I would have expected this to check for the artifact listed in exists.artifact. Instead, it skipped because the pom.xml has a snapshot version.

I then tried adding skipIfSnapshot and this seems to get further but still do something unexpected:

mvn -X build-helper:parse-version org.honton.chas:exists-maven-plugin:remote -Dexists.failIfExists=true -Dexists.artifact='${project.artifactId}-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}.${project.packaging}' -Dexists.skipIfSnapshot=true
...
[DEBUG] Configuring mojo 'org.honton.chas:exists-maven-plugin:0.6.0:remote' with basic configurator -->
[DEBUG]   (f) artifact = 'mock-java-shared-library-0.0.1.jar'
[DEBUG]   (f) cmpChecksum = false
[DEBUG]   (f) failIfExists = true
[DEBUG]   (f) failIfNotExists = false
[DEBUG]   (f) failIfNotMatch = true
[DEBUG]   (f) mavenProject = MavenProject: com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT @ C:\Code\mock\Bitbucket\mock-java-shared-library\pom.xml
[DEBUG]   (f) project = com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT
[DEBUG]   (f) property = maven.deploy.skip
[DEBUG]   (f) repository = https://artifact.nurocorinternal.com/repository/maven-releases
[DEBUG]   (f) serverId = com.nurocor.repo.releases
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@62566842
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@2f1ea80d
[DEBUG]   (f) skip = false
[DEBUG]   (f) skipIfSnapshot = false
[DEBUG]   (f) snapshotRepository = https://artifact.nurocorinternal.com/repository/maven-snapshots
[DEBUG]   (f) snapshotServerId = com.nurocor.repo.snapshots
[DEBUG]   (f) userProperty = false
[DEBUG] -- end configuration --
[DEBUG] Checking for artifact at https://artifact.nurocorinternal.com/repository/maven-snapshots/com/nurocor/mock/mock-java-shared-library/0.0.1-SNAPSHOT/'mock-java-shared-library-0.0.1.jar'
[DEBUG] no server configuration
[INFO] com.nurocor.mock:mock-java-shared-library:0.0.1-SNAPSHOT does not exist

This looks like it used the expected artifact property for the check, but did so inside a snapshot directory. So there's not way to use this and check for a version not listed in the POM? In our particular use case, we would want to prevent someone from publishing a snapshot on a version if the release has already been published. This plugin seemed like a great way to do that, but it seems that is impossible without actively changing the POM before using the plugin.

Incidentally, your README file has a slight typo:
image
Pretty sure that should read as ${project.packaging}

from exists-maven-plugin.

chonton avatar chonton commented on September 25, 2024

Please try version 0.7.0 to see if this satisfies your use case.

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

I'm unclear from the change log what has actually changed or how I would leverage it.

from exists-maven-plugin.

robross0606 avatar robross0606 commented on September 25, 2024

I don't think 0.7.0 did much of anything to help if I'm understanding the fix. I did:

mvn -X build-helper:parse-version org.honton.chas:exists-maven-plugin:0.7.0:remote -Dexists.failIfExists=true -Dexists.artifact='${project.artifactId}-${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}.${project.packaging}' -Dexists.skipIfSnapshot=true
...
[DEBUG] Configuring mojo org.honton.chas:exists-maven-plugin:0.7.0:remote from plugin realm ClassRealm[plugin>org.honton.chas:exists-maven-plugin:0.7.0, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@73d16e93]
[DEBUG] Configuring mojo 'org.honton.chas:exists-maven-plugin:0.7.0:remote' with basic configurator -->
[DEBUG]   (f) artifact = 'mock-java-backend-service-0.0.1.jar'
[DEBUG]   (f) cmpChecksum = false
[DEBUG]   (f) failIfExists = true
[DEBUG]   (f) failIfNotExists = false
[DEBUG]   (f) failIfNotMatch = true
[DEBUG]   (f) mavenProject = MavenProject: com.nurocor.mock:mock-java-backend-service:0.0.1-SNAPSHOT @ C:\Code\mock\Bitbucket\mock-java-backend-service\pom.xml
[DEBUG]   (f) project = com.nurocor.mock:mock-java-backend-service:jar:0.0.1-SNAPSHOT
[DEBUG]   (f) property = maven.deploy.skip
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@2d7a9786
[DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@7bab5898
[DEBUG]   (f) skip = false
[DEBUG]   (f) skipIfSnapshot = true
[DEBUG]   (f) userProperty = false
[DEBUG] -- end configuration --
[DEBUG] skipping -SNAPSHOT

This now appears to have ignored exists.artifact property entirely and only used the values in the POM. Because skipIfExists was set, it skipped the check instead of using exists.artifact. This is the opposite of what would be helpful for my use case. I effectively need to provide all the data on the command line and not use the POM at all.

It doesn't seem like this plugin is useful for my intended purpose, which seems a little odd considering the purpose is to "check if some artifact exists". The fundamental impedance mismatch is that your "artifact" property is the name of the JAR file. This is quite a bit different than standard plugins like Maven Dependency plugin. Take, for example dependency:copy (https://maven.apache.org/plugins/maven-dependency-plugin/copy-mojo.html). In this plugin, artifact represents the full artifact identifier (groupId:artifactId:version[:packaging[:classifier]]), not the "JAR" file name. The JAR file name is usually constructed from those values, not the other way around. In this plugin, there is no such ability to specify the real artifact by ID. It relies on the POM for that data and then allows you to override only the name of the resulting JAR.

from exists-maven-plugin.

chonton avatar chonton commented on September 25, 2024

Did you want exists.skipIfSnapshot to be true or false?

There does appear to be a defect in that SNAPSHOT is determined by project rather than by given exists.artifact, so I recommend trying with exists.skipIfSnapshot=false

from exists-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.