API gaps:\r
- Reuse ComposideBuildProcess and DelegatingBuildProcess\r
- Use XmlXppAbstractParser#parse(InputSream)\r
- - Consider reuseing of Maven build trigger/project models
\ No newline at end of file
+ - Consider reuseing of Maven build trigger/project models\r
+ - Make server-side PluginDescription contain getPluginRoot() to avoid cast to PluginInfo
\ No newline at end of file
default-autowire="constructor">\r
<!-- this is a fake spring context xml to make IDEA know all implicit beans that are available for plugin -->\r
<bean class="jetbrains.buildServer.web.openapi.PluginDescriptor"/>\r
+ <bean class="jetbrains.buildServer.plugins.bean.PluginInfo"/>\r
</beans>
\ No newline at end of file
<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
+ <orderEntry type="library" name="Common-Impl" level="project" />\r
</component>\r
</module>\r
\r
<bean class="jetbrains.buildServer.nuget.server.install.PackagesInstallerRunType"/>\r
\r
\r
+ <bean class="jetbrains.buildServer.nuget.server.exec.NuGetExecutorImpl"/>\r
+\r
<bean class="jetbrains.buildServer.nuget.server.trigger.NuGetSimpleTrigger"/>\r
</beans>
\ No newline at end of file
--- /dev/null
+/*\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.exec;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.List;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 14.07.11 13:10\r
+ */\r
+public class ListPackagesCommand {\r
+ private static final Logger LOG = Logger.getInstance(ListPackagesCommand.class.getName());\r
+\r
+ private NuGetExecutor myExec;\r
+\r
+ public ListPackagesCommand(NuGetExecutor exec) {\r
+ myExec = exec;\r
+ }\r
+\r
+ public Collection<PackageInfo> checkForChanges(\r
+ @NotNull final String source,\r
+ @NotNull final String packageId,\r
+ @Nullable final String versionSpec) {\r
+ List<String> cmd = new ArrayList<String>();\r
+\r
+ cmd.add("TeamCity.List");\r
+ cmd.add("-Source");\r
+ cmd.add(source);\r
+ cmd.add("-Id");\r
+ cmd.add(packageId);\r
+\r
+ if (!StringUtil.isEmptyOrSpaces(versionSpec)) {\r
+ cmd.add("-Version");\r
+ cmd.add(versionSpec);\r
+ }\r
+\r
+ return myExec.executeNuGet(cmd, new ListPackagesCommandProcessor(source));\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\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.exec;\r
+\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.messages.serviceMessages.ServiceMessage;\r
+import jetbrains.buildServer.messages.serviceMessages.ServiceMessageParserCallback;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.text.ParseException;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.List;\r
+\r
+/**\r
+* 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
+ 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
+\r
+ ListPackagesCommandProcessor(@NotNull final String source) {\r
+ mySource = source;\r
+ }\r
+\r
+ public void onStdOutput(String text) {\r
+ if (LOG.isDebugEnabled()) {\r
+ LOG.debug(text);\r
+ }\r
+\r
+ ServiceMessage.parse(text, new ServiceMessageParserCallback() {\r
+ public void regularText(@NotNull String s) {\r
+ }\r
+\r
+ public void serviceMessage(@NotNull ServiceMessage serviceMessage) {\r
+ if (!"nuget-package".equals(serviceMessage.getMessageName())) return;\r
+ final String id = serviceMessage.getAttributes().get("Id");\r
+ final String version = serviceMessage.getAttributes().get("Version");\r
+\r
+ if (StringUtil.isEmptyOrSpaces(id)) return;\r
+ if (StringUtil.isEmptyOrSpaces(version)) return;\r
+\r
+ myPackages.add(new PackageInfo(mySource, id, version));\r
+\r
+ }\r
+\r
+ public void parseException(@NotNull ParseException e, @NotNull String s) {\r
+ }\r
+ });\r
+ }\r
+\r
+ public void onStdError(String text) {\r
+ LOG.warn(text);\r
+ }\r
+\r
+ public void onFinished(int exitCode) {\r
+ if (LOG.isDebugEnabled()) {\r
+ LOG.debug("NuGet TeamCity.List command exited with " + exitCode);\r
+ }\r
+ }\r
+\r
+ @NotNull\r
+ public Collection<PackageInfo> getResult() {\r
+ return Collections.unmodifiableList(myPackages);\r
+ }\r
+}\r
--- /dev/null
+package jetbrains.buildServer.nuget.server.exec;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.util.List;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 14.07.11 13:23\r
+ */\r
+public interface NuGetExecutor {\r
+ <T> T executeNuGet(@NotNull List<String> arguments,\r
+ @NotNull NuGetOutputProcessor<T> listener);\r
+}\r
--- /dev/null
+/*\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.exec;\r
+\r
+import com.intellij.execution.configurations.GeneralCommandLine;\r
+import com.intellij.openapi.diagnostic.Logger;\r
+import jetbrains.buildServer.ExecResult;\r
+import jetbrains.buildServer.SimpleCommandLineProcessRunner;\r
+import jetbrains.buildServer.plugins.bean.PluginInfo;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+import java.io.File;\r
+import java.util.List;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 14.07.11 12:48\r
+ */\r
+public class NuGetExecutorImpl implements NuGetExecutor {\r
+ private static final Logger LOG = Logger.getInstance(NuGetExecutorImpl.class.getName());\r
+\r
+ private final PluginInfo myPluginInfo;\r
+\r
+ public NuGetExecutorImpl(PluginInfo pluginInfo) {\r
+ myPluginInfo = pluginInfo;\r
+ }\r
+\r
+ @NotNull\r
+ private File getNuGetRunnerPath() {\r
+ return new File(myPluginInfo.getPluginRoot(), "bin/JetBrains.TeamCity.NuGetRunner.exe");\r
+ }\r
+\r
+ public <T> T executeNuGet(@NotNull final List<String> arguments,\r
+ @NotNull final NuGetOutputProcessor<T> listener) {\r
+\r
+ GeneralCommandLine cmd = new GeneralCommandLine();\r
+ cmd.setExePath(getNuGetRunnerPath().getPath());\r
+ cmd.addParameters(arguments);\r
+\r
+ if (LOG.isDebugEnabled()) {\r
+ LOG.debug("Starting: " + cmd.getCommandLineString());\r
+ }\r
+\r
+ final ExecResult result = SimpleCommandLineProcessRunner.runCommand(cmd, new byte[0]);\r
+\r
+ if (LOG.isDebugEnabled()) {\r
+ LOG.debug("Exited with code: " + result.getExitCode());\r
+ LOG.debug("Output: " + result.getStdout());\r
+ LOG.error("Error: " + result.getStderr());\r
+ }\r
+\r
+ listener.onStdOutput(result.getStdout());\r
+ listener.onStdError(result.getStderr());\r
+ listener.onFinished(result.getExitCode());\r
+\r
+ return listener.getResult();\r
+ }\r
+}\r
--- /dev/null
+/*\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.exec;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+* Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+* Date: 14.07.11 13:23\r
+*/\r
+public interface NuGetOutputProcessor<T> {\r
+ void onStdOutput(String text);\r
+ void onStdError(String text);\r
+ void onFinished(int exitCode);\r
+\r
+ @NotNull\r
+ T getResult();\r
+}\r
--- /dev/null
+/*\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.exec;\r
+\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 14.07.11 13:17\r
+ */\r
+public class PackageInfo {\r
+ private final String mySource;\r
+ private final String myPackageId;\r
+ private final String myVersion;\r
+\r
+ public PackageInfo(@NotNull final String source,\r
+ @NotNull final String packageId,\r
+ @NotNull final String version) {\r
+ mySource = source;\r
+ myPackageId = packageId;\r
+ myVersion = version;\r
+ }\r
+\r
+ @NotNull\r
+ public String getSource() {\r
+ return mySource;\r
+ }\r
+\r
+ @NotNull\r
+ public String getPackageId() {\r
+ return myPackageId;\r
+ }\r
+\r
+ @NotNull\r
+ public String getVersion() {\r
+ return myVersion;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "PackageInfo{" +\r
+ "mySource='" + mySource + '\'' +\r
+ ", myPackageId='" + myPackageId + '\'' +\r
+ ", myVersion='" + myVersion + '\'' +\r
+ '}';\r
+ }\r
+}\r