create install packages server-side UI
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Sat, 9 Jul 2011 08:16:30 +0000 (12:16 +0400)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Sat, 9 Jul 2011 08:16:30 +0000 (12:16 +0400)
nuget-server/nuget-server.iml
nuget-server/resources/install/editInstallPackage.jsp [new file with mode: 0644]
nuget-server/resources/install/viewInstallPackage.jsp [new file with mode: 0644]
nuget-server/src/META-INF/build-server-plugin-nuget.xml
nuget-server/src/jetbrains/buildServer/nuget/server/install/InstallBean.java [new file with mode: 0644]
nuget-server/src/jetbrains/buildServer/nuget/server/install/PackageInstallerRunTypeRegistrar.java [new file with mode: 0644]
nuget-server/src/jetbrains/buildServer/nuget/server/install/PackagesInstallerRunType.java [new file with mode: 0644]

index 4fdac8fd77b0759ee840b58a16035bbfa86c12c7..a496da5feb3aad19b6a032303ccc5d5dcb1fa83e 100644 (file)
@@ -32,6 +32,7 @@
     <orderEntry type="library" name="log4j" level="project" />\r
     <orderEntry type="library" name="Idea-OpenApi" level="project" />\r
     <orderEntry type="library" name="Servlet Api" level="project" />\r
+    <orderEntry type="module" module-name="nuget-common" />\r
   </component>\r
 </module>\r
 \r
diff --git a/nuget-server/resources/install/editInstallPackage.jsp b/nuget-server/resources/install/editInstallPackage.jsp
new file mode 100644 (file)
index 0000000..cb0c7b3
--- /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
+<%@ 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="ib" class="jetbrains.buildServer.nuget.server.install.InstallBean" scope="request"/>\r
+\r
+<l:settingsGroup title="NuGet settings">\r
+  <tr>\r
+    <th>Path to NuGet.exe<l:star/></th>\r
+    <td>\r
+      <props:textProperty name="${ib.nuGetPathKey}" className="longField"/>\r
+      <span class="smallNote">Specify path to NuGet.exe</span>\r
+    </td>\r
+  </tr>\r
+  <tr>\r
+    <th>Package Sources</th>\r
+    <td>\r
+      <props:multilineProperty name="${ib.nuGetSourcesKey}"\r
+                               linkTitle="Sources"\r
+                               cols="60" rows="5"\r
+                               expanded="${true}"/>\r
+      <span class="smallNote">\r
+        Specify NuGet package sources.\r
+        Leave blank to let NuGet decided what package repository to use (nuget.org by default).\r
+      </span>\r
+    </td>\r
+  </tr>\r
+</l:settingsGroup>\r
+\r
+<l:settingsGroup title="Packages">\r
+<tr>\r
+  <th>Path to solution file</th>\r
+  <td>\r
+    <props:textProperty name="${ib.solutionPathKey}" className="longField"/>\r
+    <span class="smallNote">Specify path to Visual Studio solution file (.sln)</span>\r
+  </td>\r
+</tr>\r
+</l:settingsGroup>\r
diff --git a/nuget-server/resources/install/viewInstallPackage.jsp b/nuget-server/resources/install/viewInstallPackage.jsp
new file mode 100644 (file)
index 0000000..672d397
--- /dev/null
@@ -0,0 +1,31 @@
+<%--\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
+<%@ 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="ib" class="jetbrains.buildServer.nuget.server.install.InstallBean" scope="request"/>\r
+\r
+<div class="parameter">\r
+  Path to NuGet.exe: <strong><props:displayValue name="${ib.nuGetPathKey}"/></strong>\r
+</div>\r
+<div class="parameter">\r
+  Package Sources: <strong><props:displayValue name="${ib.nuGetSourcesKey}"\r
+                                               emptyValue="Use nuget.org package source"/></strong>\r
+</div>\r
+<div class="parameter">\r
+  Path to .sln: <strong><props:displayValue name="${ib.solutionPathKey}"/></strong>\r
+</div>\r
index d2be1be45b5db88136f66d4561af6620d136ecce..45c055a0443ff08dfc6647fcc37cb67bda793cd2 100644 (file)
@@ -4,9 +4,13 @@
        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
+<!--\r
   <bean class="jetbrains.buildServer.nuget.server.NuGetPublishRunType"/>\r
   <bean class="jetbrains.buildServer.nuget.server.NuGetDownloadedPackagesTab"/>\r
   <bean class="jetbrains.buildServer.nuget.server.NuGetDownloadFeature"/>\r
   <bean class="jetbrains.buildServer.nuget.server.NuGetTrigger"/>\r
+-->\r
 \r
+  <bean class="jetbrains.buildServer.nuget.server.install.PackageInstallerRunTypeRegistrar"/>\r
+  <bean class="jetbrains.buildServer.nuget.server.install.PackagesInstallerRunType"/>\r
 </beans>
