/
Project.java
55 lines (43 loc) · 1.69 KB
/
Project.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.arquillian.smart.testing.ftest.testbed.project;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import org.arquillian.smart.testing.ftest.testbed.testresults.TestResult;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
public class Project implements AutoCloseable {
private final Path root;
private final Repository repository;
private final ProjectBuilder projectBuilder;
public Project(Path root) throws IOException {
this.root = root;
this.repository = getRepository(root);
this.projectBuilder = new ProjectBuilder(root, this);
}
private Repository getRepository(Path root) throws IOException {
final FileRepositoryBuilder builder = new FileRepositoryBuilder();
return builder.readEnvironment().findGitDir(root.toFile()).build();
}
public ProjectConfigurator configureSmartTesting() {
return new ProjectConfigurator(this, root);
}
public List<TestResult> applyAsLocalChanges(String ... changeDescriptions) {
return new ChangeApplier(repository).applyLocally(changeDescriptions);
}
public List<TestResult> applyAsCommits(String ... changeDescriptions) {
return new ChangeApplier(repository).applyAsCommits(changeDescriptions);
}
@Override
public void close() throws Exception {
this.repository.close();
}
public ProjectBuilder buildOptions() {
return this.projectBuilder;
}
public List<TestResult> build() {
return build("clean", "package");
}
public List<TestResult> build(String ... goals) {
return projectBuilder.build(goals);
}
}