merge NPE bugfix from v0.2
authorEugene Petrenko <eugene.petrenko@gmail.com>
Tue, 19 Jul 2011 15:17:36 +0000 (19:17 +0400)
committerEugene Petrenko <eugene.petrenko@gmail.com>
Tue, 19 Jul 2011 15:17:36 +0000 (19:17 +0400)
52 files changed:
.idea/libraries/Idea_OpenApi.xml
README
nuget-agent/nuget-agent.iml
nuget-agent/src/META-INF/build-agent-plugin-nuget.xml
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/NuGetActionFactory.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/NuGetPackagesCollector.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackageUsages.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackagesInstallerRunner.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/InstallStages.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/InstallStagesImpl.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/LoggingNuGetActionFactoryImpl.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetActionFactoryImpl.java
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesCollectorEx.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesCollectorImpl.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesConfigParser.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackageUsagesImpl.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesInfoUploader.java [new file with mode: 0644]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesInstallerBuilder.java [moved from nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackagesInstallerBuilder.java with 78% similarity]
nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesWatcher.java [new file with mode: 0644]
nuget-common/nuget-common.iml
nuget-common/src/META-INF/spring-nuget-common.xml [new file with mode: 0644]
nuget-common/src/jetbrains/buildServer/nuget/common/PackageDependencies.java [new file with mode: 0644]
nuget-common/src/jetbrains/buildServer/nuget/common/PackageDependenciesStore.java [new file with mode: 0644]
nuget-common/src/jetbrains/buildServer/nuget/common/PackageInfo.java [new file with mode: 0644]
nuget-common/src/jetbrains/buildServer/nuget/common/PackagesConstants.java
nuget-server/resources/NuGetBuild.jsp [deleted file]
nuget-server/resources/show/showPackages.jsp [new file with mode: 0644]
nuget-server/src/META-INF/build-server-plugin-nuget.xml
nuget-server/src/jetbrains/buildServer/nuget/server/NuGetDownloadedPackagesTab.java [deleted file]
nuget-server/src/jetbrains/buildServer/nuget/server/exec/ListPackagesCommand.java
nuget-server/src/jetbrains/buildServer/nuget/server/exec/ListPackagesCommandImpl.java
nuget-server/src/jetbrains/buildServer/nuget/server/exec/ListPackagesCommandProcessor.java
nuget-server/src/jetbrains/buildServer/nuget/server/exec/SourcePackageInfo.java [moved from nuget-server/src/jetbrains/buildServer/nuget/server/exec/PackageInfo.java with 89% similarity]
nuget-server/src/jetbrains/buildServer/nuget/server/show/NuGetDownloadedPackagesTab.java [new file with mode: 0644]
nuget-server/src/jetbrains/buildServer/nuget/server/trigger/NamedPackagesUpdateChecker.java
nuget-server/teamcity-server-plugin.xml
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetInstallPackageActionFactoryTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPackagesConfigParserTest.java [new file with mode: 0644]
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetUpdatePackageActionFactoryTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/PackagesInstallerBuilderTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/PackagesWatcherTest.java [new file with mode: 0644]
nuget-tests/src/jetbrains/buildServer/nuget/tests/common/PackageDependenciesStoreTest.java [new file with mode: 0644]
nuget-tests/src/jetbrains/buildServer/nuget/tests/integration/InstallPackageIntegtatoinTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/integration/Paths.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/server/ListPackagesCommandProcessorTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/server/ListPackagesCommandTest.java
nuget-tests/src/jetbrains/buildServer/nuget/tests/server/NamedPackagesUpdateCheckerTest.java
nuget-tests/src/testng-nuget-tests..xml
nuget-tests/testData/config/test-01.xml [new file with mode: 0644]
nuget-tests/testData/config/test-02.xml [new file with mode: 0644]
nuget-tests/testData/config/test-03.xml [new file with mode: 0644]
nuget-tests/testData/config/test-04.xml [new file with mode: 0644]

index 7cdf0cd1c96f3294bcb399fca88ed901c4b3dde1..12c0ba987c6c1911cdac9b98e76bf205a1858d7f 100644 (file)
@@ -4,6 +4,7 @@
       <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/util.jar!/" />\r
       <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/openapi.jar!/" />\r
       <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/trove4j.jar!/" />\r
+      <root url="jar://$TeamCityDistribution$/webapps/ROOT/WEB-INF/lib/jdom.jar!/" />\r
     </CLASSES>\r
     <JAVADOC />\r
     <SOURCES />\r
diff --git a/README b/README
index a2737b4fe05ea1b43d6409e6850aa0742a1b97d5..f227ef73aa434bbd9da311b62d46fce7826322b6 100644 (file)
--- a/README
+++ b/README
@@ -22,6 +22,12 @@ Supported features:
   \r
   Build Trigger that starts a new build if package is updated.   \r
 \r
+- NuGet used packages tab\r
+\r
+  Reports list of all used packages in build configuration. \r
+  Available only if NuGet Packages Installer Build Runner is used.\r
+\r
+\r
 API gaps:\r
  - Reuse ComposideBuildProcess and DelegatingBuildProcess\r
  - Use XmlXppAbstractParser#parse(InputSream)\r
index 4a2a067bccadfb2d72a6cbb47132689cffb77d61..6ec8153d0949adc5f9e0c05fc78ed7103d1bafe9 100644 (file)
     <orderEntry type="sourceFolder" forTests="false" />\r
     <orderEntry type="library" name="Agent-Api" level="project" />\r
     <orderEntry type="library" name="Common-Api" level="project" />\r
-    <orderEntry type="library" name="Idea-OpenApi" level="project" />\r
     <orderEntry type="library" name="log4j" level="project" />\r
     <orderEntry type="module" module-name="nuget-common" />\r
     <orderEntry type="library" name="Agent-internal" level="project" />\r
     <orderEntry type="library" name="Common-Impl" level="project" />\r
+    <orderEntry type="library" name="Idea-OpenApi" level="project" />\r
   </component>\r
 </module>\r
 \r
index 7e157a597ceb4f38bfb7129327b9efdeef6ff675..433fa93abba7e11a69623ebc0483bfc9f3eb3ded 100644 (file)
@@ -6,6 +6,8 @@
                            http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
        default-autowire="constructor">\r
 \r
+  <import resource="classpath*:META-INF/spring-nuget-common.xml"/>\r
+\r
   <bean class="jetbrains.buildServer.nuget.agent.util.impl.CommandlineBuildProcessFactoryImpl"/>\r
 \r
   <bean class="jetbrains.buildServer.nuget.agent.install.PackagesInstallerRunner"/>\r
   </bean>\r
 \r
   <bean class="jetbrains.buildServer.nuget.agent.parameters.impl.PackagesParametersFactoryImpl"/>\r
+\r
+  <bean class="jetbrains.buildServer.nuget.agent.install.impl.PackageUsagesImpl"/>\r
+  <bean class="jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser" />\r
+  <bean class="jetbrains.buildServer.nuget.agent.install.impl.PackagesWatcher"/>\r
+  <bean class="jetbrains.buildServer.nuget.agent.install.impl.PackagesInfoUploader"/>\r
+  <bean class="jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl"/>\r
 </beans>
\ No newline at end of file
index 378f3783958c12217e579b404ff946fb9db73352..94bb7dee3409f5c0a3b69582360dfd222814edf7 100644 (file)
@@ -42,4 +42,10 @@ public interface NuGetActionFactory {
                             @NotNull PackagesUpdateParameters params,\r
                             @NotNull File packagesConfig,\r
                             @NotNull File targetFolder) throws RunBuildException;\r
+\r
+  @NotNull\r
+  BuildProcess createUsageReport(@NotNull BuildRunnerContext context,\r
+                                 @NotNull NuGetParameters params,\r
+                                 @NotNull File packagesConfig,\r
+                                 @NotNull File targetFolder) throws RunBuildException;\r
 }\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/NuGetPackagesCollector.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/NuGetPackagesCollector.java
new file mode 100644 (file)
index 0000000..a561ff2
--- /dev/null
@@ -0,0 +1,38 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install;\r
+\r
+import jetbrains.buildServer.nuget.common.PackageDependencies;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 22:43\r
+ */\r
+public interface NuGetPackagesCollector {\r
+\r
+  void addPackage(@NotNull final String packageId,\r
+                  @NotNull final String version,\r
+                  @Nullable final String allowedVersions);\r
+\r
+  /**\r
+   * @return sorted list of packages that were registered\r
+   */\r
+  @NotNull\r
+  public PackageDependencies getPackages();\r
+}\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackageUsages.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackageUsages.java
new file mode 100644 (file)
index 0000000..bf1e3bc
--- /dev/null
@@ -0,0 +1,29 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.File;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 23:50\r
+ */\r
+public interface PackageUsages {\r
+  void createReport(@NotNull File packagesConfig);\r
+}\r
index 8db97682d4116728d457632b0ae9825b402d3760..6c5c07a5d816304bbf3f60ab0effaaf944971583 100644 (file)
@@ -19,11 +19,13 @@ package jetbrains.buildServer.nuget.agent.install;
 import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.*;\r
+import jetbrains.buildServer.nuget.agent.install.impl.InstallStages;\r
+import jetbrains.buildServer.nuget.agent.install.impl.InstallStagesImpl;\r
+import jetbrains.buildServer.nuget.agent.install.impl.PackagesInstallerBuilder;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
-import jetbrains.buildServer.nuget.agent.util.CompositeBuildProcess;\r
 import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
 import jetbrains.buildServer.nuget.common.DotNetConstants;\r
 import jetbrains.buildServer.nuget.common.PackagesConstants;\r
@@ -49,6 +51,13 @@ public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunn
   public BuildProcess createBuildProcess(@NotNull AgentRunningBuild runningBuild,\r
                                          @NotNull final BuildRunnerContext context) throws RunBuildException {\r
     CompositeBuildProcessImpl process = new CompositeBuildProcessImpl();\r
+    InstallStages stages = new InstallStagesImpl(process);\r
+    createStages(context, stages);\r
+    return process;\r
+  }\r
+\r
+  private void createStages(@NotNull final BuildRunnerContext context,\r
+                            @NotNull final InstallStages stages) throws RunBuildException {\r
     final NuGetParameters parameters = myParametersFactory.loadNuGetParameters(context);\r
     final PackagesInstallParameters installParameters = myParametersFactory.loadInstallPackagesParameters(context, parameters);\r
     final PackagesUpdateParameters updateParameters = myParametersFactory.loadUpdatePackagesParameters(context, parameters);\r
@@ -57,29 +66,18 @@ public class PackagesInstallerRunner implements AgentBuildRunner, AgentBuildRunn
       throw new RunBuildException("NuGet install packages must be enabled");\r
     }\r
 \r
-    final CompositeBuildProcess install = new CompositeBuildProcessImpl();\r
-    final CompositeBuildProcess update = new CompositeBuildProcessImpl();\r
-    final CompositeBuildProcess postUpdate = new CompositeBuildProcessImpl();\r
-\r
     final LocateNuGetConfigBuildProcess locate = new LocateNuGetConfigBuildProcess(\r
             parameters,\r
             context.getBuild().getBuildLogger(),\r
             new PackagesInstallerBuilder(\r
                     myNuGetActionFactory,\r
-                    install,\r
-                    update,\r
-                    postUpdate,\r
+                    stages,\r
                     context,\r
                     installParameters,\r
                     updateParameters\r
             ));\r
 \r
-    process.pushBuildProcess(locate);\r
-    process.pushBuildProcess(install);\r
-    process.pushBuildProcess(update);\r
-    process.pushBuildProcess(postUpdate);\r
-\r
-    return process;\r
+    stages.getLocateStage().pushBuildProcess(locate);\r
   }\r
 \r
   @NotNull\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/InstallStages.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/InstallStages.java
