<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed Materials - Property of IBM Corp.
- IBM UrbanCode Deploy
- (c) Copyright IBM Corporation 2014. All Rights Reserved.
-
- U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
- GSA ADP Schedule Contract with IBM Corp.
-->
<plugin xmlns="http://www.urbancode.com/PluginXMLSchema_v1"
    xmlns:server="http://www.urbancode.com/PluginServerXMLSchema_v1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <header>
    <identifier id="com.ibm.urbancode.air.plugin.source.nuget" name="NuGet" version="2"/>
    <description>
      The NuGet plugin automates downloading artifacts from NuGet packages.
    </description>
    <tag>Source and Repositories/NuGet</tag>
    <server:plugin-type>Source</server:plugin-type>
  </header>

  <step-type name="Import Version">
    <description>Creates a new component version and imports artifacts from NuGet</description>
    <properties>
    </properties>
    <post-processing><![CDATA[
        if (properties.get("exitCode") != 0) {
            properties.put(new java.lang.String("Status"), new java.lang.String("Failure"));
        }
        else {
            properties.put("Status", "Success");
        }
     ]]></post-processing>
    <command program="${GROOVY_HOME}/bin/groovy">
      <arg value="-cp"/>
      <arg path="classes:lib/httpclient.jar:lib/httpcore.jar:lib/HttpComponents-Util.jar:lib/CommonsFileUtils.jar:lib/log4j.jar:lib/udclient.jar:lib/uDeployRestClient.jar"/>
      <arg file="nuget_download.groovy"/>
      <arg file="${PLUGIN_INPUT_PROPS}"/>
      <arg file="${PLUGIN_OUTPUT_PROPS}"/>
    </command>
  </step-type>

    <!-- ==================================== -->
    <!--   Properties                         -->
    <!-- ==================================== -->
    <server:property-group type="Component" name="NuGetComponentProperties">
      <server:property name="nuGetHost" required="true">
        <server:property-ui type="textBox"
                            label="NuGet URL"
                            description="Base URL for the NuGet repository host"
                            placeholder="https://nugetrepo.company.com" />
      </server:property>
      <server:property name="nuGetPackage" required="true">
        <server:property-ui type="textBox"
                            label="Package Name"
                            description="Specify name of NuGet package to import"
                            placeholder="mypackage"/>
      </server:property>
      <server:property name="user">
        <server:property-ui type="textBox"
                            label="User" />
      </server:property>
      <server:property name="password">
        <server:property-ui type="secureBox"
                            label="Password"/>
      </server:property>
      <server:property name="saveFileExecuteBits">
        <server:property-ui type="checkBox"
                            label="Preserve Execute Permissions"
                            description="When enabled, file execute permissions are saved with files."/>
      </server:property>
      <server:property name="extensions">
        <server:property-ui type="textBox"
                            label="Extensions of Files to Convert"
                            description="The comma separated list of text extensions of files which need to be
                            converted to a new Charset on download."
                            placeholder=".txt,.log,.properties"/>
      </server:property>
    </server:property-group>

    <server:property-group type="Import" name="NuGetImportProperties">
      <server:property name="version" >
        <server:property-ui type="textBox"
                            label="Specific version" />
      </server:property>
    </server:property-group>
</plugin>
