repaint-io / maven-tiles

Injecting maven configurations by composition rather than inheritance
154 stars 32 forks source link

Could not find tiles when using snapshot from a repository manager #14

Closed xfr-dev closed 8 years ago

xfr-dev commented 10 years ago

With snapshot version of a tile, it works fine locally when using maven install command. But, when deployed to a repository manager (ie Artifactory), Maven never find the tile and seems to not look into the specified snapshot repository. Only the release repository is used instead. Fyi, It works fine with not snapshot version locally and remotely.

rvowles commented 9 years ago

What does the effective pom say? Does it list the snapshot repository? I presume your snapshot repository is in your settings.xml?

xfr-dev commented 9 years ago

You're right, my repositories definitions (snapshot included) is in my user settings.xml. With these settings, snapshot artifacts (other than tiles) are retrieved successfully. If you have a such repository manager, does-it work for you? I'm completely aware that this problem is not simple to explain, reproduce outside and thus hard to resolve... :-)

talios commented 9 years ago

I can confirm there's a strange issue going on here - I just deployed one of my tiles to our SNAPSHOT repository and then deleted the directory from my ~/.m2/settings/repository/...:

tiledeploy

I declared a repository in my pom.xml that enabled snapshots:

<repositories>
  <repository>
    <id>snapshot</id>
    <name>snapshot</name>
    <url>http://nexus/nexus/content/groups/this_really_shouldnt_matter_as_mirror_overrules/</url>
    <layout>default</layout>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>

and my build reports:

