[ 
https://issues.apache.org/jira/browse/NPANDAY-322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13141596#comment-13141596
 ] 

Stoyan Damov commented on NPANDAY-322:
--------------------------------------

I can't re-open the ticket but the problem is still there in 
NPanDay.VisualStudio.Plugin (mainly in ReferenceManager).

In ReferenceManager.CopyArtifact there's this snippet

{code}
if (!artifact.FileInfo.Exists || artifact.Version.EndsWith("SNAPSHOT"))
{
    if 
(!NPanday.ProjectImporter.Digest.Model.Reference.DownloadArtifact(artifact,logger))
    {
        ReferenceErrorEventArgs e = new ReferenceErrorEventArgs();
        e.Message = string.Format("Unable to get the artifact {0} from any of 
your repositories.", artifact.ArtifactId);
        onError(e);
        return;
    }
}
{code}

The check for SNAPSHOT above forces "Resync references" to try and download the 
artifact off the remote repository.
If the artifact is not yet installed (which is common if I'm developing a new 
module but don't want to commit/push it yet), what happens is that:
# The resync fails (which is bad) and
# If the artifact is installed in the local repo, it gets deleted (which is
worse)

What should happen (for SNAPSHOTs) instead is this:

# Try to get timestamp of artifact in remote repo. If that fails, it shouldn't 
be a problem, the artifact might not be deployed (yet).
# Try to get timestamp of artifact in local repo. If that fails, then this is 
an error and should be reported.
# Get the timestamp of the local file (in .references/...)
# If there's a remote timestamp and it's greater than the local one, update the 
local repo's artifact.
# If the local repo's timestamp (possibly updated at point 4) is greater than 
the timestamp of the local file, update the file in .references/...

For steps 1 and 2 use the timestamp in maven-metadata(-local?).xml (in 
ReferenceManager.copyToReferenceFolder there's already a TODO which suggests
to use {{metadata/versioning/lastUpdated}} for the timestamp). Currently, the 
local repo's timestamp is considered to be the file's last write time (not even 
{{.LastWriteTimeUtc}}, which is another bug).

To make it clear, since we're all developers, here's the algo in pseudo code 
(this might not compile, I'm writing it in Jira):

{code}
DateTime remoteRepoTimestamp, localRepoTimestamp, localFileTimestamp;
bool hasRemoteTimestamp =TryGetArtifactRemoteRepositoryTimestamp(artifact, 
logger, out remoteRepoTimestamp);
bool hasLocalRepoTimestamp = TryGetArtifactLocalRepositoryTimestamp(artifact, 
logger, out localRepoTimestamp);
localFileTimestamp = GetLocalFileTimestamp(artifact.FileInfo, logger);

if (hasRemoteTimestamp && hasLocalRepoTimestamp && remoteRepoTimestamp > 
localRepoTimestamp)
{
    UpdateLocalRepoArtifact(); // == 
NPanday.ProjectImporter.Digest.Model.Reference.DownloadArtifact(artifact, 
logger)
    // ^^ error handling above omitted for brevity
    localRepoTimestamp = remoteRepoTimestamp;
}
if (hasLocalRepoTimestamp && localRepoTimestamp > localFileTimestamp)
{
    copyToReferenceFolder(artifact, referenceFolder);
}
{code}

Something like this.
                
> Resync Reference doesn't update SNAPSHOT artifact from local repository that 
> already exist in .references folder
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: NPANDAY-322
>                 URL: https://issues.apache.org/jira/browse/NPANDAY-322
>             Project: NPanday
>          Issue Type: Bug
>            Reporter: Dmitry L
>            Assignee: Joe Ocaba
>            Priority: Minor
>             Fix For: 1.2.1
>
>
> Steps:
> 1. Install Library1 into local maven repo
> 2. Add Library1 as dependency using Resync Reference to ProjectA (it will be 
> copied into .references folder)
> 3. Update and reinstall Library1 into local maven repo
> 4. Invoke Resync Reference for ProjectA
> 5. Error: Library1 won't be updated in .references folder
> Expected: newer version (in terms of file timestamp) of Library1 (if any) 
> should be copied into .references folder from local maven repo during Resync 
> Reference
> Issue exist in trunk r59731

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to