use of org.gradle.integtests.fixtures.SourceFile in project gradle by gradle.
the class IncrementalCppElement method rename.
protected static Transform rename(final CppSourceFileElement beforeElement, String renamePrefix) {
SourceFile beforeFile = beforeElement.getSource().getSourceFile();
final SourceFile afterFile = new SourceFile(beforeFile.getPath(), renamePrefix + beforeFile.getName(), beforeFile.getContent());
return new AbstractRenameTransform(beforeFile, afterFile, beforeElement) {
@Override
public List<SourceFile> getAfterFiles() {
List<SourceFile> result = new ArrayList<SourceFile>();
result.addAll(beforeElement.getHeaders().getFiles());
result.add(afterFile);
return result;
}
};
}
use of org.gradle.integtests.fixtures.SourceFile in project gradle by gradle.
the class IncrementalElement method delete.
/**
* Returns a transform that delete the before element.
*/
protected static Transform delete(final SourceElement beforeElement) {
final String sourceSetName = beforeElement.getSourceSetName();
final List<SourceFile> beforeFiles = beforeElement.getFiles();
return new Transform() {
@Override
public void applyChangesToProject(TestFile projectDir) {
for (SourceFile beforeFile : beforeFiles) {
TestFile file = projectDir.file(beforeFile.withPath("src/" + sourceSetName));
file.assertExists();
file.delete();
}
}
@Override
public List<SourceFile> getBeforeFiles() {
return beforeElement.getFiles();
}
@Override
public List<SourceFile> getAfterFiles() {
return Collections.emptyList();
}
};
}
use of org.gradle.integtests.fixtures.SourceFile in project gradle by gradle.
the class IncrementalSwiftElement method modify.
/**
* Returns a transform that replace the content of the before element with the content of the after element.
* Both elements must have the same location.
*/
protected static Transform modify(final SourceFileElement beforeElement, SourceFileElement afterElement) {
assert beforeElement.getFiles().size() == 1;
assert afterElement.getFiles().size() == 1;
assert beforeElement.getSourceSetName().equals(afterElement.getSourceSetName());
final String sourceSetName = beforeElement.getSourceSetName();
final SourceFile beforeFile = beforeElement.getSourceFile();
final SourceFile afterFile = afterElement.getSourceFile();
assert beforeFile.getPath().equals(afterFile.getPath());
assert beforeFile.getName().equals(afterFile.getName());
assert !beforeFile.getContent().equals(afterFile.getContent());
return new Transform() {
@Override
public void applyChangesToProject(TestFile projectDir) {
TestFile file = projectDir.file(beforeFile.withPath("src/" + sourceSetName));
file.assertExists();
file.write(afterFile.getContent());
}
@Override
public List<SourceFile> getBeforeFiles() {
return Arrays.asList(beforeFile);
}
@Override
public List<SourceFile> getAfterFiles() {
return Arrays.asList(afterFile);
}
};
}
use of org.gradle.integtests.fixtures.SourceFile in project gradle by gradle.
the class IncrementalSwiftElement method rename.
protected static Transform rename(SourceFileElement beforeElement, String renamePrefix) {
assert beforeElement.getFiles().size() == 1;
SourceFile beforeFile = beforeElement.getSourceFile();
final SourceFile afterFile = new SourceFile(beforeFile.getPath(), renamePrefix + beforeFile.getName(), beforeFile.getContent());
return new AbstractRenameTransform(beforeFile, afterFile, beforeElement) {
@Override
public List<SourceFile> getAfterFiles() {
return Arrays.asList(afterFile);
}
};
}
Aggregations