$ mvn clean install -U
[INFO] Scanning for projects...
Downloading: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/org/codehaus/groovy/groovy-all/maven-metadata.xml
Downloaded: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/org/codehaus/groovy/groovy-all/maven-metadata.xml (5 KB at 42.8 KB/sec)
Downloading: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/org/apache/maven/shared/maven-filtering/maven-metadata.xml
Downloaded: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/org/apache/maven/shared/maven-filtering/maven-metadata.xml (674 B at 23.5 KB/sec)
Downloading: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/io/repaint/maven/tiles-maven-plugin/1.8-SNAPSHOT/maven-metadata.xml
Downloading: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/com/smxemail/tiles/com.smxemail.tiles.enforcements/maven-metadata.xml
Downloaded: http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/com/smxemail/tiles/com.smxemail.tiles.enforcements/maven-metadata.xml (467 B at 15.7 KB/sec)
[ERROR] Could not find artifact com.smxemail.tiles:com.smxemail.tiles.enforcements:pom:tile-pom:1.0.4-SNAPSHOT
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=com.smxemail.tiles -DartifactId=com.smxemail.tiles.enforcements -Dversion=1.0.4-SNAPSHOT -Dclassifier=tile-pom -Dpackaging=tile -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=com.smxemail.tiles -DartifactId=com.smxemail.tiles.enforcements -Dversion=1.0.4-SNAPSHOT -Dclassifier=tile-pom -Dpackaging=tile -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR]
[ERROR] com.smxemail.tiles:com.smxemail.tiles.enforcements:tile:1.0.4-SNAPSHOT
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] Nexus (http://build.smx.co.nz:8081/nexus/content/groups/public-and-snapshots/, releases=true, snapshots=false)
[ERROR] -> [Help 1]
[ERROR]

Two things to note, Maven did find the 1.0.4-SNAPSHOT metadata entries from the mirror repository mentioned in my settings.xml but then failed to actually download the artifact, probably because the error message mentions snapshots=false - so somewhere SNAPSHOT resolution is being disabled.

talios commented 9 years ago

After bouncing back and forth with various different setups of <mirrors> and local <profile> enabled repositories I'm still unable to get the remote -SNAPSHOT artifact to resolve.

I did make one local change to io.repaint.maven.tiles.TilesMavenLifecycleParticipant#afterProjectsRead to use topLevelProject.remoteArtifactRepositories to assign the remoteRepositories which appears to include the repositories defined in my profile, which otherwise didn't seem to show up anywhere --- however I don't know the mavenSession.request.remoteReposities is eliding them because they were covered by the mirror ( even tho I had an exclusion defined with <mirrorOf>*,!snaps</mirrorOf> ) so I suspect that change is rather unwarranted.

@rvowles Have you had a -SNAPSHOT tile successfully resolve via nexus ( and not via the local repository ) at all?

talios commented 9 years ago

Ok, now I'm invested in resolving this - since deploying the snapshot of my tile, my C.I. server is now complaining it can't find it ( it's in the meta-data, but since nothing is expecting SNAPSHOTs it never resolves the timestamp'd artifact file. ).

Time to manually delete the snapshot from my Nexus tho :(

rvowles commented 9 years ago

I do not use snapshots in Nexus yet, so no. Until we move to snapshot builds as otherwise discussed around Gerrit we have no use case for it. You however do :-)

On Mon, Oct 20, 2014 at 9:01 PM, Mark Derricutt notifications@github.com wrote:

After bouncing back and forth with various different setups of and local enabled repositories I'm still unable to get the remote -SNAPSHOT artifact to resolve.

I did make one local change to io.repaint.maven.tiles.TilesMavenLifecycleParticipant#afterProjectsRead to use topLevelProject.remoteArtifactRepositories to assign the remoteRepositories which appears to include the repositories defined in my profile, which otherwise didn't seem to show up anywhere --- however I don't know the mavenSession.request.remoteReposities is eliding them because they were covered by the mirror ( even tho I had an exclusion defined with *,!snaps ) so I suspect that change is rather unwarranted.

@rvowles https://github.com/rvowles Have you had a -SNAPSHOT tile successfully resolve via nexus ( and not via the local repository ) at all?

— Reply to this email directly or view it on GitHub https://github.com/repaint-io/maven-tiles/issues/14#issuecomment-59698943 .


Richard Vowles, Groovy, Java, Javascript, AngularJS

ph: +64275467747, web: www.google.com/+RichardVowles

talios commented 9 years ago

We don't do snapshots in Nexus either. They cause way too much pain with feature branches/gerrit.

Gael63 commented 9 years ago

Hi, I use this plugin to make tiles, but when I deploy this in my artifactory, I can't get this in my project without compiling the tile in my computer. I tested the tile with maven 3.2.3 and 3.0.5. I tried to get the remote repositories (modifying the TilesMavenLifecycleParticipant) but this solution can't work with maven 3.0.5. My settings's file contains repositories which cointains my tiles. The plugin tried to download tile in the maven central repo (http://repo.maven.apache.org/maven2). The modification is : this.remoteRepositories = mavenSession.request.projectBuildingRequest.remoteRepositories My settings file :

<?xml version="1.0" encoding="UTF-8"?>
<settings>  
    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <repositories>
                <repository>
                    <id>libs-releases-local</id>
                    <url>http://XXX:8080/artifactory/libs-releases-local@repo</url>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <updatePolicy>never</updatePolicy>
                    </releases>
                </repository>
                <repository>
                    <id>libs-snapshots-local</id>
                    <url>http://XXX:8080/artifactory/libs-snapshots-local@repo</url>
                    <snapshots>
                        <updatePolicy>always</updatePolicy>
                    </snapshots>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                </repository>               
            </repositories>         
        </profile>
    </profiles>
    <localRepository>D:\.m2</localRepository>
</settings>
kriegaex commented 9 years ago

This issue is not so new anymore and IMO it makes tiles unusable. I cannot even build the sample project. I expect tiles to be read from my local repository even if not deployed to a repo manager at all.

talios commented 9 years ago

I really wish I knew HOW to fix it as well.

Not sure whats up with the sample project - I don't think that ever worked actually. I should update it - currently theres a stash of reviews open in gerrithub ( https://review.gerrithub.io/#/q/project:repaint-io/maven-tiles+status:open ) that need reviewing/merging/releasing - the current 2.0.1 release is fundamentally broken and these fixes have sadly become languished with $work getting in the way ).

I'm tempted to just merge them and get a release out and kick the tires on tiles again...

talios commented 9 years ago

...and just merged.

talios commented 9 years ago

I just got hit with this again, what what investigation I did this morning, a) we're not copying the <repositories> element of a model (raised as #35 ), but also it looks like when using maven mirrors the <snapshots><enabled>true</enabled></snapshots> setting is dropped, so even tho the repository may contain SNAPSHOTS which get picked up in version range metadata, the SNAPSHOT is never resolved as maven is told to NOT resolve it.