\ No newline at end of file
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/install/InstallBean.java b/nuget-server/src/jetbrains/buildServer/nuget/server/install/InstallBean.java
new file mode 100644 (file)
index 0000000..59dd28f
--- /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.server.install;\r
+\r
+import jetbrains.buildServer.nuget.common.PackagesInstallerConstants;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 08.07.11 20:49\r
+ */\r
+public class InstallBean {\r
+  public String getNuGetPathKey() { return PackagesInstallerConstants.NUGET_PATH; }\r
+  public String getNuGetSourcesKey() { return PackagesInstallerConstants.NUGET_SOURCES; }\r
+  public String getSolutionPathKey() { return PackagesInstallerConstants.SLN_PATH; }\r
+}\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/install/PackageInstallerRunTypeRegistrar.java b/nuget-server/src/jetbrains/buildServer/nuget/server/install/PackageInstallerRunTypeRegistrar.java
new file mode 100644 (file)
index 0000000..3bd8f50
--- /dev/null
@@ -0,0 +1,31 @@
+/*\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.server.install;\r
+\r
+import jetbrains.buildServer.serverSide.RunTypeRegistry;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 09.07.11 12:08\r
+ */\r
+public class PackageInstallerRunTypeRegistrar {\r
+  public PackageInstallerRunTypeRegistrar(@NotNull final PackagesInstallerRunType rt,\r
+                                          @NotNull final RunTypeRegistry reg) {\r
+    reg.registerRunType(rt);\r
+  }\r
+}\r
diff --git a/nuget-server/src/jetbrains/buildServer/nuget/server/install/PackagesInstallerRunType.java b/nuget-server/src/jetbrains/buildServer/nuget/server/install/PackagesInstallerRunType.java
new file mode 100644 (file)
index 0000000..6947bf6
--- /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.server.install;\r
+\r
+import jetbrains.buildServer.nuget.common.DotNetConstants;\r
+import jetbrains.buildServer.requirements.Requirement;\r
+import jetbrains.buildServer.requirements.RequirementType;\r
+import jetbrains.buildServer.serverSide.InvalidProperty;\r
+import jetbrains.buildServer.serverSide.PropertiesProcessor;\r
+import jetbrains.buildServer.serverSide.RunType;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.*;\r
+\r
+import static jetbrains.buildServer.nuget.common.PackagesInstallerConstants.*;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 08.07.11 20:45\r
+ */\r
+public class PackagesInstallerRunType extends RunType {\r
+  private final PluginDescriptor myDescriptor;\r
+\r
+  public PackagesInstallerRunType(@NotNull final PluginDescriptor descriptor) {\r
+    myDescriptor = descriptor;\r
+  }\r
+\r
+  @NotNull\r
+  @Override\r
+  public String getType() {\r
+    return RUN_TYPE;\r
+  }\r
+\r
+  @Override\r
+  public String getDisplayName() {\r
+    return "NuGet packages installer";\r
+  }\r
+\r
+  @Override\r
+  public String getDescription() {\r
+    return "Installs missing NuGet packages";\r
+  }\r
+\r
+  @Override\r
+  public PropertiesProcessor getRunnerPropertiesProcessor() {\r
+    return new PropertiesProcessor() {\r
+      public Collection<InvalidProperty> process(Map<String, String> properties) {\r
+        List<InvalidProperty> checks = new ArrayList<InvalidProperty>();\r
+\r
+        if (StringUtil.isEmptyOrSpaces(properties.get(NUGET_PATH))) {\r
+          checks.add(new InvalidProperty(NUGET_PATH, "Path to nuget.exe must be specified"));\r
+        }\r
+\r
+        String sln = properties.get(SLN_PATH);\r
+        if (StringUtil.isEmptyOrSpaces(sln)) {\r
+          checks.add(new InvalidProperty(NUGET_PATH, "Path to solution file should be specified"));\r
+        }\r
+        if (!sln.toLowerCase().endsWith(".sln")) {\r
+          checks.add(new InvalidProperty(NUGET_PATH, "File extension must be .sln. Specify path to .sln file."));\r
+        }\r
+\r
+        return checks;\r
+      }\r
+    };\r
+  }\r
+\r
+  @NotNull\r
+  @Override\r
+  public String describeParameters(@NotNull Map<String, String> parameters) {\r
+    return getDescription() + "\nSolution: " + parameters.get(SLN_PATH);\r
+  }\r
+\r
+  @Override\r
+  public List<Requirement> getRunnerSpecificRequirements(@NotNull Map<String, String> runParameters) {\r
+    List<Requirement> list = new ArrayList<Requirement>(super.getRunnerSpecificRequirements(runParameters));\r
+    list.add(new Requirement(DotNetConstants.DOT_NET_FRAMEWORK_4_x86, null, RequirementType.EXISTS));\r
+    return list;\r
+  }\r
+\r
+  @Override\r
+  public String getEditRunnerParamsJspFilePath() {\r
+    return myDescriptor.getPluginResourcesPath("editInstallPackage.jsp");\r
+  }\r
+\r
+  @Override\r
+  public String getViewRunnerParamsJspFilePath() {\r
+    return myDescriptor.getPluginResourcesPath("viewInstallPackage.jsp");\r
+  }\r
+\r
+  @Override\r
+  public Map<String, String> getDefaultRunnerProperties() {\r
+    return new TreeMap<String, String>();\r
+  }\r
+}\r