new file mode 100644 (file)
index 0000000..f395fbf
--- /dev/null
@@ -0,0 +1,41 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import jetbrains.buildServer.nuget.agent.util.BuildProcessContinuation;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 23:36\r
+ */\r
+public interface InstallStages {\r
+  @NotNull\r
+  BuildProcessContinuation getLocateStage();\r
+\r
+  @NotNull\r
+  BuildProcessContinuation getInstallStage();\r
+\r
+  @NotNull\r
+  BuildProcessContinuation getUpdateStage();\r
+\r
+  @NotNull\r
+  BuildProcessContinuation getPostUpdateStart();\r
+\r
+  @NotNull\r
+  BuildProcessContinuation getReportStage();\r
+}\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/InstallStagesImpl.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/InstallStagesImpl.java
new file mode 100644 (file)
index 0000000..9f59c5c
--- /dev/null
@@ -0,0 +1,73 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import jetbrains.buildServer.nuget.agent.util.BuildProcessContinuation;\r
+import jetbrains.buildServer.nuget.agent.util.impl.CompositeBuildProcessImpl;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 23:40\r
+ */\r
+public class InstallStagesImpl implements InstallStages {\r
+  private final BuildProcessContinuation myLocate;\r
+  private final BuildProcessContinuation myInstall;\r
+  private final BuildProcessContinuation myUpdate;\r
+  private final BuildProcessContinuation myPostInstall;\r
+  private final BuildProcessContinuation myReport;\r
+\r
+  public InstallStagesImpl(@NotNull final BuildProcessContinuation host) {\r
+    //order is significant\r
+    myLocate = push(host);\r
+    myInstall = push(host);\r
+    myUpdate = push(host);\r
+    myPostInstall = push(host);\r
+    myReport = push(host);\r
+  }\r
+\r
+  private static BuildProcessContinuation push(@NotNull final BuildProcessContinuation proc) {\r
+    CompositeBuildProcessImpl child = new CompositeBuildProcessImpl();\r
+    proc.pushBuildProcess(child);\r
+    return child;\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcessContinuation getLocateStage() {\r
+    return myLocate;\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcessContinuation getInstallStage() {\r
+    return myInstall;\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcessContinuation getUpdateStage() {\r
+    return myUpdate;\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcessContinuation getPostUpdateStart() {\r
+    return myPostInstall;\r
+  }\r
+\r
+  @NotNull\r
+  public BuildProcessContinuation getReportStage() {\r
+    return myReport;\r
+  }\r
+}\r
index d35f855568a5c4e4784179216b03845e55603dbe..04812bb5c6bea5242fac63701355c6bc3fcadd35 100644 (file)
@@ -21,6 +21,7 @@ import jetbrains.buildServer.agent.BuildProcess;
 import jetbrains.buildServer.agent.BuildProgressLogger;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.install.NuGetActionFactory;\r
+import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
 import jetbrains.buildServer.nuget.agent.util.DelegatingBuildProcess;\r
@@ -40,6 +41,11 @@ public class LoggingNuGetActionFactoryImpl implements NuGetActionFactory {
     myActionFactory = actionFactory;\r
   }\r
 \r
+  @NotNull\r
+  public BuildProcess createUsageReport(@NotNull BuildRunnerContext context, @NotNull NuGetParameters params, @NotNull File packagesConfig, @NotNull File targetFolder) throws RunBuildException {\r
+    return myActionFactory.createUsageReport(context, params, packagesConfig, targetFolder);\r
+  }\r
+\r
   @NotNull\r
   public BuildProcess createInstall(@NotNull final BuildRunnerContext context,\r
                                     @NotNull final PackagesInstallParameters params,\r
index 1ce6cafedc2f1095073a1bccff5040d7e4d8e6e9..640a7f7189ce666b27eb1c14adcdfbac168199be 100644 (file)
 \r
 package jetbrains.buildServer.nuget.agent.install.impl;\r
 \r
+import com.intellij.openapi.diagnostic.Logger;\r
 import jetbrains.buildServer.RunBuildException;\r
+import jetbrains.buildServer.agent.BuildFinishedStatus;\r
 import jetbrains.buildServer.agent.BuildProcess;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.install.NuGetActionFactory;\r
+import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
+import jetbrains.buildServer.nuget.agent.util.BuildProcessBase;\r
 import jetbrains.buildServer.nuget.agent.util.CommandlineBuildProcessFactory;\r
 import jetbrains.buildServer.util.FileUtil;\r
 import org.jetbrains.annotations.NotNull;\r
@@ -37,10 +41,15 @@ import java.util.List;
  * Date: 07.07.11 17:49\r
  */\r
 public class NuGetActionFactoryImpl implements NuGetActionFactory {\r
+  private static final Logger LOG = Logger.getInstance(NuGetActionFactoryImpl.class.getName());\r
+\r
   private final CommandlineBuildProcessFactory myFactory;\r
+  private final PackageUsages myPackageUsages;\r
 \r
-  public NuGetActionFactoryImpl(CommandlineBuildProcessFactory factory) {\r
+  public NuGetActionFactoryImpl(@NotNull final CommandlineBuildProcessFactory factory,\r
+                                @NotNull final PackageUsages packageUsages) {\r
     myFactory = factory;\r
+    myPackageUsages = packageUsages;\r
   }\r
 \r
   @NotNull\r
@@ -84,6 +93,20 @@ public class NuGetActionFactoryImpl implements NuGetActionFactory {
     return executeNuGet(context, params.getNuGetParameters(), argz, packagesConfig.getParentFile());\r
   }\r
 \r
+  @NotNull\r
+  public BuildProcess createUsageReport(@NotNull final BuildRunnerContext context,\r
+                                        @NotNull final NuGetParameters params,\r
+                                        @NotNull final File packagesConfig,\r
+                                        @NotNull final File targetFolder) throws RunBuildException {\r
+    return new BuildProcessBase() {\r
+      @NotNull\r
+      @Override\r
+      protected BuildFinishedStatus waitForImpl() throws RunBuildException {\r
+        myPackageUsages.createReport(packagesConfig);\r
+        return BuildFinishedStatus.FINISHED_SUCCESS;\r
+      }\r
+    };\r
+  }\r
 \r
   @NotNull\r
   private BuildProcess executeNuGet(@NotNull final BuildRunnerContext context,\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesCollectorEx.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesCollectorEx.java
new file mode 100644 (file)
index 0000000..ab89d8e
--- /dev/null
@@ -0,0 +1,27 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import jetbrains.buildServer.nuget.agent.install.NuGetPackagesCollector;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 23:00\r
+ */\r
+public interface NuGetPackagesCollectorEx extends NuGetPackagesCollector {\r
+  void removeAllPackages();\r
+}\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesCollectorImpl.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesCollectorImpl.java
new file mode 100644 (file)
index 0000000..a798400
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import jetbrains.buildServer.nuget.common.PackageDependencies;\r
+import jetbrains.buildServer.nuget.common.PackageInfo;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+import java.util.Collections;\r
+import java.util.TreeSet;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 22:52\r
+ */\r
+public class NuGetPackagesCollectorImpl implements NuGetPackagesCollectorEx {\r
+  private final TreeSet<PackageInfo> myPackages = new TreeSet<PackageInfo>();\r
+\r
+\r
+  public void addPackage(@NotNull String packageId, @NotNull String version, @Nullable String allowedVersions) {\r
+    myPackages.add(new PackageInfo(packageId, version));\r
+  }\r
+\r
+  @NotNull\r
+  public PackageDependencies getPackages() {\r
+    return new PackageDependencies(\r
+            Collections.<String>emptyList(),\r
+            myPackages);\r
+  }\r
+\r
+  public void removeAllPackages() {\r
+    myPackages.clear();\r
+  }\r
+}\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesConfigParser.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/NuGetPackagesConfigParser.java
new file mode 100644 (file)
index 0000000..fb6aa36
--- /dev/null
@@ -0,0 +1,69 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.nuget.agent.install.NuGetPackagesCollector;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import jetbrains.buildServer.util.XmlXppAbstractParser;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 22:45\r
+ */\r
+public class NuGetPackagesConfigParser {\r
+  private static final Logger LOG = Logger.getInstance(NuGetPackagesConfigParser.class.getName());\r
+\r
+  public void parseNuGetPackages(@NotNull final File packagesConfig,\r
+                                 @NotNull final NuGetPackagesCollector callback) throws IOException {\r
+    XmlXppAbstractParser parser = new XmlXppAbstractParser() {\r
+      @Override\r
+      protected List<XmlHandler> getRootHandlers() {\r
+        return Arrays.asList(elementsPath(new Handler() {\r
+          public XmlReturn processElement(@NotNull XmlElementInfo xmlElementInfo) {\r
+            String id = xmlElementInfo.getAttribute("id");\r
+            String version = xmlElementInfo.getAttribute("version");\r
+            if (id == null || StringUtil.isEmptyOrSpaces(id))\r
+              return xmlElementInfo.noDeep();\r
+\r
+            if (version == null || StringUtil.isEmptyOrSpaces(version))\r
+              return xmlElementInfo.noDeep();\r
+\r
+\r
+            callback.addPackage(\r
+                    id,\r
+                    version,\r
+                    xmlElementInfo.getAttribute("allowedVersions"));\r
+\r
+            return xmlElementInfo.noDeep();\r
+          }\r
+        }, "packages", "package"));\r
+      }\r
+    };\r
+    try {\r
+      parser.parse(packagesConfig);\r
+    } catch (IOException e) {\r
+      LOG.warn("Failed to parse packages.config file: " + packagesConfig + ". " + e.getMessage(), e);\r
+    }\r
+  }\r
+}\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackageUsagesImpl.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackageUsagesImpl.java
new file mode 100644 (file)
index 0000000..b62aa8c
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.nuget.agent.install.NuGetPackagesCollector;\r
+import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 23:17\r
+ */\r
+public class PackageUsagesImpl implements PackageUsages {\r
+  private static final Logger LOG = Logger.getInstance(PackageUsagesImpl.class.getName());\r
+\r
+  private final NuGetPackagesCollector myCollector;\r
+  private final NuGetPackagesConfigParser myParser;\r
+\r
+  public PackageUsagesImpl(@NotNull final NuGetPackagesCollector collector,\r
+                           @NotNull final NuGetPackagesConfigParser parser) {\r
+    myCollector = collector;\r
+    myParser = parser;\r
+  }\r
+\r
+  public void createReport(@NotNull final File packagesConfig) {\r
+    if (!packagesConfig.exists()) {\r
+      LOG.debug("Packages file: " + packagesConfig + " does not exit");\r
+      return;\r
+    }\r
+\r
+    try {\r
+      myParser.parseNuGetPackages(packagesConfig, myCollector);\r
+    } catch (IOException e) {\r
+      LOG.warn("Failed to parse " + packagesConfig + ". " + e.getMessage(), e);\r
+    }\r
+  }\r
+}\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesInfoUploader.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesInfoUploader.java
new file mode 100644 (file)
index 0000000..10c2819
--- /dev/null
@@ -0,0 +1,53 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.artifacts.ArtifactsWatcher;\r
+import jetbrains.buildServer.nuget.common.PackageDependencies;\r
+import jetbrains.buildServer.nuget.common.PackageDependenciesStore;\r
+import jetbrains.buildServer.util.FileUtil;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_USED_PACKAGES_DIR;\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_USED_PACKAGES_FILE;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 23:02\r
+ */\r
+public class PackagesInfoUploader {\r
+  private final ArtifactsWatcher myPublisher;\r
+  private final PackageDependenciesStore myStore;\r
+\r
+  public PackagesInfoUploader(@NotNull final ArtifactsWatcher publisher,\r
+                              @NotNull final PackageDependenciesStore store) {\r
+    myPublisher = publisher;\r
+    myStore = store;\r
+  }\r
+\r
+  public void uploadDepectedPackages(@NotNull final AgentRunningBuild build,\r
+                                     @NotNull final PackageDependencies infos) throws IOException {\r
+    File tmp = FileUtil.createTempDirectory("nuget", "packages", build.getBuildTempDirectory());\r
+    File content = new File(tmp, NUGET_USED_PACKAGES_FILE);\r
+    myStore.save(infos, content);\r
+    myPublisher.addNewArtifactsPath(content.getPath() + " => " + NUGET_USED_PACKAGES_DIR);\r
+  }\r
+}\r
similarity index 78%
rename from nuget-agent/src/jetbrains/buildServer/nuget/agent/install/PackagesInstallerBuilder.java
rename to nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesInstallerBuilder.java
index 856da9050dbfc34dffc90864ab3ea85a6fec02e4..230851c2a44b8df1e41084f647caac5e6865e4e8 100644 (file)
  * limitations under the License.\r
  */\r
 \r
-package jetbrains.buildServer.nuget.agent.install;\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
 \r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
+import jetbrains.buildServer.nuget.agent.install.LocateNuGetConfigBuildProcess;\r
+import jetbrains.buildServer.nuget.agent.install.NuGetActionFactory;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
-import jetbrains.buildServer.nuget.agent.util.BuildProcessContinuation;\r
 import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
 import org.jetbrains.annotations.NotNull;\r
 import org.jetbrains.annotations.Nullable;\r
@@ -35,24 +36,18 @@ import static jetbrains.buildServer.nuget.common.PackagesUpdateMode.FOR_EACH_PAC
  */\r
 public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.Callback {\r
   private final NuGetActionFactory myActionFactory;\r
-  private final BuildProcessContinuation myInstall;\r
-  private final BuildProcessContinuation myUpdate;\r
-  private final BuildProcessContinuation myPostUpdate;\r
+  private final InstallStages myStages;\r
   private final BuildRunnerContext myContext;\r
 \r
   private final PackagesUpdateParameters myUpdateParameters;\r
   private final PackagesInstallParameters myInstallParameters;\r
 \r
   public PackagesInstallerBuilder(@NotNull final NuGetActionFactory actionFactory,\r
-                                  @NotNull final BuildProcessContinuation install,\r
-                                  @NotNull final BuildProcessContinuation update,\r
-                                  @NotNull final BuildProcessContinuation postUpdate,\r
+                                  @NotNull final InstallStages stages,\r
                                   @NotNull final BuildRunnerContext context,\r
                                   @NotNull final PackagesInstallParameters installParameters,\r
                                   @Nullable final PackagesUpdateParameters updateParameters) {\r
-    myInstall = install;\r
-    myUpdate = update;\r
-    myPostUpdate = postUpdate;\r
+    myStages = stages;\r
     myContext = context;\r
     myUpdateParameters = updateParameters;\r
     myInstallParameters = installParameters;\r
@@ -63,7 +58,7 @@ public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.C
     if (myUpdateParameters == null) return;\r
     if (myUpdateParameters.getUpdateMode() != PackagesUpdateMode.FOR_SLN) return;\r
 \r
-    myUpdate.pushBuildProcess(\r
+    myStages.getUpdateStage().pushBuildProcess(\r
             myActionFactory.createUpdate(\r
                     myContext,\r
                     myUpdateParameters,\r
@@ -74,14 +69,20 @@ public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.C
   }\r
 \r
   public final void onPackagesConfigFound(@NotNull final File config, @NotNull final File targetFolder) throws RunBuildException {\r
-    myInstall.pushBuildProcess(myActionFactory.createInstall(myContext,\r
+    myStages.getInstallStage().pushBuildProcess(myActionFactory.createInstall(\r
+            myContext,\r
             myInstallParameters,\r
             config,\r
             targetFolder));\r
 \r
+    myStages.getReportStage().pushBuildProcess(myActionFactory.createUsageReport(\r
+            myContext,\r
+            myInstallParameters.getNuGetParameters(),\r
+            config, targetFolder));\r
+\r
     if (myUpdateParameters == null) return;\r
     if (myUpdateParameters.getUpdateMode() == FOR_EACH_PACKAGES_CONFIG) {\r
-      myUpdate.pushBuildProcess(\r
+      myStages.getUpdateStage().pushBuildProcess(\r
               myActionFactory.createUpdate(\r
                       myContext,\r
                       myUpdateParameters,\r
@@ -91,7 +92,7 @@ public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.C
       );\r
     }\r
 \r
-    myPostUpdate.pushBuildProcess(\r
+    myStages.getPostUpdateStart().pushBuildProcess(\r
             myActionFactory.createInstall(\r
                     myContext,\r
                     myInstallParameters,\r
@@ -99,6 +100,8 @@ public class PackagesInstallerBuilder implements LocateNuGetConfigBuildProcess.C
                     targetFolder\r
             )\r
     );\r
+\r
+\r
   }\r
 \r
 }\r
diff --git a/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesWatcher.java b/nuget-agent/src/jetbrains/buildServer/nuget/agent/install/impl/PackagesWatcher.java
new file mode 100644 (file)
index 0000000..69e16cc
--- /dev/null
@@ -0,0 +1,67 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.agent.install.impl;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.agent.AgentLifeCycleAdapter;\r
+import jetbrains.buildServer.agent.AgentLifeCycleListener;\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.BuildFinishedStatus;\r
+import jetbrains.buildServer.nuget.common.PackageDependencies;\r
+import jetbrains.buildServer.nuget.common.PackageInfo;\r
+import jetbrains.buildServer.util.EventDispatcher;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 22:59\r
+ */\r
+public class PackagesWatcher {\r
+  private static final Logger LOG = Logger.getInstance(PackagesWatcher.class.getName());\r
+\r
+  public PackagesWatcher(@NotNull final EventDispatcher<AgentLifeCycleListener> events,\r
+                         @NotNull final NuGetPackagesCollectorEx collector,\r
+                         @NotNull final PackagesInfoUploader uploader) {\r
+    events.addListener(new AgentLifeCycleAdapter(){\r
+      @Override\r
+      public void buildStarted(@NotNull AgentRunningBuild runningBuild) {\r
+        collector.removeAllPackages();\r
+      }\r
+\r
+      @Override\r
+      public void beforeBuildFinish(@NotNull AgentRunningBuild build, @NotNull BuildFinishedStatus buildStatus) {\r
+        PackageDependencies packages = collector.getPackages();\r
+        if (packages.isEmpty()) return;\r
+\r
+        try {\r
+          uploader.uploadDepectedPackages(build, packages);\r
+        } catch (IOException e) {\r
+          LOG.warn("Failed to generate and upload list of used NuGet packages. " + e.getMessage(), e);\r
+        }\r
+      }\r
+\r
+      @Override\r
+      public void buildFinished(@NotNull AgentRunningBuild build, @NotNull BuildFinishedStatus buildStatus) {\r
+        collector.removeAllPackages();\r
+      }\r
+    });\r
+  }\r
+}\r
index b2eeaf1bc3750f59dcf7854214ed64a431a826c9..8c83284ff32af754d8f48a8b42e4bcd1be5140bd 100644 (file)
@@ -1,5 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <module type="JAVA_MODULE" version="4">\r
+  <component name="FacetManager">\r
+    <facet type="Spring" name="Spring">\r
+      <configuration>\r
+        <fileset id="fileset1" name="nuget-common" removed="false">\r
+          <file>file://$MODULE_DIR$/src/META-INF/spring-nuget-common.xml</file>\r
+        </fileset>\r
+      </configuration>\r
+    </facet>\r
+  </component>\r
   <component name="NewModuleRootManager" inherit-compiler-output="true">\r
     <exclude-output />\r
     <content url="file://$MODULE_DIR$">\r
@@ -8,6 +17,9 @@
     <orderEntry type="inheritedJdk" />\r
     <orderEntry type="sourceFolder" forTests="false" />\r
     <orderEntry type="library" name="idea annotations.jar" level="project" />\r
+    <orderEntry type="library" name="Idea-OpenApi" level="project" />\r
+    <orderEntry type="library" name="Common-Api" level="project" />\r
+    <orderEntry type="library" name="Common-Impl" level="project" />\r
   </component>\r
 </module>\r
 \r
diff --git a/nuget-common/src/META-INF/spring-nuget-common.xml b/nuget-common/src/META-INF/spring-nuget-common.xml
new file mode 100644 (file)
index 0000000..dd90a7e
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--suppress AutowiredDependenciesInspection -->\r
+<beans xmlns="http://www.springframework.org/schema/beans"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.springframework.org/schema/beans\r
+                           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
+       default-autowire="constructor">\r
+\r
+  <bean class="jetbrains.buildServer.nuget.common.PackageDependenciesStore"/>\r
+\r
+</beans>\r
diff --git a/nuget-common/src/jetbrains/buildServer/nuget/common/PackageDependencies.java b/nuget-common/src/jetbrains/buildServer/nuget/common/PackageDependencies.java
new file mode 100644 (file)
index 0000000..a862f20
--- /dev/null
@@ -0,0 +1,68 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.common;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.TreeSet;\r
+\r
+/**\r
+ * Represent list of downloaded dependecies of a build\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 19.07.11 11:41\r
+ */\r
+public class PackageDependencies {\r
+  private final Collection<String> mySources;\r
+  private final Collection<PackageInfo> myPackages;\r
+\r
+  public PackageDependencies(@NotNull final Collection<String> sources,\r
+                             @NotNull final Collection<PackageInfo> packages) {\r
+    mySources = Collections.unmodifiableCollection(new TreeSet<String>(sources));\r
+    myPackages = Collections.unmodifiableCollection(new TreeSet<PackageInfo>(packages));\r
+  }\r
+\r
+  /**\r
+   * @return NuGet sources configured from web\r
+   */\r
+  @NotNull\r
+  public Collection<String> getSources() {\r
+    return mySources;\r
+  }\r
+\r
+  /**\r
+   *\r
+   * @return sorted list of packages that were used in project\r
+   */\r
+  @NotNull\r
+  public Collection<PackageInfo> getPackages() {\r
+    return myPackages;\r
+  }\r
+\r
+  public boolean isEmpty() {\r
+    return getPackages().isEmpty();\r
+  }\r
+\r
+  @Override\r
+  public String toString() {\r
+    return "PackageDependencies{" +\r
+            "mySources=" + mySources +\r
+            ", myPackages=" + myPackages +\r
+            '}';\r
+  }\r
+}\r
diff --git a/nuget-common/src/jetbrains/buildServer/nuget/common/PackageDependenciesStore.java b/nuget-common/src/jetbrains/buildServer/nuget/common/PackageDependenciesStore.java
new file mode 100644 (file)
index 0000000..1b7514a
--- /dev/null
@@ -0,0 +1,110 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.common;\r
+\r
+import jetbrains.buildServer.util.FileUtil;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import jetbrains.buildServer.util.XmlUtil;\r
+import org.jdom.Content;\r
+import org.jdom.Document;\r
+import org.jdom.Element;\r
+import org.jdom.JDOMException;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.*;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 19.07.11 11:39\r
+ */\r
+public class PackageDependenciesStore {\r
+\r
+  public PackageDependencies load(@NotNull final InputStream is) throws IOException {\r
+    Element element = null;\r
+    try {\r
+      element = FileUtil.parseDocument(is, false);\r
+    } catch (final JDOMException e) {\r
+      throw new IOException("Failed to parse stream." + e.getMessage()){{initCause(e);}};\r
+    }\r
+\r
+    final List<String> sources = new ArrayList<String>();\r
+    final List<PackageInfo> infos = new ArrayList<PackageInfo>();\r
+\r
+    Element packagesElement = element.getChild("packages");\r
+    if (packagesElement != null) {\r
+      for (Object pkg : packagesElement.getChildren("package")) {\r
+        Element el = (Element) pkg;\r
+        final String id = el.getAttributeValue("id");\r
+        final String version = el.getAttributeValue("version");\r
+        if (id != null && version != null) {\r
+          infos.add(new PackageInfo(id, version));\r
+        }\r
+      }\r
+    }\r
+\r
+    Element sourcesElement = element.getChild("sources");\r
+    if (sourcesElement != null) {\r
+      for (Object o : sourcesElement.getChildren("source")) {\r
+        Element source = (Element) o;\r
+        String text = source.getTextTrim();\r
+        if (!StringUtil.isEmptyOrSpaces(text)) {\r
+          sources.add(text);\r
+        }\r
+      }\r
+    }\r
+    return new PackageDependencies(sources, infos);\r
+  }\r
+\r
+  public PackageDependencies load(@NotNull final File file) throws IOException {\r
+    return load(new BufferedInputStream(new FileInputStream(file)));\r
+  }\r
+\r
+  public void save(@NotNull final PackageDependencies deps,\r
+                   @NotNull final File file) throws IOException {\r
+    Element root = new Element("nuget-dependencies");\r
+\r
+    Element pkgs = new Element("packages");\r
+    for (PackageInfo info : deps.getPackages()) {\r
+      Element pkg = new Element("package");\r
+      pkg.setAttribute("id", info.getId());\r
+      pkg.setAttribute("version", info.getVersion());\r
+      pkgs.addContent((Content) pkg);\r
+    }\r
+\r
+    root.addContent((Content) pkgs);\r
+\r
+    Element sources = new Element("sources");\r
+    for (String source : deps.getSources()) {\r
+      Element src = new Element("source");\r
+      src.setText(source);\r
+      sources.addContent((Content) src);\r
+    }\r
+\r
+    root.addContent((Content) sources);\r
+\r
+    Document doc = new Document(root);\r
+\r
+    OutputStream os = new BufferedOutputStream(new FileOutputStream(file));\r
+    try {\r
+      XmlUtil.saveDocument(doc, os);\r
+    } finally {\r
+      FileUtil.close(os);\r
+    }\r
+  }\r
+}\r
diff --git a/nuget-common/src/jetbrains/buildServer/nuget/common/PackageInfo.java b/nuget-common/src/jetbrains/buildServer/nuget/common/PackageInfo.java
new file mode 100644 (file)
index 0000000..a03dc30
--- /dev/null
@@ -0,0 +1,75 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.common;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 18.07.11 22:55\r
+ */\r
+public class PackageInfo implements Comparable<PackageInfo> {\r
+  private final String myId;\r
+  private final String myVersion;\r
+\r
+  public PackageInfo(@NotNull final String id,\r
+                     @NotNull final String version) {\r
+    myId = id;\r
+    myVersion = version;\r
+  }\r
+\r
+  public int compareTo(PackageInfo o) {\r
+    int x;\r
+    if ((x = getId().compareTo(o.getId())) != 0) return x;\r
+    if ((x = getVersion().compareTo(o.getVersion())) != 0) return x;\r
+    return 0;\r
+  }\r
+\r
+  @NotNull\r
+  public String getId() {\r
+    return myId;\r
+  }\r
+\r
+  @NotNull\r
+  public String getVersion() {\r
+    return myVersion;\r
+  }\r
+\r
+  @Override\r
+  public boolean equals(Object o) {\r
+    if (this == o) return true;\r
+    if (o == null || getClass() != o.getClass()) return false;\r
+\r
+    PackageInfo that = (PackageInfo) o;\r
+    return myId.equals(that.myId) && myVersion.equals(that.myVersion);\r
+  }\r
+\r
+  @Override\r
+  public int hashCode() {\r
+    int result = myId.hashCode();\r
+    result = 31 * result + myVersion.hashCode();\r
+    return result;\r
+  }\r
+\r
+  @Override\r
+  public String toString() {\r
+    return "PackageInfo{" +\r
+            "myId='" + myId + '\'' +\r
+            ", myVersion='" + myVersion + '\'' +\r
+            '}';\r
+  }\r
+}\r
index 404819d6d2e80f553aa7e6740a16d7b357c45604..29b929fb2dc8e6940a6b4c5eb407ebafce9a00be 100644 (file)
@@ -16,6 +16,8 @@
 \r
 package jetbrains.buildServer.nuget.common;\r
 \r
+import jetbrains.buildServer.ArtifactsConstants;\r
+\r
 /**\r
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 07.07.11 13:56\r
@@ -34,4 +36,7 @@ public interface PackagesConstants {
   public static final String NUGET_UPDATE_MODE = "nuget.updatePackages.mode";\r
 \r
   public static final String SLN_PATH = "sln.path";\r
+\r
+  public static final String NUGET_USED_PACKAGES_DIR = ArtifactsConstants.TEAMCITY_ARTIFACTS_DIR + "/nuget";\r
+  public static final String NUGET_USED_PACKAGES_FILE = "nuget.xml";\r
 }\r
diff --git a/nuget-server/resources/NuGetBuild.jsp b/nuget-server/resources/NuGetBuild.jsp
deleted file mode 100644 (file)
index 6cf7398..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<%@ taglib prefix="forms" tagdir="/WEB-INF/tags/forms" %>\r
-<%@ taglib prefix="props" tagdir="/WEB-INF/tags/props" %>\r
-<%@ taglib prefix="l" tagdir="/WEB-INF/tags/layout" %>\r
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>\r
-<jsp:useBean id="nugetPackages" scope="request" type="java.util.Map<java.lang.String, java.lang.String>"/>\r
-\r
-This is the list of all NuGet packages that were downloaded for the build.\r
-\r
-<table class="runnerFormTable" style="width:40em">\r
-  <thead>\r
-    <tr>\r
-      <th>Package Name</th>\r
-      <th>Package Version</th>\r
-    </tr>\r
-  </thead>\r
-<c:forEach var="it" items="${nugetPackages}">\r
-  <tr>\r
-    <td><a href="http://somewhere">${it.key}</a></td>\r
-    <td>${it.value}</td>\r
-  </tr>\r
-</c:forEach>\r
-</table>
\ No newline at end of file
diff --git a/nuget-server/resources/show/showPackages.jsp b/nuget-server/resources/show/showPackages.jsp
new file mode 100644 (file)
index 0000000..9b4dca7
--- /dev/null
@@ -0,0 +1,31 @@
+<%@ taglib prefix="forms" tagdir="/WEB-INF/tags/forms" %>\r
+<%@ taglib prefix="props" tagdir="/WEB-INF/tags/props" %>\r
+<%@ taglib prefix="l" tagdir="/WEB-INF/tags/layout" %>\r
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>\r
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>\r
+<jsp:useBean id="nugetPackages" scope="request" type="java.util.Map<java.lang.String, java.lang.String>"/>\r
+\r
+This is the list of all NuGet packages that were downloaded for the build.\r
+\r
+<c:choose>\r
+  <c:when test="${fn:length(nugetPackages) eq 0}">\r
+    No packages were reported\r
+  </c:when>\r
+  <c:otherwise>\r
+    <table class="runnerFormTable" style="width:40em">\r
+      <thead>\r
+      <tr>\r
+        <th>Package Name</th>\r
+        <th>Package Version</th>\r
+      </tr>\r
+      </thead>\r
+      <c:forEach var="it" items="${nugetPackages}">\r
+        <tr>\r
+          <td><c:out value="${it.key}"/></td>\r
+          <td><c:out value="${it.value}"/></td>\r
+        </tr>\r
+      </c:forEach>\r
+    </table>\r
+  </c:otherwise>\r
+</c:choose>\r
+\r
index a1ba186b065bb3e69ca5d14363bd48f89c0c72d7..741a391d65539402802cb163b616600cf5fc6625 100644 (file)
@@ -4,9 +4,10 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
        default-autowire="constructor">\r
 \r
+  <import resource="classpath*:META-INF/spring-nuget-common.xml"/>\r
 <!--\r
   <bean class="jetbrains.buildServer.nuget.server.NuGetPublishRunType"/>\r
-  <bean class="jetbrains.buildServer.nuget.server.NuGetDownloadedPackagesTab"/>\r
+  <bean class="jetbrains.buildServer.nuget.server.show.NuGetDownloadedPackagesTab"/>\r
   <bean class="jetbrains.buildServer.nuget.server.NuGetDownloadFeature"/>\r
 \r
 -->\r
@@ -22,4 +23,7 @@
   <bean class="jetbrains.buildServer.nuget.server.trigger.ThreadedBuildTriggetFactoryImpl"/>\r
   <bean class="jetbrains.buildServer.nuget.server.trigger.NamedPackagesUpdateChecker"/>\r
   <bean class="jetbrains.buildServer.nuget.server.trigger.NuGetSimpleTrigger"/>\r
+\r
+\r
+  <bean class="jetbrains.buildServer.nuget.server.show.NuGetDownloadedPackagesTab"/>\r
 </beans>
\ No newline at end of file
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/NuGetDownloadedPackagesTab.java b/nuget-server/src/jetbrains/buildServer/nuget/server/NuGetDownloadedPackagesTab.java
deleted file mode 100644 (file)
index aed2548..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-package jetbrains.buildServer.nuget.server;\r
-\r
-import java.util.Map;\r
-import java.util.TreeMap;\r
-import javax.servlet.http.HttpServletRequest;\r
-import jetbrains.buildServer.serverSide.SBuild;\r
-import jetbrains.buildServer.serverSide.SBuildServer;\r
-import jetbrains.buildServer.web.openapi.PagePlaces;\r
-import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
-import jetbrains.buildServer.web.openapi.ViewLogTab;\r
-import org.jetbrains.annotations.NotNull;\r
-import org.jetbrains.annotations.Nullable;\r
-\r
-/**\r
- * Created Eugene Petrenko (eugene.petrenko@gmail.com)\r
- * date: 28.04.11\r
- */\r
-public class NuGetDownloadedPackagesTab extends ViewLogTab {\r
-  public NuGetDownloadedPackagesTab(@NotNull final PagePlaces pagePlaces,\r
-                                    @NotNull final SBuildServer server,\r
-                                    @NotNull final PluginDescriptor descriptor) {\r
-    super("NuGet Packages", "xxx", pagePlaces, server);\r
-    setIncludeUrl(descriptor.getPluginResourcesPath("NuGetBuild.jsp"));\r
-    register();\r
-  }\r
-\r
-  @Override\r
-  public boolean isAvailable(@NotNull final HttpServletRequest request) {\r
-    final SBuild build = getBuild(request);\r
-    return super.isAvailable(request) && build != null && build.getParametersProvider().get("nuget.packages") != null;\r
-  }\r
-\r
-  @Override\r
-  protected void fillModel(final Map model, final HttpServletRequest request, @Nullable final SBuild build) {\r
-    final Map<String, String> packages = new TreeMap<String, String>();\r
-    packages.put("ELMAH", "1.2.0");\r
-    packages.put("Antlr", "4.0.0");\r
-    packages.put("EasyHTTP", "1.1");\r
-    packages.put("JsonFX", "2.0");\r
-    packages.put("structuremap", "2.6.2");\r
-    packages.put("Awsome", "1.5.0");\r
-\r
-    //noinspection unchecked\r
-    model.put("nugetPackages", packages);\r
-  }\r
-}\r
index f1a17a17a46caee92632f9a209b08a55730967bf..1b78079c145d6fea24a471f1e1ce70df62aa0a97 100644 (file)
@@ -28,7 +28,7 @@ import java.util.Collection;
  */\r
 public interface ListPackagesCommand {\r
   @NotNull\r
-  Collection<PackageInfo> checkForChanges(\r
+  Collection<SourcePackageInfo> checkForChanges(\r
           @NotNull File nugetPath,\r
           @Nullable String source,\r
           @NotNull String packageId,\r
index 4bffd6c5b5603037b62c9e4f9eb5a9aad95eb082..5e3b194d26d2cb69e91df7fa15e1f413c6fb9602 100644 (file)
@@ -37,7 +37,7 @@ public class ListPackagesCommandImpl implements ListPackagesCommand {
   }\r
 \r
   @NotNull\r
-  public Collection<PackageInfo> checkForChanges(\r
+  public Collection<SourcePackageInfo> checkForChanges(\r
           @NotNull final File nugetPath,\r
           @Nullable final String source,\r
           @NotNull final String packageId,\r
index 950027009330bca1ef705d7b69011f0266d3ac98..f32b1f53436f3b446305cdbaf53a88b215e435dd 100644 (file)
@@ -33,10 +33,10 @@ import java.util.List;
 * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
 * Date: 14.07.11 13:23\r
 */\r
-public class ListPackagesCommandProcessor implements NuGetOutputProcessor<Collection<PackageInfo>> {\r
+public class ListPackagesCommandProcessor implements NuGetOutputProcessor<Collection<SourcePackageInfo>> {\r
   private static final Logger LOG = Logger.getInstance(ListPackagesCommandProcessor.class.getName());\r
   private final String mySource;\r
-  private final List<PackageInfo> myPackages = new ArrayList<PackageInfo>();\r
+  private final List<SourcePackageInfo> myPackages = new ArrayList<SourcePackageInfo>();\r
 \r
   public ListPackagesCommandProcessor(@Nullable final String source) {\r
     mySource = source;\r
@@ -59,7 +59,7 @@ public class ListPackagesCommandProcessor implements NuGetOutputProcessor<Collec
         if (StringUtil.isEmptyOrSpaces(id)) return;\r
         if (StringUtil.isEmptyOrSpaces(version)) return;\r
 \r
-        myPackages.add(new PackageInfo(mySource, id, version));\r
+        myPackages.add(new SourcePackageInfo(mySource, id, version));\r
 \r
       }\r
 \r
@@ -84,7 +84,7 @@ public class ListPackagesCommandProcessor implements NuGetOutputProcessor<Collec
   }\r
 \r
   @NotNull\r
-  public Collection<PackageInfo> getResult() {\r
+  public Collection<SourcePackageInfo> getResult() {\r
     return Collections.unmodifiableList(myPackages);\r
   }\r
 }\r
similarity index 89%
rename from nuget-server/src/jetbrains/buildServer/nuget/server/exec/PackageInfo.java
rename to nuget-server/src/jetbrains/buildServer/nuget/server/exec/SourcePackageInfo.java
index 0b318ff1d69df0d856f0331c70817e6ef2bd6917..5ab83963b15f38a384c2b1f9a007c7fa1f9d77d7 100644 (file)
@@ -23,12 +23,13 @@ import org.jetbrains.annotations.Nullable;
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
  * Date: 14.07.11 13:17\r
  */\r
-public class PackageInfo {\r
+public class SourcePackageInfo {\r
   private final String mySource;\r
   private final String myPackageId;\r
   private final String myVersion;\r
 \r
-  public PackageInfo(@Nullable final String source,\r
+
+  public SourcePackageInfo(@Nullable final String source,\r
                            @NotNull final String packageId,\r
                            @NotNull final String version) {\r
     mySource = source;\r
@@ -53,7 +54,7 @@ public class PackageInfo {
 \r
   @Override\r
   public String toString() {\r
-    return "PackageInfo{" +\r
+    return "SourcePackageInfo{" +\r
             "mySource='" + mySource + '\'' +\r
             ", myPackageId='" + myPackageId + '\'' +\r
             ", myVersion='" + myVersion + '\'' +\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/show/NuGetDownloadedPackagesTab.java b/nuget-server/src/jetbrains/buildServer/nuget/server/show/NuGetDownloadedPackagesTab.java
new file mode 100644 (file)
index 0000000..b2a98e3
--- /dev/null
@@ -0,0 +1,96 @@
+package jetbrains.buildServer.nuget.server.show;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.nuget.common.PackageDependencies;\r
+import jetbrains.buildServer.nuget.common.PackageDependenciesStore;\r
+import jetbrains.buildServer.nuget.common.PackageInfo;\r
+import jetbrains.buildServer.serverSide.SBuild;\r
+import jetbrains.buildServer.serverSide.SBuildServer;\r
+import jetbrains.buildServer.serverSide.artifacts.BuildArtifact;\r
+import jetbrains.buildServer.serverSide.artifacts.BuildArtifactsViewMode;\r
+import jetbrains.buildServer.util.FileUtil;\r
+import jetbrains.buildServer.web.openapi.PagePlaces;\r
+import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
+import jetbrains.buildServer.web.openapi.ViewLogTab;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_USED_PACKAGES_DIR;\r
+import static jetbrains.buildServer.nuget.common.PackagesConstants.NUGET_USED_PACKAGES_FILE;\r
+\r
+/**\r
+ * Created Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * date: 28.04.11\r
+ */\r
+public class NuGetDownloadedPackagesTab extends ViewLogTab {\r
+  private static final String DEPS_FILE = NUGET_USED_PACKAGES_DIR + "/" + NUGET_USED_PACKAGES_FILE;\r
+  private static final Logger LOG = Logger.getInstance(NuGetDownloadedPackagesTab.class.getName());\r
+\r
+\r
+  private final PackageDependenciesStore myStore;\r
+\r
+  public NuGetDownloadedPackagesTab(@NotNull final PagePlaces pagePlaces,\r
+                                    @NotNull final SBuildServer server,\r
+                                    @NotNull final PluginDescriptor descriptor,\r
+                                    @NotNull final PackageDependenciesStore store) {\r
+    super("NuGet Packages", "nugetPackagesBuildTab", pagePlaces, server);\r
+    myStore = store;\r
+    setIncludeUrl(descriptor.getPluginResourcesPath("show/showPackages.jsp"));\r
+    register();\r
+  }\r
+\r
+  @Override\r
+  public boolean isAvailable(@NotNull final HttpServletRequest request) {\r
+    final SBuild build = getBuild(request);\r
+    return super.isAvailable(request) && getPackagesFile(build) != null;\r
+  }\r
+\r
+  @Nullable\r
+  private BuildArtifact getPackagesFile(@Nullable final SBuild build) {\r
+    if (build == null) return null;\r
+    BuildArtifact file = build.getArtifacts(BuildArtifactsViewMode.VIEW_ALL).getArtifact(DEPS_FILE);\r
+    if (file == null) return null;\r
+    if (file.isDirectory()) return null;\r
+    return file;\r
+  }\r
+\r
+\r
+  @Override\r
+  protected void fillModel(final Map model, final HttpServletRequest request, @Nullable final SBuild build) {\r
+    final Map<String, String> packages = new TreeMap<String, String>();\r
+    //noinspection unchecked\r
+    model.put("nugetPackages", packages);\r
+\r
+    if (build == null) return;\r
+    PackageDependencies deps = loadDependencies(build);\r
+\r
+    if (deps != null) {\r
+      for (PackageInfo info : deps.getPackages()) {\r
+        packages.put(info.getId(), info.getVersion());\r
+      }\r
+    }\r
+  }\r
+\r
+  @Nullable\r
+  private PackageDependencies loadDependencies(@NotNull final SBuild build) {\r
+    final BuildArtifact file = getPackagesFile(build);\r
+    if (file != null) {\r
+      InputStream inputStream = null;\r
+      try {\r
+        inputStream = file.getInputStream();\r
+        return myStore.load(inputStream);\r
+      } catch (IOException e) {\r
+        LOG.warn("Failed to read used packages build artifacts of build id=" + build.getBuildId());\r
+      } finally {\r
+        FileUtil.close(inputStream);\r
+      }\r
+    }\r
+    return null;\r
+  }\r
+}\r
index 85bad5aba13bfea2e6945baec7c29910c567902a..ffbdfe6139b1ea31d5e74705cd17acce04136875 100644 (file)
@@ -3,7 +3,7 @@ package jetbrains.buildServer.nuget.server.trigger;
 import jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor;\r
 import jetbrains.buildServer.buildTriggers.BuildTriggerException;\r
 import jetbrains.buildServer.nuget.server.exec.ListPackagesCommand;\r
-import jetbrains.buildServer.nuget.server.exec.PackageInfo;\r
+import jetbrains.buildServer.nuget.server.exec.SourcePackageInfo;\r
 import jetbrains.buildServer.serverSide.CustomDataStorage;\r
 import jetbrains.buildServer.util.StringUtil;\r
 import org.jetbrains.annotations.NotNull;\r
@@ -43,7 +43,7 @@ public class NamedPackagesUpdateChecker implements TriggerUpdateChecker {
       throw new BuildTriggerException("Failed to find NuGet.exe at: " + nugetPath);\r
     }\r
 \r
-    Collection<PackageInfo> result;\r
+    Collection<SourcePackageInfo> result;\r
     try {\r
       result = myCommand.checkForChanges(nugetPath, source, pkgId, version);\r
     } catch (Throwable t) {\r
@@ -61,10 +61,10 @@ public class NamedPackagesUpdateChecker implements TriggerUpdateChecker {
     return null;\r
   }\r
 \r
-  private String serializeHashcode(@NotNull final Collection<PackageInfo> _packages) {\r
-    List<PackageInfo> sorted = new ArrayList<PackageInfo>(_packages);\r
-    Collections.sort(sorted, new Comparator<PackageInfo>() {\r
-      public int compare(PackageInfo o1, PackageInfo o2) {\r
+  private String serializeHashcode(@NotNull final Collection<SourcePackageInfo> _packages) {\r
+    List<SourcePackageInfo> sorted = new ArrayList<SourcePackageInfo>(_packages);\r
+    Collections.sort(sorted, new Comparator<SourcePackageInfo>() {\r
+      public int compare(SourcePackageInfo o1, SourcePackageInfo o2) {\r
         int i;\r
         String s1 = o1.getSource();\r
         String s2 = o2.getSource();\r
@@ -76,7 +76,7 @@ public class NamedPackagesUpdateChecker implements TriggerUpdateChecker {
     });\r
 \r
     StringBuilder sb = new StringBuilder();\r
-    for (PackageInfo info : sorted) {\r
+    for (SourcePackageInfo info : sorted) {\r
       String source = info.getSource();\r
       if (source != null) {\r
         sb.append("|s:").append(source);\r
index c29e0b1f30f8838d0809ab5a03f8a5585f944682..ae8d70e575fb0629ae7cf6e57781e60a3ae5a8cd 100644 (file)
@@ -2,8 +2,8 @@
 <teamcity-plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
                  xsi:noNamespaceSchemaLocation="urn:shemas-jetbrains-com:teamcity-plugin-v1-xml">\r
   <info>\r
-    <name>dotNetPackageManagers</name>\r
-    <display-name>.NET Package managers support (i.e. NuGet or openwrap)</display-name>\r
+    <name>nuget</name>\r
+    <display-name>Provides support for NuGet package manager</display-name>\r
     <version>@Plugin_Version@</version>\r
     <vendor>\r
       <name>@Plugin_Vendor@</name>\r
index 7eaf04787c83089d3fe7c21e0c34c05164fa9124..86b8c059d4dc67bf1cdc09c37521521e28e3e20d 100644 (file)
@@ -19,6 +19,7 @@ package jetbrains.buildServer.nuget.tests.agent;
 import jetbrains.buildServer.BaseTestCase;\r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
+import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetActionFactoryImpl;\r
@@ -53,7 +54,8 @@ public class NuGetInstallPackageActionFactoryTest extends BaseTestCase {
     super.setUp();\r
     m = new Mockery();\r
     myProcessFactory = m.mock(CommandlineBuildProcessFactory.class);\r
-    i = new NuGetActionFactoryImpl(myProcessFactory);\r
+    PackageUsages pu = m.mock(PackageUsages.class);\r
+    i = new NuGetActionFactoryImpl(myProcessFactory, pu);\r
     ctx = m.mock(BuildRunnerContext.class);\r
     ps = m.mock(PackagesInstallParameters.class);\r
     nugetParams = m.mock(NuGetParameters.class);\r
diff --git a/nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPackagesConfigParserTest.java b/nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/NuGetPackagesConfigParserTest.java
new file mode 100644 (file)
index 0000000..036d789
--- /dev/null
@@ -0,0 +1,78 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.tests.agent;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.nuget.common.PackageInfo;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser;\r
+import jetbrains.buildServer.nuget.tests.integration.Paths;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.testng.Assert;\r
+import org.testng.annotations.Test;\r
+\r
+import java.io.IOException;\r
+import java.util.Arrays;\r
+import java.util.TreeSet;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 19.07.11 2:01\r
+ */\r
+public class NuGetPackagesConfigParserTest extends BaseTestCase {\r
+\r
+  @Test\r
+  public void test_01() throws IOException {\r
+    doTest("test-01.xml", new PackageInfo("elmah", "1.1"));\r
+  }\r
+\r
+  @Test\r
+  public void test_02() throws IOException {\r
+    doTest("test-02.xml", new PackageInfo("elmah", "1.1"));\r
+  }\r
+\r
+  @Test\r
+  public void test_03() throws IOException {\r
+    doTest("test-03.xml",\r
+            new PackageInfo("Machine.Specifications", "0.4.13.0"),\r
+            new PackageInfo("NUnit", "2.5.7.10213")\r
+            )    ;\r
+  }\r
+\r
+  @Test\r
+  public void test_04() throws IOException {\r
+    doTest("test-04.xml",\r
+            new PackageInfo("EasyHttp", "1.0.6"),\r
+            new PackageInfo("JsonFx", "2.0.1106.2610"),\r
+            new PackageInfo("structuremap", "2.6.2"));\r
+  }\r
+\r
+  public void doTest(@NotNull String testData,\r
+                     @NotNull PackageInfo... packages) throws IOException {\r
+    NuGetPackagesConfigParser p = new NuGetPackagesConfigParser();\r
+    NuGetPackagesCollectorImpl i = new NuGetPackagesCollectorImpl();\r
+    p.parseNuGetPackages(Paths.getTestDataPath("config/" + testData), i);\r
+\r
+    if (packages.length != i.getPackages().getPackages().size()) {\r
+      System.out.println(i.getPackages());\r
+    }\r
+\r
+    Assert.assertEquals(\r
+            new TreeSet<PackageInfo>(i.getPackages().getPackages()),\r
+            new TreeSet<PackageInfo>(Arrays.asList(packages)));\r
+  }\r
+}\r
index 022d936a047281aefa648a7cb7827446ace33d56..2131a6abb4e744240eae9f547f249f8dd41e7950 100644 (file)
@@ -19,6 +19,7 @@ package jetbrains.buildServer.nuget.tests.agent;
 import jetbrains.buildServer.BaseTestCase;\r
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
+import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetActionFactoryImpl;\r
@@ -53,7 +54,8 @@ public class NuGetUpdatePackageActionFactoryTest extends BaseTestCase {
     super.setUp();\r
     m = new Mockery();\r
     myProcessFactory = m.mock(CommandlineBuildProcessFactory.class);\r
-    i = new NuGetActionFactoryImpl(myProcessFactory);\r
+    PackageUsages pu = m.mock(PackageUsages.class);\r
+    i = new NuGetActionFactoryImpl(myProcessFactory, pu);\r
     ctx = m.mock(BuildRunnerContext.class);\r
     ps = m.mock(PackagesUpdateParameters.class);\r
     nugetParams = m.mock(NuGetParameters.class);\r
index c063287e59703bdc6ed6441495c742d5fefb0ef4..233b621d1b79fb8ca410f2a32f618082504a2b54 100644 (file)
@@ -21,7 +21,8 @@ import jetbrains.buildServer.RunBuildException;
 import jetbrains.buildServer.agent.BuildProcess;\r
 import jetbrains.buildServer.agent.BuildRunnerContext;\r
 import jetbrains.buildServer.nuget.agent.install.NuGetActionFactory;\r
-import jetbrains.buildServer.nuget.agent.install.PackagesInstallerBuilder;\r
+import jetbrains.buildServer.nuget.agent.install.impl.InstallStages;\r
+import jetbrains.buildServer.nuget.agent.install.impl.PackagesInstallerBuilder;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
@@ -46,6 +47,7 @@ public class PackagesInstallerBuilderTest extends BaseTestCase {
   private BuildProcessContinuation install;\r
   private BuildProcessContinuation update;\r
   private BuildProcessContinuation postUpdate;\r
+  private BuildProcessContinuation report;\r
   private BuildRunnerContext context;\r
   private NuGetParameters nugetSettings;\r
   private PackagesInstallParameters installParameters;\r
@@ -71,25 +73,39 @@ public class PackagesInstallerBuilderTest extends BaseTestCase {
     install = m.mock(BuildProcessContinuation.class, "install");\r
     update = m.mock(BuildProcessContinuation.class, "update");\r
     postUpdate = m.mock(BuildProcessContinuation.class, "post-install");\r
+    report = m.mock(BuildProcessContinuation.class, "report");\r
     context = m.mock(BuildRunnerContext.class);\r
     installParameters = m.mock(PackagesInstallParameters.class);\r
     updateParameters = m.mock(PackagesUpdateParameters.class);\r
     nugetSettings = m.mock(NuGetParameters.class);\r
 \r
+    final InstallStages is = m.mock(InstallStages.class);\r
+    final BuildProcess reportProcess = m.mock(BuildProcess.class, "report process");\r
+    m.checking(new Expectations(){{\r
+      allowing(is).getInstallStage(); will(returnValue(install));\r
+      allowing(is).getUpdateStage(); will(returnValue(update));\r
+      allowing(is).getPostUpdateStart(); will(returnValue(postUpdate));\r
+      allowing(is).getReportStage(); will(returnValue(report));\r
+\r
+      allowing(factory).createUsageReport(context, nugetSettings, myConfig, myTaget);\r
+      will(returnValue(reportProcess));\r
+      allowing(factory).createUsageReport(context, nugetSettings, myConfig2, myTaget);\r
+      will(returnValue(reportProcess));\r
+\r
+      allowing(report).pushBuildProcess(reportProcess);\r
+    }});\r
+\r
     builderUpdate = new PackagesInstallerBuilder(\r
             factory,\r
-            install,\r
-            update,\r
-            postUpdate,\r
+            is,\r
             context,\r
             installParameters,\r
-            updateParameters);\r
+            updateParameters\r
+            );\r
 \r
     builderInstall = new PackagesInstallerBuilder(\r
             factory,\r
-            install,\r
-            update,\r
-            postUpdate,\r
+            is,\r
             context,\r
             installParameters,\r
             null);\r
@@ -102,7 +118,7 @@ public class PackagesInstallerBuilderTest extends BaseTestCase {
 \r
   @Test\r
   public void test_install() throws RunBuildException {\r
-    final BuildProcess bp = m.mock(BuildProcess.class);\r
+    final BuildProcess bp = m.mock(BuildProcess.class, "bp");\r
     m.checking(new Expectations(){{\r
       oneOf(factory).createInstall(context, installParameters, myConfig, myTaget);\r
       will(returnValue(bp));\r
diff --git a/nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/PackagesWatcherTest.java b/nuget-tests/src/jetbrains/buildServer/nuget/tests/agent/PackagesWatcherTest.java
new file mode 100644 (file)
index 0000000..b98a740
--- /dev/null
@@ -0,0 +1,122 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.tests.agent;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.agent.AgentLifeCycleListener;\r
+import jetbrains.buildServer.agent.AgentRunningBuild;\r
+import jetbrains.buildServer.agent.BuildFinishedStatus;\r
+import jetbrains.buildServer.agent.BuildRunnerContext;\r
+import jetbrains.buildServer.agent.artifacts.ArtifactsWatcher;\r
+import jetbrains.buildServer.nuget.agent.install.NuGetPackagesCollector;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;\r
+import jetbrains.buildServer.nuget.agent.install.impl.PackagesInfoUploader;\r
+import jetbrains.buildServer.nuget.agent.install.impl.PackagesWatcher;\r
+import jetbrains.buildServer.nuget.common.PackageDependenciesStore;\r
+import jetbrains.buildServer.util.EventDispatcher;\r
+import org.hamcrest.BaseMatcher;\r
+import org.hamcrest.Description;\r
+import org.jmock.Expectations;\r
+import org.jmock.Mockery;\r
+import org.testng.Assert;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 19.07.11 14:10\r
+ */\r
+public class PackagesWatcherTest extends BaseTestCase {\r
+  private Mockery m;\r
+  private ArtifactsWatcher watcher;\r
+  private NuGetPackagesCollector collector;\r
+  private AgentLifeCycleListener multicaster;\r
+  private AgentRunningBuild build;\r
+\r
+  @BeforeMethod\r
+  @Override\r
+  protected void setUp() throws Exception {\r
+    super.setUp();\r
+    m = new Mockery();\r
+    watcher = m.mock(ArtifactsWatcher.class);\r
+    build = m.mock(AgentRunningBuild.class);\r
+\r
+    final EventDispatcher<AgentLifeCycleListener> events = EventDispatcher.create(AgentLifeCycleListener.class);\r
+    multicaster = events.getMulticaster();\r
+\r
+    final NuGetPackagesCollectorImpl nuGetPackagesCollector = new NuGetPackagesCollectorImpl();\r
+    collector = nuGetPackagesCollector;\r
+\r
+    new PackagesWatcher(\r
+            events,\r
+            nuGetPackagesCollector,\r
+            new PackagesInfoUploader(watcher, new PackageDependenciesStore())\r
+    );\r
+  }\r
+\r
+  @Test\r
+  public void test_upload_packages_in_before_build_finish_no_packages() {\r
+    multicaster.beforeBuildFinish(build, BuildFinishedStatus.FINISHED_FAILED);\r
+\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_upload_packages_in_before_build_finish_with_packages() throws IOException {\r
+    final File tempDir = createTempDir();\r
+    m.checking(new Expectations(){{\r
+      allowing(build).getBuildTempDirectory();  will(returnValue(tempDir));\r
+      oneOf(watcher).addNewArtifactsPath(with(new NuGetUploadPathMatcher(tempDir)));\r
+    }});\r
+\r
+    collector.addPackage("aaa", "1.2.4", null);\r
+    multicaster.beforeBuildFinish(build, BuildFinishedStatus.FINISHED_FAILED);\r
+\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  @Test\r
+  public void test_clean_packages_on_build_start() {\r
+    collector.addPackage("aaa", "bbb", null);\r
+    multicaster.buildStarted(build);\r
+\r
+    Assert.assertTrue(collector.getPackages().isEmpty());\r
+\r
+    m.assertIsSatisfied();\r
+  }\r
+\r
+  private static class NuGetUploadPathMatcher extends BaseMatcher<String> {\r
+    private final File myTempDir;\r
+\r
+    public NuGetUploadPathMatcher(File tempDir) {\r
+      myTempDir = tempDir;\r
+    }\r
+\r
+    public boolean matches(Object o) {\r
+      String path = ((String) o).trim();\r
+      if (!path.startsWith(myTempDir.getPath())) return false;\r
+      return (path.endsWith("/nuget.xml => .teamcity/nuget")\r
+              || path.endsWith("\\nuget.xml => .teamcity/nuget"));\r
+    }\r
+\r
+    public void describeTo(Description description) {\r
+    }\r
+  }\r
+}\r
diff --git a/nuget-tests/src/jetbrains/buildServer/nuget/tests/common/PackageDependenciesStoreTest.java b/nuget-tests/src/jetbrains/buildServer/nuget/tests/common/PackageDependenciesStoreTest.java
new file mode 100644 (file)
index 0000000..42a9d81
--- /dev/null
@@ -0,0 +1,85 @@
+/*\r
+ * Copyright 2000-2011 JetBrains s.r.o.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package jetbrains.buildServer.nuget.tests.common;\r
+\r
+import jetbrains.buildServer.BaseTestCase;\r
+import jetbrains.buildServer.nuget.common.PackageDependencies;\r
+import jetbrains.buildServer.nuget.common.PackageDependenciesStore;\r
+import jetbrains.buildServer.nuget.common.PackageInfo;\r
+import org.testng.Assert;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.Arrays;\r
+import java.util.TreeSet;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 19.07.11 13:24\r
+ */\r
+public class PackageDependenciesStoreTest extends BaseTestCase {\r
+  private PackageDependenciesStore store;\r
+\r
+  @BeforeMethod\r
+  @Override\r
+  protected void setUp() throws Exception {\r
+    store = new PackageDependenciesStore();\r
+  }\r
+\r
+  @Test\r
+  public void test_load() throws IOException {\r
+    File temp = createTempFile("<nuget-dependencies>\n" +\r
+            "  <packages>\n" +\r
+            "    <package id=\"id1\" version=\"v1\" />\n" +\r
+            "    <package id=\"id2\" version=\"v2\" />\n" +\r
+            "  </packages>\n" +\r
+            "  <sources>\n" +\r
+            "    <source>source1</source>\n" +\r
+            "    <source>source2</source>\n" +\r
+            "  </sources>\n" +\r
+            "</nuget-dependencies>");\r
+\r
+    PackageDependencies deps = new PackageDependencies(Arrays.asList("source1", "source2"),\r
+            Arrays.asList(new PackageInfo("id1", "v1"), new PackageInfo("id2", "v2")));\r
+\r
+    PackageDependencies load = store.load(temp);\r
+    assertEquals(deps, load);\r
+  }\r
+\r
+\r
+  @Test\r
+  public void test_saveLoad() throws IOException {\r
+    final File tmp = createTempFile();\r
+\r
+    PackageDependencies deps = new PackageDependencies(Arrays.asList("source1", "source2"),\r
+            Arrays.asList(new PackageInfo("id1", "v1"), new PackageInfo("id2", "v2")));\r
+    store.save(deps, tmp);\r
+\r
+    dumpFile(tmp);\r
+\r
+    PackageDependencies load = store.load(tmp);\r
+\r
+    assertEquals(deps, load);\r
+  }\r
+\r
+  private void assertEquals(PackageDependencies deps, PackageDependencies load) {\r
+    Assert.assertEquals(new TreeSet<String>(load.getSources()), new TreeSet<String>(deps.getSources()));\r
+    Assert.assertEquals(new TreeSet<PackageInfo>(load.getPackages()), new TreeSet<PackageInfo>(deps.getPackages()));\r
+  }\r
+}\r
index 489a5a45b65c479dd4dd4d288a25569ff5adcfcb..510a30b9ceccc7d03c3c0e71f72a19ea5c99a940 100644 (file)
@@ -21,29 +21,32 @@ import jetbrains.buildServer.ExecResult;
 import jetbrains.buildServer.RunBuildException;\r
 import jetbrains.buildServer.SimpleCommandLineProcessRunner;\r
 import jetbrains.buildServer.agent.*;\r
+import jetbrains.buildServer.nuget.agent.install.PackageUsages;\r
 import jetbrains.buildServer.nuget.agent.install.PackagesInstallerRunner;\r
 import jetbrains.buildServer.nuget.agent.install.impl.NuGetActionFactoryImpl;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesCollectorImpl;\r
+import jetbrains.buildServer.nuget.agent.install.impl.NuGetPackagesConfigParser;\r
+import jetbrains.buildServer.nuget.agent.install.impl.PackageUsagesImpl;\r
 import jetbrains.buildServer.nuget.agent.parameters.NuGetParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesInstallParameters;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesParametersFactory;\r
 import jetbrains.buildServer.nuget.agent.parameters.PackagesUpdateParameters;\r
 import jetbrains.buildServer.nuget.agent.util.BuildProcessBase;\r
 import jetbrains.buildServer.nuget.agent.util.CommandlineBuildProcessFactory;\r
+import jetbrains.buildServer.nuget.common.PackageInfo;\r
 import jetbrains.buildServer.nuget.common.PackagesUpdateMode;\r
 import jetbrains.buildServer.nuget.tests.util.BuildProcessTestCase;\r
 import jetbrains.buildServer.util.ArchiveUtil;\r
-import junit.framework.Assert;\r
 import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
 import org.jmock.Expectations;\r
 import org.jmock.Mockery;\r
+import org.testng.Assert;\r
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
 import java.io.File;\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.List;\r
+import java.util.*;\r
 \r
 /**\r
  * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
@@ -77,27 +80,38 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
     myNuGet = m.mock(NuGetParameters.class);\r
 \r
     m.checking(new Expectations() {{\r
-      allowing(myContext).getBuild();  will(returnValue(myBuild));\r
-      allowing(myBuild).getBuildLogger(); will(returnValue(myLogger));\r
-      allowing(myBuild).getCheckoutDirectory(); will(returnValue(myRoot));\r
+      allowing(myContext).getBuild();\r
+      will(returnValue(myBuild));\r
+      allowing(myBuild).getBuildLogger();\r
+      will(returnValue(myLogger));\r
+      allowing(myBuild).getCheckoutDirectory();\r
+      will(returnValue(myRoot));\r
 \r
       allowing(myMockProcess).start();\r
-      allowing(myMockProcess).waitFor(); will(returnValue(BuildFinishedStatus.FINISHED_SUCCESS));\r
+      allowing(myMockProcess).waitFor();\r
+      will(returnValue(BuildFinishedStatus.FINISHED_SUCCESS));\r
 \r
       allowing(myLogger).message(with(any(String.class)));\r
       allowing(myLogger).activityStarted(with(equal("install")), with(any(String.class)), with(any(String.class)));\r
       allowing(myLogger).activityFinished(with(equal("install")), with(any(String.class)));\r
 \r
-      allowing(myInstall).getNuGetParameters(); will(returnValue(myNuGet));\r
-      allowing(myUpdate).getNuGetParameters(); will(returnValue(myNuGet));\r
+      allowing(myInstall).getNuGetParameters();\r
+      will(returnValue(myNuGet));\r
+      allowing(myUpdate).getNuGetParameters();\r
+      will(returnValue(myNuGet));\r
     }});\r
   }\r
 \r
   @Test\r
   public void test_01_online_sources() throws RunBuildException {\r
-    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+    ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
 \r
-    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, false);\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, false,\r
+            Arrays.asList(\r
+                    new PackageInfo("Machine.Specifications", "0.4.13.0"),\r
+                    new PackageInfo("NUnit", "2.5.7.10213"),\r
+                    new PackageInfo("Ninject", "2.2.1.4"))\r
+    );\r
 \r
     List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
     System.out.println("installed packageses = " + packageses);\r
@@ -108,11 +122,16 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
     Assert.assertEquals(4, packageses.size());\r
   }\r
 \r
+  @NotNull\r
+  private File getTestDataPath() {\r
+    return Paths.getTestDataPath("integration/test-01.zip");\r
+  }\r
+\r
   @Test\r
-  public void test_01_online_sources_update() throws RunBuildException {\r
-    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+  public void test_01_online_sources_update_forConfig() throws RunBuildException {\r
+    ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
 \r
-    m.checking(new Expectations(){{\r
+    m.checking(new Expectations() {{\r
       allowing(myLogger).activityStarted(with(equal("update")), with(any(String.class)), with(equal("nuget")));\r
       allowing(myLogger).activityFinished(with(equal("update")), with(equal("nuget")));\r
 \r
@@ -121,7 +140,7 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
       allowing(myUpdate).getUpdateMode(); will(returnValue(PackagesUpdateMode.FOR_EACH_PACKAGES_CONFIG));\r
     }});\r
 \r
-    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true);\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true, null);\r
 \r
 \r
     List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
@@ -136,18 +155,21 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
 \r
   @Test\r
   public void test_01_online_sources_update_forSln() throws RunBuildException {\r
-    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+    ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
 \r
-    m.checking(new Expectations(){{\r
+    m.checking(new Expectations() {{\r
       allowing(myLogger).activityStarted(with(equal("update")), with(any(String.class)), with(equal("nuget")));\r
       allowing(myLogger).activityFinished(with(equal("update")), with(equal("nuget")));\r
 \r
-      allowing(myUpdate).getUseSafeUpdate(); will(returnValue(false));\r
-      allowing(myUpdate).getPackagesToUpdate(); will(returnValue(Collections.<String>emptyList()));\r
-      allowing(myUpdate).getUpdateMode(); will(returnValue(PackagesUpdateMode.FOR_SLN));\r
+      allowing(myUpdate).getUseSafeUpdate();\r
+      will(returnValue(false));\r
+      allowing(myUpdate).getPackagesToUpdate();\r
+      will(returnValue(Collections.<String>emptyList()));\r
+      allowing(myUpdate).getUpdateMode();\r
+      will(returnValue(PackagesUpdateMode.FOR_SLN));\r
     }});\r
 \r
-    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true);\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true, null);\r
 \r
 \r
     List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
@@ -162,18 +184,21 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
 \r
   @Test\r
   public void test_01_online_sources_update_safe() throws RunBuildException {\r
-    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+    ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
 \r
-    m.checking(new Expectations(){{\r
+    m.checking(new Expectations() {{\r
       allowing(myLogger).activityStarted(with(equal("update")), with(any(String.class)), with(equal("nuget")));\r
       allowing(myLogger).activityFinished(with(equal("update")), with(equal("nuget")));\r
 \r
-      allowing(myUpdate).getUseSafeUpdate(); will(returnValue(true));\r
-      allowing(myUpdate).getPackagesToUpdate(); will(returnValue(Collections.<String>emptyList()));\r
-      allowing(myUpdate).getUpdateMode(); will(returnValue(PackagesUpdateMode.FOR_EACH_PACKAGES_CONFIG));\r
+      allowing(myUpdate).getUseSafeUpdate();\r
+      will(returnValue(true));\r
+      allowing(myUpdate).getPackagesToUpdate();\r
+      will(returnValue(Collections.<String>emptyList()));\r
+      allowing(myUpdate).getUpdateMode();\r
+      will(returnValue(PackagesUpdateMode.FOR_EACH_PACKAGES_CONFIG));\r
     }});\r
 \r
-    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true);\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), false, true, null);\r
 \r
 \r
     List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
@@ -188,9 +213,13 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
 \r
   @Test\r
   public void test_01_online_sources_ecludeVersion() throws RunBuildException {\r
-    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+    ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
 \r
-    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), true, false);\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Collections.<String>emptyList(), true, false,\r
+            Arrays.asList(\r
+                    new PackageInfo("Machine.Specifications", "0.4.13.0"),\r
+                    new PackageInfo("NUnit", "2.5.7.10213"),\r
+                    new PackageInfo("Ninject", "2.2.1.4")));\r
 \r
     List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
     System.out.println("installed packageses = " + packageses);\r
@@ -203,11 +232,11 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
 \r
   @Test(enabled = false, dependsOnGroups = "Need to understand how to check NuGet uses only specified sources")\r
   public void test_01_local_sources() throws RunBuildException {\r
-    ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01.zip"), "", myRoot);\r
+    ArchiveUtil.unpackZip(getTestDataPath(), "", myRoot);\r
     File sourcesDir = new File(myRoot, "js");\r
     ArchiveUtil.unpackZip(Paths.getTestDataPath("test-01-sources.zip"), "", sourcesDir);\r
 \r
-    fetchPackages(new File(myRoot, "sln1-lib.sln"), Arrays.asList("file:///" + sourcesDir.getPath()), false, false);\r
+    fetchPackages(new File(myRoot, "sln1-lib.sln"), Arrays.asList("file:///" + sourcesDir.getPath()), false, false, null);\r
 \r
     List<File> packageses = Arrays.asList(new File(myRoot, "packages").listFiles());\r
     System.out.println("installed packageses = " + packageses);\r
@@ -221,26 +250,47 @@ public class InstallPackageIntegtatoinTest extends BuildProcessTestCase {
   private void fetchPackages(final File sln,\r
                              final List<String> sources,\r
                              final boolean excludeVersion,\r
-                             final boolean update) throws RunBuildException {\r
+                             final boolean update,\r
+                             @Nullable Collection<PackageInfo> detectedPackages) throws RunBuildException {\r
+\r
     m.checking(new Expectations() {{\r
-      allowing(myParametersFactory).loadNuGetParameters(myContext);  will(returnValue(myNuGet));\r
-      allowing(myParametersFactory).loadInstallPackagesParameters(myContext, myNuGet);  will(returnValue(myInstall));\r
+      allowing(myParametersFactory).loadNuGetParameters(myContext);\r
+      will(returnValue(myNuGet));\r
+      allowing(myParametersFactory).loadInstallPackagesParameters(myContext, myNuGet);\r
+      will(returnValue(myInstall));\r
 \r
       allowing(myNuGet).getNuGetExeFile();\r
       will(returnValue(Paths.getPathToNuGet()));\r
-      allowing(myNuGet).getSolutionFile(); will(returnValue(sln));\r
-      allowing(myNuGet).getNuGetPackageSources(); will(returnValue(sources));\r
-      allowing(myInstall).getExcludeVersion(); will(returnValue(excludeVersion));\r
-      allowing(myParametersFactory).loadUpdatePackagesParameters(myContext, myNuGet);  will(returnValue(update ? myUpdate : null));\r
+      allowing(myNuGet).getSolutionFile();\r
+      will(returnValue(sln));\r
+      allowing(myNuGet).getNuGetPackageSources();\r
+      will(returnValue(sources));\r
+      allowing(myInstall).getExcludeVersion();\r
+      will(returnValue(excludeVersion));\r
+      allowing(myParametersFactory).loadUpdatePackagesParameters(myContext, myNuGet);\r
+      will(returnValue(update ? myUpdate : null));\r
     }});\r
 \r
+    NuGetPackagesCollectorImpl collector = new NuGetPackagesCollectorImpl();\r
+    PackageUsages pu = new PackageUsagesImpl(\r
+            collector,\r
+            new NuGetPackagesConfigParser()\r
+    );\r
+\r
     BuildProcess proc = new PackagesInstallerRunner(\r
-            new NuGetActionFactoryImpl(executingFactory()),\r
+            new NuGetActionFactoryImpl(executingFactory(), pu),\r
             myParametersFactory\r
     ).createBuildProcess(myBuild, myContext);\r
 \r
     assertRunSuccessfully(proc, BuildFinishedStatus.FINISHED_SUCCESS);\r
 \r
+    System.out.println(collector.getPackages());\r
+    if (detectedPackages != null) {\r
+      Assert.assertEquals(\r
+              new TreeSet<PackageInfo>(collector.getPackages().getPackages()),\r
+              new TreeSet<PackageInfo>(detectedPackages));\r
+    }\r
+\r
     m.assertIsSatisfied();\r
   }\r
 \r
index 17b5416d7d2c997ea23b0e118cef57eb16fb87f7..554119d81152edc0e3edc6d1d6958333f897e4cc 100644 (file)
@@ -28,7 +28,7 @@ import java.io.File;
 public class Paths {\r
   @NotNull\r
   public static File getTestDataPath() {\r
-    return FileUtil.getCanonicalFile(new File("./nuget-tests/testData/integration"));\r
+    return FileUtil.getCanonicalFile(new File("./nuget-tests/testData"));\r
   }\r
 \r
   @NotNull\r
index 2c01f64b71d4c683b70f581dfc93fb4aa8cda627..51146fb5133eab9d952b2a03429672f1c41284d1 100644 (file)
@@ -18,7 +18,7 @@ package jetbrains.buildServer.nuget.tests.server;
 \r
 import jetbrains.buildServer.BaseTestCase;\r
 import jetbrains.buildServer.nuget.server.exec.ListPackagesCommandProcessor;\r
-import jetbrains.buildServer.nuget.server.exec.PackageInfo;\r
+import jetbrains.buildServer.nuget.server.exec.SourcePackageInfo;\r
 import org.testng.Assert;\r
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
@@ -68,9 +68,9 @@ public class ListPackagesCommandProcessorTest extends BaseTestCase {
   public void test_parse_service_message() {\r
     p.onStdOutput("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");\r
 \r
-    Collection<PackageInfo> result = p.getResult();\r
+    Collection<SourcePackageInfo> result = p.getResult();\r
     Assert.assertEquals(result.size(), 1);\r
-    PackageInfo next = result.iterator().next();\r
+    SourcePackageInfo next = result.iterator().next();\r
 \r
     Assert.assertEquals(next.getSource(), "source5");\r
     Assert.assertEquals(next.getPackageId(), "NUnit");\r
@@ -82,9 +82,9 @@ public class ListPackagesCommandProcessorTest extends BaseTestCase {
     p = new ListPackagesCommandProcessor(null);\r
     p.onStdOutput("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");\r
 \r
-    Collection<PackageInfo> result = p.getResult();\r
+    Collection<SourcePackageInfo> result = p.getResult();\r
     Assert.assertEquals(result.size(), 1);\r
-    PackageInfo next = result.iterator().next();\r
+    SourcePackageInfo next = result.iterator().next();\r
 \r
     Assert.assertEquals(next.getSource(), null);\r
     Assert.assertEquals(next.getPackageId(), "NUnit");\r
@@ -96,10 +96,10 @@ public class ListPackagesCommandProcessorTest extends BaseTestCase {
     p.onStdOutput("##teamcity[nuget-package Id='NUnit' Version='2.5.10.11092']");\r
     p.onStdOutput("##teamcity[nuget-package Id='JUnit' Version='1.2.0.92']");\r
 \r
-    Collection<PackageInfo> result = p.getResult();\r
+    Collection<SourcePackageInfo> result = p.getResult();\r
     Assert.assertEquals(result.size(), 2);\r
-    Iterator<PackageInfo> it = result.iterator();\r
-    PackageInfo next = it.next();\r
+    Iterator<SourcePackageInfo> it = result.iterator();\r
+    SourcePackageInfo next = it.next();\r
 \r
     Assert.assertEquals(next.getSource(), "source5");\r
     Assert.assertEquals(next.getPackageId(), "NUnit");\r
index 1420f7c2a1774d3611bf163a49da08a03ddd43b9..31032167193304436a38895750aa4a5de393e294 100644 (file)
@@ -48,7 +48,7 @@ public class ListPackagesCommandTest extends BaseTestCase {
     final List<String> list = new ArrayList<String>(Arrays.<String>asList(cmd));\r
     m.checking(new Expectations(){{\r
       oneOf(exec).executeNuGet(with(any(File.class)), with(equal(list)), with(any(ListPackagesCommandProcessor.class)));\r
-      will(returnValue(Collections.<PackageInfo>emptyList()));\r
+      will(returnValue(Collections.<SourcePackageInfo>emptyList()));\r
     }});\r
   }\r
 \r
index 208e265b9d50454090364f5739280b30cb209d93..ebb15bbc90f84950de68cf2a7411e7dd529b6537 100644 (file)
@@ -20,7 +20,7 @@ import jetbrains.buildServer.BaseTestCase;
 import jetbrains.buildServer.buildTriggers.BuildTriggerDescriptor;\r
 import jetbrains.buildServer.buildTriggers.BuildTriggerException;\r
 import jetbrains.buildServer.nuget.server.exec.ListPackagesCommand;\r
-import jetbrains.buildServer.nuget.server.exec.PackageInfo;\r
+import jetbrains.buildServer.nuget.server.exec.SourcePackageInfo;\r
 import jetbrains.buildServer.nuget.server.trigger.NamedPackagesUpdateChecker;\r
 import jetbrains.buildServer.nuget.server.trigger.TriggerConstants;\r
 import jetbrains.buildServer.nuget.tests.integration.Paths;\r
@@ -75,7 +75,7 @@ public class NamedPackagesUpdateCheckerTest extends BaseTestCase {
   public void test_check_first_time_should_not_trigger() {\r
     m.checking(new Expectations(){{\r
       oneOf(cmd).checkForChanges(nugetFakePath, null, "NUnit", null);\r
-      will(returnValue(Arrays.asList(new PackageInfo("src", "pkg", "5.6.87"))));\r
+      will(returnValue(Arrays.asList(new SourcePackageInfo("src", "pkg", "5.6.87"))));\r
 \r
       oneOf(store).getValue("hash"); will(returnValue(null));\r
       oneOf(store).putValue(with(equal("hash")), with(any(String.class)));\r
@@ -88,10 +88,10 @@ public class NamedPackagesUpdateCheckerTest extends BaseTestCase {
   public void test_check_should_not_trigger_twice() {\r
     m.checking(new Expectations(){{\r
       oneOf(cmd).checkForChanges(nugetFakePath, null, "NUnit", null);\r
-      will(returnValue(Arrays.asList(new PackageInfo("src", "pkg", "5.6.87"))));\r
+      will(returnValue(Arrays.asList(new SourcePackageInfo("src", "pkg", "5.6.87"))));\r
 \r
       oneOf(cmd).checkForChanges(nugetFakePath, null, "NUnit", null);\r
-      will(returnValue(Arrays.asList(new PackageInfo("src", "pkg", "5.6.87"))));\r
+      will(returnValue(Arrays.asList(new SourcePackageInfo("src", "pkg", "5.6.87"))));\r
 \r
       oneOf(store).getValue("hash"); will(returnValue("aaa"));\r
       oneOf(store).putValue("hash", "|s:src|p:pkg|v:5.6.87");\r
index 8c25e055686b7fd3fcad1d02affc1d75228a8727..866a2b0ee6f12c19e93d8a9cd09ef1b67d5f329e 100644 (file)
@@ -3,11 +3,15 @@
 \r
   <test name="fast tests">\r
     <classes>\r
+      <class name="jetbrains.buildServer.nuget.tests.agent.NuGetPackagesConfigParserTest"/>\r
+      <class name="jetbrains.buildServer.nuget.tests.agent.PackagesWatcherTest"/>\r
       <class name="jetbrains.buildServer.nuget.tests.agent.LocateNuGetConfigBuildProcessTest"/>\r
       <class name="jetbrains.buildServer.nuget.tests.agent.PackagesInstallerBuilderTest"/>\r
       <class name="jetbrains.buildServer.nuget.tests.agent.NuGetInstallPackageActionFactoryTest"/>\r
       <class name="jetbrains.buildServer.nuget.tests.agent.NuGetUpdatePackageActionFactoryTest"/>\r
 \r
+      <class name="jetbrains.buildServer.nuget.tests.common.PackageDependenciesStoreTest"/>\r
+\r
       <class name="jetbrains.buildServer.nuget.tests.util.CompositeBuildProcessTest"/>\r
       <class name="jetbrains.buildServer.nuget.tests.util.DelegatingBuildProcessTest"/>\r
 \r
diff --git a/nuget-tests/testData/config/test-01.xml b/nuget-tests/testData/config/test-01.xml
new file mode 100644 (file)
index 0000000..4431598
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+  <package id="elmah" version="1.1" />\r
+</packages>
\ No newline at end of file
diff --git a/nuget-tests/testData/config/test-02.xml b/nuget-tests/testData/config/test-02.xml
new file mode 100644 (file)
index 0000000..541a8d6
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+  <package id="elmah" version="1.1" allowedVersions="(1.0, 5.5)"/>\r
+</packages>
\ No newline at end of file
diff --git a/nuget-tests/testData/config/test-03.xml b/nuget-tests/testData/config/test-03.xml
new file mode 100644 (file)
index 0000000..1be9c90
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+  <package id="Machine.Specifications" version="0.4.13.0" />\r
+  <package id="NUnit" version="2.5.7.10213" allowedVersions="[2.5.0, 2.5.111)" />\r
+</packages>
\ No newline at end of file
diff --git a/nuget-tests/testData/config/test-04.xml b/nuget-tests/testData/config/test-04.xml
new file mode 100644 (file)
index 0000000..51cf381
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<packages>\r
+  <package id="structuremap" version="2.6.2" />\r
+  <package id="JsonFx" version="2.0.1106.2610" />\r
+  <package id="EasyHttp" version="1.0.6" />\r
+</packages>
\ No newline at end of file