I might do some more investigation and possibly post on the maven list about this, but either range resolution shouldn't be returning SNAPSHOT ranges for a repo thats not enabled for SNAPSHOTs, or the snapshot=true state should be carried forward. Either way, it looks like it may be a maven issue.

One work around I've seen suggested, but havn't had a chance to try yet is to change ones mirror settings to exclude your snapshot repo using <mirrorOf>!mySnapshotRepoId, *</mirrorOf>.

Review for #35 at https://review.gerrithub.io/249566 Copy respositories of a model along with the pluginRepositories )

rvowles commented 9 years ago

repositories were left out deliberately so that people couldn't bring repositories in via tiles. We found that with pluginRepositories then stuff wouldn't work, so I wonder if we are hitting the same issue with repositories?

talios commented 9 years ago

Rather than silently dropping the <repositories> maybe it should be a fast-fail/warning/smell on the production of the tile ( I'd probably lean toward smell/warning ).

However, I'm not sure - maven by default does not resolve SNAPSHOT artifacts from a repository unless you declare the repository and enable SNAPSHOTs.

Good news tho - I have managed to resolve the issue, or... side step it with actual maven config. In my ~/.m2/settings.xml to contain:

<mirrors>
  <mirror>
    <id>Nexus</id>
    <name>Nexus Public Mirror</name>
    <url>http://mynexus/nexus/content/groups/public</url>
    <mirrorOf>!smx3-snapshots,*</mirrorOf>
  </mirror>
</mirrors>
....
<profile>
  <id>smx</id>
  <repositories>
      <repository>
        <id>smx3-snapshots</id>
        <url>http://mynexus/nexus/content/repositories/snapshots/</url>
        <snapshots>
          <enabled>true</enabled>
        </snapshots>
        <releases>
          <enabled>false</enabled>
        </releases>
      </repository>
    </repositories>
  </profile>
</profiles>
<activeProfiles>
  <activeProfile>smx</activeProfile>
</activeProfiles>

This tells maven to enable a profile that defines a SNAPSHOT enabled repository, which is also NOT mirrored ( !smx3-snapshots in the <mirrorOf> element ) so that maven goes to it directly. Adding in some debug on the tiles plugin I see:

       id: Nexus
      url: http://mynexus/nexus/content/groups/public
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]

       id: smx3-snapshots
      url: http://mynexus/nexus/content/repositories/snapshots/
   layout: default
snapshots: [enabled => true, update => daily]
 releases: [enabled => false, update => daily]

and in the standard maven output I see:

 [INFO] --- tiles-maven-plugin: Injecting 4 tiles as intermediary parent artifact's...
 [INFO] Mixed 'com.smxemail:com.smxemail.datatype:1.4.7-SNAPSHOT' with tile 'com.smxemail.tiles:com.smxemail.tiles.release:2.0.2' as it's new parent.
 [INFO] Mixed 'com.smxemail.tiles:com.smxemail.tiles.release:2.0.2' with tile 'com.smxemail.tiles:com.smxemail.tiles.enforcements:2.0.3-20151013.021527-1' as it's new parent.
 [INFO] Mixed 'com.smxemail.tiles:com.smxemail.tiles.enforcements:2.0.3-20151013.021527-1' with tile 'com.smxemail.tiles:com.smxemail.tiles.osgiapi:2.0.1' as it's new parent.
 [INFO] Mixed 'com.smxemail.tiles:com.smxemail.tiles.osgiapi:2.0.1' with tile 'com.smxemail.tiles:com.smxemail.tiles.karaffeature:2.0.1' as it's new parent.
 [INFO] Mixed 'com.smxemail.tiles:com.smxemail.tiles.karaffeature:2.0.1' with original parent 'com.smxemail:com.smxemail.parent:2.1.16' as it's  new top level parent.

Which you can see the timestamped SNAPSHOT being mixed in.

Maybe we simple add this information into the README.adoc or a new FAQ.adoc and close the issue?

talios commented 9 years ago

Note - I was seeing this fail when using <activeByDefault> inside the profile defintion, but including the profile in the <activeProfiles> element seemed to work.

rvowles commented 8 years ago

You will need to talk me through this @talios - is there a TL;DR summary somewhere?