I wrote custom ant task which uses jgit. It should take local repository address together with directory address and add all files in the directory to index. It builds successfully but unfortunately it doesn't work. I'm totally new to that, so I wonder if some of you could help me finding the problem or what i am missing. Here's my code:
package customGitTasks;
import java.io.File;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.Git;
public class GitAdd extends Task{
private String dir;
private String repository;
public void setRepository(String repository) {
this.repository = repository;
}
public void setDir(String dir) {
this.dir = dir;
}
public void execute() throws BuildException {
try {
Git git = Git.open(new File(repository));
AddCommand add = git.add();
add.addFilepattern(dir).call();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
}
Thank you