<bean class="jetbrains.buildServer.nuget.server.toolRegistry.impl.ToolsRegistry"/>\r
<bean class="jetbrains.buildServer.nuget.server.toolRegistry.impl.ToolPacker"/>\r
<bean class="jetbrains.buildServer.nuget.server.toolRegistry.impl.ToolPaths"/>\r
+ <bean class="jetbrains.buildServer.nuget.server.toolRegistry.impl.PluginNaming"/>\r
</beans>
\ No newline at end of file
private final NuGetFeedReader myClient;\r
private final AvailableToolsState myState;\r
private final ToolPacker myPacker;\r
+ private final PluginNaming myNaming;\r
\r
public NuGetToolsInstaller(@NotNull final ToolPaths toolPaths,\r
@NotNull final NuGetFeedReader client,\r
@NotNull final AvailableToolsState state,\r
- @NotNull final ToolPacker packer) {\r
+ @NotNull final ToolPacker packer,\r
+ @NotNull final PluginNaming naming) {\r
myToolPaths = toolPaths;\r
myClient = client;\r
myState = state;\r
myPacker = packer;\r
+ myNaming = naming;\r
}\r
\r
public InstallResult installNuGet(@NotNull final String packageId, @NotNull final InstallLogger logger) {\r
logger.agentToolPubslishStarted(tool, agentTool);\r
\r
try {\r
- final File dest = new File(myToolPaths.getAgentPluginsPath(), agentTool.getName());\r
+ final File dest = myNaming.getAgetToolFilePath(tool);\r
if (!agentTool.renameTo(dest)) {\r
FileUtil.copy(agentTool, dest);\r
FileUtil.delete(agentTool);\r
}\r
}\r
\r
+ private String getAgentToolFileName(@NotNull String version) {\r
+ return "nuget-commnadline-" + version;\r
+ }\r
+\r
private File packAgentPlugin(@NotNull final InstallLogger logger,\r
@NotNull final FeedPackage tool,\r
@NotNull final File dest) {\r
logger.agentToolPackStarted(tool, dest);\r
try {\r
- return myPacker.packTool("nuget-commandline-" + tool.getInfo().getVersion(), dest);\r
+ return myPacker.packTool(getAgentToolFileName(tool.getInfo().getVersion()), dest);\r
} catch (Exception e) {\r
logger.agentToolPackFailed(tool, dest, e);\r
LOG.warn("Failed to pack agent tool " + tool);\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.toolRegistry.impl;\r
+\r
+import jetbrains.buildServer.nuget.server.feed.reader.FeedPackage;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.NuGetTool;\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: 16.08.11 1:00\r
+ */\r
+public class PluginNaming {\r
+ private final ToolPaths myPaths;\r
+\r
+ public PluginNaming(@NotNull final ToolPaths paths) {\r
+ myPaths = paths;\r
+ }\r
+\r
+ @NotNull\r
+ public String getAgentToolFileName(@NotNull String version) {\r
+ return "nuget-commnadline-" + version + ".zip";\r
+ }\r
+\r
+ public File getAgetToolFilePath(@NotNull NuGetTool tool) {\r
+ return new File(myPaths.getAgentPluginsPath(), getAgentToolFileName(tool.getVersion()));\r
+ }\r
+\r
+ public File getAgetToolFilePath(@NotNull FeedPackage tool) {\r
+ return new File(myPaths.getAgentPluginsPath(), getAgentToolFileName(tool.getInfo().getVersion()));\r
+ }\r
+\r
+}\r
import java.io.File;\r
import java.io.FileOutputStream;\r
import java.io.IOException;\r
-import java.util.Collection;\r
import java.util.zip.ZipEntry;\r
import java.util.zip.ZipOutputStream;\r
\r
\r
package jetbrains.buildServer.nuget.server.toolRegistry.impl;\r
\r
+import com.intellij.openapi.diagnostic.Logger;\r
import jetbrains.buildServer.nuget.server.toolRegistry.NuGetInstalledTool;\r
import jetbrains.buildServer.util.FileUtil;\r
import org.jetbrains.annotations.NotNull;\r
* Date: 16.08.11 0:25\r
*/\r
public class ToolsRegistry {\r
+ private static final Logger LOG = Logger.getInstance(ToolsRegistry.class.getName());\r
private final ToolPaths myPaths;\r
+ private final PluginNaming myNaming;\r
\r
- public ToolsRegistry(@NotNull final ToolPaths paths) {\r
+ public ToolsRegistry(@NotNull final ToolPaths paths,\r
+ @NotNull final PluginNaming naming) {\r
myPaths = paths;\r
+ myNaming = naming;\r
}\r
\r
@NotNull\r
public void removeTool(@NotNull final String toolId) {\r
for (InstalledTool tool : getToolsInternal()) {\r
if (tool.getId().equals(toolId)) {\r
- tool.delete();\r
+ LOG.info("Removing NuGet plugin: " + tool);\r
+\r
+ final File agentPlugin = myNaming.getAgetToolFilePath(tool);\r
+ LOG.info("Removing NuGet plugin agent tool : " + agentPlugin);\r
+ FileUtil.delete(agentPlugin);\r
+\r
+ final File toolHome = tool.getRootPath();\r
+ LOG.info("Removing NuGet files from: " + toolHome);\r
+ FileUtil.delete(toolHome);\r
return;\r
}\r
}\r
myPath = path;\r
}\r
\r
- public void delete() {\r
- while(myPath.exists()) {\r
- FileUtil.delete(myPath);\r
- }\r
+ @NotNull\r
+ public File getRootPath() {\r
+ return myPath;\r
}\r
\r
@NotNull\r
return new File(myPath, "tools/NuGet.exe");\r
}\r
\r
+ @NotNull\r
+ public String getAgentToolName() {\r
+ return "nuget-commandline-" + getVersion() + ".zip";\r
+ }\r
+\r
@NotNull\r
public String getId() {\r
return myPath.getName();\r