package com.rimerosolutions.ant.git.tasks;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Reference;

import com.rimerosolutions.ant.git.GitSettings;
import com.rimerosolutions.ant.git.GitUtils;

public class GitSettingsTask extends Task {

        private String name;
        private String email;
        private String username;
        private String password;
        private String refId;

        public void setRefId(String refId) {
                this.refId = refId;
        }

        /**
         * @param name
         *                the name to set
         */
        public void setName(String name) {
                this.name = name;
        }

        /**
         * @param email
         *                the email to set
         */
        public void setEmail(String email) {
                this.email = email;
        }

        /**
         * @param username
         *                the username to set
         */
        public void setUsername(String username) {
                this.username = username;
        }

        /**
         * @param password
         *                the password to set
         */
        public void setPassword(String password) {
                this.password = password;
        }

        @Override
        public void execute() throws BuildException {
                final GitSettings settings = new GitSettings();

                if (!GitUtils.nullOrEmptyString(username) && !GitUtils.nullOrEmptyString(password)) {
                        settings.setCredentials(username, password);
                }

                if (!GitUtils.nullOrEmptyString(name) && !GitUtils.nullOrEmptyString(email)) {
                        settings.setIdentity(name, email);
                }

                getProject().addReference(refId, new Reference(getProject(), refId) {
                                public GitSettings getReferencedObject(Project fallback) throws BuildException {
                                        return settings;
                                }
                        });
        }

}

@@ -1,8 +1,610 @@
+/*%0A * Copyright 2013, Rimero Solutions%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A
 package 
@@ -894,16 +894,107 @@
 Utils;%0A%0A
+/**%0A * Sets reusable Git settings (credentials and identity)%0A *%0A * @author Yves Zoundi%0A */%0A
 public c
@@ -1186,16 +1186,148 @@
 refId;%0A%0A
+        /**%0A         * Sets a project reference id for reuse%0A         *%0A         * @param refId The reference id to set%0A         */%0A
         
@@ -1433,22 +1433,31 @@
       * 
-@param
+Sets the user's
  name%0A  
@@ -1456,32 +1456,33 @@
  name%0A         *
+%0A
                 
@@ -1470,30 +1470,37 @@
  *%0A         
-      
+* @param name
  the name to
@@ -1627,22 +1627,31 @@
       * 
-@param
+Sets the user's
  email%0A 
@@ -1651,32 +1651,33 @@
 email%0A         *
+%0A
                 
@@ -1665,30 +1665,38 @@
  *%0A         
-      
+* @param email
  the email t
@@ -1832,19 +1832,24 @@
   * 
-@param
+Sets the
  user
+'s 
 name
@@ -1851,32 +1851,33 @@
  name%0A         *
+%0A
                 
@@ -1865,30 +1865,41 @@
  *%0A         
-      
+* @param username
  the usernam
@@ -2050,49 +2050,70 @@
   * 
-@param password%0A         *               
+Sets the user's password%0A         *%0A         * @param password
  the

Update javadoc and license header.