use of org.gradle.language.swift.tasks.UnexportMainSymbol in project gradle by gradle.
the class XCTestConventionPlugin method configureTestSuiteWithTestedComponentWhenAvailable.
private void configureTestSuiteWithTestedComponentWhenAvailable(final Project project, final DefaultSwiftXCTestSuite testSuite, final DefaultSwiftXCTestBinary testExecutable) {
SwiftComponent target = testSuite.getTestedComponent().getOrNull();
if (!(target instanceof ProductionSwiftComponent)) {
return;
}
final ProductionSwiftComponent testedComponent = (ProductionSwiftComponent) target;
final TaskContainer tasks = project.getTasks();
testedComponent.getBinaries().whenElementFinalized(new Action<SwiftBinary>() {
@Override
public void execute(SwiftBinary testedBinary) {
if (testedBinary != testedComponent.getDevelopmentBinary().get()) {
return;
}
// If nothing was configured for the test suite source compatibility, use the tested component one.
if (testSuite.getSourceCompatibility().getOrNull() == null) {
testExecutable.getSourceCompatibility().set(testedBinary.getSourceCompatibility());
}
// Configure test suite link task from tested component compiled objects
final AbstractLinkTask linkTest = testExecutable.getLinkTask().get();
if (testedComponent instanceof SwiftApplication) {
final UnexportMainSymbol unexportMainSymbol = tasks.create("relocateMainForTest", UnexportMainSymbol.class);
unexportMainSymbol.source(testedBinary.getObjects());
linkTest.source(testedBinary.getObjects().filter(new Spec<File>() {
@Override
public boolean isSatisfiedBy(File objectFile) {
return !objectFile.equals(unexportMainSymbol.getMainObject());
}
}));
linkTest.source(unexportMainSymbol.getObjects());
} else {
linkTest.source(testedBinary.getObjects());
}
}
});
}
Aggregations