Author: lcorneliussen
Date: Fri Nov 4 16:31:33 2011
New Revision: 1197631
URL: http://svn.apache.org/viewvc?rev=1197631&view=rev
Log:
[NPANDAY-322, NPANDAY-476] Resync References
Submitted by: Stoyan Damov
o Applied without changes.
Added:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ArtifactUtils.cs
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday.VisualStudio.Addin.csproj
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
incubator/npanday/trunk/pom.xml
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday.VisualStudio.Addin.csproj
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday.VisualStudio.Addin.csproj?rev=1197631&r1=1197630&r2=1197631&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday.VisualStudio.Addin.csproj
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday.VisualStudio.Addin.csproj
Fri Nov 4 16:31:33 2011
@@ -107,6 +107,7 @@ under the License.
<Compile
Include="NPanday\VisualStudio\Addin\RemoveArtifactsForm.Designer.cs">
<DependentUpon>RemoveArtifactsForm.cs</DependentUpon>
</Compile>
+ <Compile Include="NPanday\VisualStudio\Addin\ArtifactUtils.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource
Include="NPanday\VisualStudio\Addin\AddArtifactsForm.resx">
Added:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ArtifactUtils.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ArtifactUtils.cs?rev=1197631&view=auto
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ArtifactUtils.cs
(added)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ArtifactUtils.cs
Fri Nov 4 16:31:33 2011
@@ -0,0 +1,134 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+
+namespace NPanday.VisualStudio.Addin
+{
+ static class ArtifactUtils
+ {
+ public static bool IsSnapshot(Artifact.Artifact artifact)
+ {
+ return artifact.Version.EndsWith("-SNAPSHOT");
+ }
+
+ public static bool Exists(Artifact.Artifact artifact)
+ {
+ return artifact.FileInfo.Exists;
+ }
+
+ public static bool DownloadFromRemoteRepository(Artifact.Artifact
artifact, NPanday.Logging.Logger logger)
+ {
+ return
NPanday.ProjectImporter.Digest.Model.Reference.DownloadArtifact(artifact,
logger);
+ }
+
+ public static string GetArtifactReferenceFolder(Artifact.Artifact
artifact, string referenceFolder)
+ {
+ //modified artifactFolder to match the .dll searched in
NPanday.ProjectImporter.Digest.Model.Reference.cs
+ string artifactFolder = Path.Combine(
+ referenceFolder,
+ string.Format("{0}\\{1}-{2}",
+ artifact.GroupId,
+ artifact.ArtifactId,
+ artifact.Version));
+ return artifactFolder;
+ }
+
+ public static string GetArtifactReferenceFilePath(Artifact.Artifact
artifact, string referenceFolder)
+ {
+ string artifactReferenceFolder =
GetArtifactReferenceFolder(artifact, referenceFolder);
+ Directory.CreateDirectory(artifactReferenceFolder);
+
+ string artifactReferenceFilePath =
Path.Combine(artifactReferenceFolder,
+ String.Concat(artifact.ArtifactId,
artifact.FileInfo.Extension));
+
+ return artifactReferenceFilePath;
+ }
+
+ public static DateTime GetArtifactTimestamp(Artifact.Artifact artifact)
+ {
+ // try maven-metadata-${repoId}.xml or maven-metadata-local.xml
+ string localRepoArtifactFolder =
artifact.FileInfo.Directory.FullName;
+ string[] metadataFilePaths =
Directory.GetFiles(localRepoArtifactFolder, "maven-metadata-*.xml");
+
+ DateTime metadataTimestamp;
+ if (!TryGetArtifactTimestampFromMetadataFiles(metadataFilePaths,
out metadataTimestamp))
+ {
+ // if that fails, get the file's timestamp)
+ metadataTimestamp = new
FileInfo(artifact.FileInfo.FullName).LastWriteTimeUtc;
+ }
+
+ return metadataTimestamp;
+ }
+
+ public static bool TryGetArtifactTimestampFromMetadataFiles(
+ IEnumerable<string> metadataFilePaths,
+ out DateTime timestamp)
+ {
+ foreach (string metadataFilePath in metadataFilePaths)
+ {
+ if (TryGetArtifactTimestampFromMetadataFile(metadataFilePath,
out timestamp))
+ {
+ return true;
+ }
+ }
+
+ timestamp = DateTime.MinValue;
+ return false;
+ }
+
+ public static bool TryGetArtifactTimestampFromMetadataFile(
+ string metadataFilePath,
+ out DateTime timestamp)
+ {
+ // Try to get the timestamp from metadata/versioning/lastUpdated
+ using (FileStream stream = new FileStream(metadataFilePath,
FileMode.Open, FileAccess.Read, FileShare.Read))
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.Load(stream);
+ XmlNode node =
doc.SelectSingleNode("metadata/versioning/lastUpdated");
+ string nodeInnerText;
+ if (node != null && !String.IsNullOrEmpty(nodeInnerText =
node.InnerText))
+ {
+ string value = nodeInnerText.Trim();
+ // format is yyyyMMddHHmmss e.g. 20111028030112)
+ bool parsed = DateTime.TryParseExact(value,
+ "yyyyMMddHHmmss",
+
CultureInfo.InvariantCulture,
+
DateTimeStyles.AssumeUniversal,
+ out timestamp);
+ if (parsed)
+ {
+ timestamp = timestamp.ToUniversalTime();
+ }
+ return parsed;
+ }
+ }
+
+ timestamp = DateTime.MinValue;
+ return false;
+ }
+
+ public static bool IsEarlierArtifactTimestamp(DateTime value, DateTime
comparand)
+ {
+ return CompareDatesWithoutMilliseconds(value, comparand) < 0;
+ }
+
+ public static int CompareDatesWithoutMilliseconds(DateTime left,
DateTime right)
+ {
+ DateTime l = CreateDateTimeWithoutMilliseconds(left);
+ DateTime r = CreateDateTimeWithoutMilliseconds(right);
+ return l.CompareTo(r);
+ }
+
+ public static DateTime CreateDateTimeWithoutMilliseconds(DateTime
dateTime)
+ {
+ DateTime result = new DateTime(
+ dateTime.Year, dateTime.Month, dateTime.Day,
+ dateTime.Hour, dateTime.Minute, dateTime.Second, 0,
+ dateTime.Kind);
+ return result;
+ }
+ }
+}
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs?rev=1197631&r1=1197630&r2=1197631&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/Connect.cs
Fri Nov 4 16:31:33 2011
@@ -1192,15 +1192,22 @@ namespace NPanday.VisualStudio.Addin
CommandBarButton installButton;
CommandBarButton deployButton;
CommandBarButton buildButton;
- CommandBarButton resetReferenceButton;
+ CommandBarButton resyncProjectReferencesButton;
+ CommandBarButton resyncProjectReferencesFromLocalRepositoryButton;
private void createCurrentProjectMenu(CommandBarPopup ctl)
{
- resetReferenceButton =
(CommandBarButton)ctl.Controls.Add(MsoControlType.msoControlButton,
+ resyncProjectReferencesButton =
(CommandBarButton)ctl.Controls.Add(MsoControlType.msoControlButton,
System.Type.Missing, System.Type.Missing, 1, true);
- resetReferenceButton.Visible = true;
- resetReferenceButton.Caption = "Resync References";
- resetReferenceButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(resetReferenceButton_Click);
+ resyncProjectReferencesButton.Visible = true;
+ resyncProjectReferencesButton.Caption = "Resync References";
+ resyncProjectReferencesButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(OnResyncProjectReferencesButtonClicked);
+
+ resyncProjectReferencesFromLocalRepositoryButton =
(CommandBarButton)ctl.Controls.Add(MsoControlType.msoControlButton,
+ System.Type.Missing, System.Type.Missing, 1, true);
+ resyncProjectReferencesFromLocalRepositoryButton.Visible = true;
+ resyncProjectReferencesFromLocalRepositoryButton.Caption = "Resync
References From Local Repository";
+ resyncProjectReferencesFromLocalRepositoryButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(OnResyncProjectReferencesFromLocalRepositoryButtonClicked);
cleanButton =
(CommandBarButton)ctl.Controls.Add(MsoControlType.msoControlButton,
System.Type.Missing, System.Type.Missing, 1, true);
@@ -1240,10 +1247,23 @@ namespace NPanday.VisualStudio.Addin
buildControls.Add(deployButton);
buildControls.Add(cleanButton);
buildControls.Add(testButton);
- buildControls.Add(resetReferenceButton);
+ buildControls.Add(resyncProjectReferencesButton);
+
buildControls.Add(resyncProjectReferencesFromLocalRepositoryButton);
}
- void resetReferenceButton_Click(CommandBarButton Ctrl, ref bool
CancelDefault)
+ void OnResyncProjectReferencesButtonClicked(CommandBarButton button,
ref bool cancelDefault)
+ {
+ bool resyncFromRemoteRepository = true;
+ ResyncCurrentProjectArtifacts(resyncFromRemoteRepository);
+ }
+
+ void
OnResyncProjectReferencesFromLocalRepositoryButtonClicked(CommandBarButton
button, ref bool cancelDefault)
+ {
+ bool resyncFromRemoteRepository = false;
+ ResyncCurrentProjectArtifacts(resyncFromRemoteRepository);
+ }
+
+ private void ResyncCurrentProjectArtifacts(bool fromRemoteRepository)
{
refManagerHasError = false;
outputWindowPane.OutputString(string.Format("\n[INFO] Re-syncing
artifacts in {0} project... ", CurrentSelectedProject.Name));
@@ -1252,7 +1272,15 @@ namespace NPanday.VisualStudio.Addin
IReferenceManager refmanager = new ReferenceManager();
refmanager.OnError += new
EventHandler<ReferenceErrorEventArgs>(refmanager_OnError);
refmanager.Initialize((VSProject2)CurrentSelectedProject.Object);
- refmanager.ResyncArtifacts(logger);
+
+ if (fromRemoteRepository)
+ {
+ refmanager.ResyncArtifacts(logger);
+ }
+ else
+ {
+ refmanager.ResyncArtifactsFromLocalRepository(logger);
+ }
if (!refManagerHasError)
{
@@ -1345,7 +1373,8 @@ namespace NPanday.VisualStudio.Addin
CommandBarButton testAllButton;
CommandBarButton installAllButton;
CommandBarButton buildAllButton;
- CommandBarButton resetAllButton;
+ CommandBarButton resyncSolutionReferencesButton;
+ CommandBarButton resyncSolutionReferencesFromLocalRepositoryButton;
private void createAllProjectMenu(CommandBar commandBar,
CommandBarControl control)
{
@@ -1357,11 +1386,17 @@ namespace NPanday.VisualStudio.Addin
ctlAll.BeginGroup = true;
buildControls.Add(ctlAll);
- resetAllButton =
(CommandBarButton)ctlAll.Controls.Add(MsoControlType.msoControlButton,
+ resyncSolutionReferencesButton =
(CommandBarButton)ctlAll.Controls.Add(MsoControlType.msoControlButton,
+ System.Type.Missing, System.Type.Missing, 1, true);
+ resyncSolutionReferencesButton.Visible = true;
+ resyncSolutionReferencesButton.Caption = "Resync References";
+ resyncSolutionReferencesButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(OnResyncSolutionReferencesButtonClicked);
+
+ resyncSolutionReferencesFromLocalRepositoryButton =
(CommandBarButton)ctlAll.Controls.Add(MsoControlType.msoControlButton,
System.Type.Missing, System.Type.Missing, 1, true);
- resetAllButton.Visible = true;
- resetAllButton.Caption = "Resync References";
- resetAllButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(resetAllButton_Click);
+ resyncSolutionReferencesFromLocalRepositoryButton.Visible = true;
+ resyncSolutionReferencesFromLocalRepositoryButton.Caption =
"Resync References From Local Repository";
+ resyncSolutionReferencesFromLocalRepositoryButton.Click += new
_CommandBarButtonEvents_ClickEventHandler(OnResyncSolutionReferencesFromLocalRepositoryButtonClicked);
cleanAllButton =
(CommandBarButton)ctlAll.Controls.Add(MsoControlType.msoControlButton,
System.Type.Missing, System.Type.Missing, 1, true);
@@ -1393,10 +1428,23 @@ namespace NPanday.VisualStudio.Addin
buildControls.Add(installAllButton);
buildControls.Add(cleanAllButton);
buildControls.Add(testAllButton);
- buildControls.Add(resetAllButton);
+ buildControls.Add(resyncSolutionReferencesButton);
+
buildControls.Add(resyncSolutionReferencesFromLocalRepositoryButton);
}
- void resetAllButton_Click(CommandBarButton Ctrl, ref bool
CancelDefault)
+ void OnResyncSolutionReferencesButtonClicked(CommandBarButton button,
ref bool cancelDefault)
+ {
+ bool resyncFromRemoteRepository = true;
+ ResyncSolutionArtifacts(resyncFromRemoteRepository);
+ }
+
+ void
OnResyncSolutionReferencesFromLocalRepositoryButtonClicked(CommandBarButton
button, ref bool cancelDefault)
+ {
+ bool resyncFromRemoteRepository = false;
+ ResyncSolutionArtifacts(resyncFromRemoteRepository);
+ }
+
+ private void ResyncSolutionArtifacts(bool fromRemoteRepository)
{
refManagerHasError = false;
outputWindowPane.OutputString("\n[INFO] Re-syncing artifacts in
all projects... ");
@@ -1412,7 +1460,14 @@ namespace NPanday.VisualStudio.Addin
IReferenceManager mgr = new ReferenceManager();
mgr.OnError += new
EventHandler<ReferenceErrorEventArgs>(refmanager_OnError);
mgr.Initialize((VSProject2)project.Object);
- mgr.ResyncArtifacts(logger);
+ if (fromRemoteRepository)
+ {
+ mgr.ResyncArtifacts(logger);
+ }
+ else
+ {
+ mgr.ResyncArtifactsFromLocalRepository(logger);
+ }
mgr = null;
}
}
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs?rev=1197631&r1=1197630&r2=1197631&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPanday/VisualStudio/Addin/ReferenceManager.cs
Fri Nov 4 16:31:33 2011
@@ -19,13 +19,9 @@
//
#endregion
using System;
-using System.Collections.Generic;
-using System.Text;
using System.IO;
using NPanday.Model.Pom;
-using System.Windows.Forms;
using EnvDTE;
-using EnvDTE80;
namespace NPanday.VisualStudio.Addin
{
@@ -42,6 +38,7 @@ namespace NPanday.VisualStudio.Addin
string ReferenceFolder { get; }
void CopyArtifact(Artifact.Artifact artifact, NPanday.Logging.Logger
logger);
void ResyncArtifacts(NPanday.Logging.Logger logger);
+ void ResyncArtifactsFromLocalRepository(NPanday.Logging.Logger logger);
event EventHandler<ReferenceErrorEventArgs> OnError;
}
@@ -66,10 +63,9 @@ namespace NPanday.VisualStudio.Addin
public Artifact.Artifact Add(IReferenceInfo reference)
{
- if (!initialized)
- throw new Exception("Reference manager not initialized.");
+ EnsureInitialized();
- string artifactFileName =
copyToReferenceFolder(reference.Artifact, referenceFolder);
+ string artifactFileName =
CopyToReferenceFolder(reference.Artifact, referenceFolder);
Artifact.Artifact a = reference.Artifact;
@@ -94,7 +90,7 @@ namespace NPanday.VisualStudio.Addin
{
throw new Exception("Project has no valid pom file.");
}
- createReferenceFolder();
+ CreateReferenceFolder();
}
string referenceFolder;
@@ -114,72 +110,89 @@ namespace NPanday.VisualStudio.Addin
public void CopyArtifact(Artifact.Artifact artifact,
NPanday.Logging.Logger logger)
{
- if (!initialized)
- throw new Exception("Reference manager not initialized.");
-
- 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;
- }
- }
-
- copyToReferenceFolder(artifact, referenceFolder);
+ CopyArtifactImpl(artifact, logger,
ArtifactResyncSource.RemoteRepository);
}
public void ResyncArtifacts(NPanday.Logging.Logger logger)
{
- if (!initialized)
- throw new Exception("Reference manager not initialized.");
- getReferencesFromPom(logger);
+ ResyncArtifactsImpl(logger, ArtifactResyncSource.RemoteRepository);
+ }
+
+ public void ResyncArtifactsFromLocalRepository(NPanday.Logging.Logger
logger)
+ {
+ ResyncArtifactsImpl(logger, ArtifactResyncSource.LocalRepository);
}
#endregion
#region privates
- static string copyToReferenceFolder(Artifact.Artifact artifact, string
referenceFolder)
+ private enum ArtifactResyncSource
{
- //modified artifactFolder to match the .dll searched in
NPanday.ProjectImporter.Digest.Model.Reference.cs
- string artifactFolder = Path.Combine(referenceFolder,
string.Format("{0}\\{1}-{2}", artifact.GroupId, artifact.ArtifactId,
artifact.Version));
- //string artifactFolder = Path.Combine(referenceFolder,
string.Format("{0}\\{1}", artifact.GroupId, artifact.ArtifactId));
-
- DirectoryInfo di = new DirectoryInfo(artifactFolder);
- if (!di.Exists)
- {
- di.Create();
- }
-
- //string artifactFileName = Path.Combine(artifactFolder,
artifact.FileInfo.Name);
- string artifactFileName = Path.Combine(artifactFolder,
artifact.ArtifactId+".dll");
+ RemoteRepository,
+ LocalRepository
+ }
- // TODO: Probably we should use value of
- // <metadata>/<versioning>/<lastUpdated> node from maven metadata
xml file
- // as an artifactTimestamp
- DateTime artifactTimestamp = new
FileInfo(artifact.FileInfo.FullName).LastWriteTime;
+ private void ResyncArtifactsImpl(
+ NPanday.Logging.Logger logger,
+ ArtifactResyncSource artifactResyncSource)
+ {
+ EnsureInitialized();
+
+ GetReferencesFromPom(logger, artifactResyncSource);
+ }
- if (!File.Exists(artifactFileName) ||
- (artifactTimestamp.CompareTo(new
FileInfo(artifactFileName).LastWriteTime) > 0))
+ private void CopyArtifactImpl(
+ Artifact.Artifact artifact,
+ NPanday.Logging.Logger logger,
+ ArtifactResyncSource artifactResyncSource)
+ {
+ EnsureInitialized();
+
+ bool isSnapshot = ArtifactUtils.IsSnapshot(artifact);
+ bool resyncFromRemoteRepo = artifactResyncSource ==
ArtifactResyncSource.RemoteRepository;
+
+ if (!ArtifactUtils.Exists(artifact) || (isSnapshot &&
resyncFromRemoteRepo))
{
- try
- {
- byte[] contents =
File.ReadAllBytes(artifact.FileInfo.FullName);
- File.WriteAllBytes(artifactFileName, contents);
- }
- catch (Exception ex)
+ if (!ArtifactUtils.DownloadFromRemoteRepository(artifact,
logger))
{
- Console.WriteLine(ex.ToString());
+ RaiseError("Unable to get the artifact {0} from any of
your repositories.", artifact.ArtifactId);
+ return;
}
}
- return artifactFileName;
+
+ CopyToReferenceFolder(artifact, referenceFolder);
}
+ static string CopyToReferenceFolder(Artifact.Artifact artifact, string
referenceFolder)
+ {
+ string artifactReferenceFilePath =
ArtifactUtils.GetArtifactReferenceFilePath(artifact, referenceFolder);
- void getReferencesFromPom(NPanday.Logging.Logger logger)
+ bool overwriteReferenceFile;
+ DateTime localRepoArtifactTimestamp =
ArtifactUtils.GetArtifactTimestamp(artifact);
+ if (File.Exists(artifactReferenceFilePath))
+ {
+ DateTime referenceFileTimestamp = new
FileInfo(artifactReferenceFilePath).LastWriteTimeUtc;
+ overwriteReferenceFile =
ArtifactUtils.IsEarlierArtifactTimestamp(
+ referenceFileTimestamp,
+ localRepoArtifactTimestamp);
+ }
+ else
+ {
+ overwriteReferenceFile = true;
+ }
+
+ if (overwriteReferenceFile)
+ {
+ File.Copy(artifact.FileInfo.FullName,
artifactReferenceFilePath, true);
+ // set the timestamp of the local repo's artifact
+ new FileInfo(artifactReferenceFilePath).LastWriteTimeUtc =
localRepoArtifactTimestamp;
+ }
+
+ return artifactReferenceFilePath;
+ }
+
+ void GetReferencesFromPom(NPanday.Logging.Logger logger,
ArtifactResyncSource artifactResyncSource)
{
Artifact.ArtifactRepository repository = new
NPanday.Artifact.ArtifactContext().GetArtifactRepository();
NPanday.Model.Pom.Model m =
NPanday.Utils.PomHelperUtility.ReadPomAsModel(new FileInfo(pomFile));
@@ -188,17 +201,41 @@ namespace NPanday.VisualStudio.Addin
{
foreach (Dependency d in m.dependencies)
{
- // check if intra-project reference and copy
- // artifacts from remote repository only
- if (!isIntraProject(m, d) && d.classifier == null)
+ // check if intra-project reference and copy artifacts
+ if (!IsIntraProject(m, d) && d.classifier == null)
{
- CopyArtifact(repository.GetArtifact(d),logger);
+ Artifact.Artifact artifact = repository.GetArtifact(d);
+ CopyArtifactImpl(artifact, logger,
artifactResyncSource);
}
}
}
}
- bool isIntraProject(NPanday.Model.Pom.Model m, Dependency d)
+ private void EnsureInitialized()
+ {
+ if (!initialized)
+ {
+ throw new InvalidOperationException("Reference manager not
initialized.");
+ }
+ }
+
+ private void RaiseError(string format, params object[] args)
+ {
+ ReferenceErrorEventArgs e = new ReferenceErrorEventArgs();
+ e.Message = string.Format(format, args);
+ RaiseError(e);
+ }
+
+ private void RaiseError(ReferenceErrorEventArgs e)
+ {
+ EventHandler<ReferenceErrorEventArgs> handler = OnError;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ private bool IsIntraProject(NPanday.Model.Pom.Model m, Dependency d)
{
string pomGroupId = (m.parent != null) ? m.parent.groupId :
m.groupId;
if (d.groupId == pomGroupId)
@@ -217,12 +254,12 @@ namespace NPanday.VisualStudio.Addin
return false;
}
- bool pomExist()
+ private bool pomExist()
{
return File.Exists(pomFile);
}
- void createReferenceFolder()
+ void CreateReferenceFolder()
{
DirectoryInfo di = new DirectoryInfo(referenceFolder);
if (!di.Exists)
@@ -237,17 +274,8 @@ namespace NPanday.VisualStudio.Addin
#region IReferenceManager Members
-
public event EventHandler<ReferenceErrorEventArgs> OnError;
- void onError(ReferenceErrorEventArgs e)
- {
- if (OnError != null)
- {
- OnError(this, e);
- }
- }
-
#endregion
}
Modified: incubator/npanday/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/pom.xml?rev=1197631&r1=1197630&r2=1197631&view=diff
==============================================================================
--- incubator/npanday/trunk/pom.xml (original)
+++ incubator/npanday/trunk/pom.xml Fri Nov 4 16:31:33 2011
@@ -259,6 +259,9 @@ under the License.
<contributor>
<name>Henrik Bie</name>
</contributor>
+ <contributor>
+ <name>Stoyan Damov</name>
+ </contributor>
</contributors>
<modules>
<module>components</module>