use of org.gradle.api.file.FileTree in project gradle by gradle.
the class DefaultTestExecuter method execute.
@Override
public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
final TestFramework testFramework = testTask.getTestFramework();
final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
final BuildOperationWorkerRegistry.Operation currentOperation = buildOperationWorkerRegistry.getCurrent();
final Set<File> classpath = ImmutableSet.copyOf(testTask.getClasspath());
final Factory<TestClassProcessor> forkingProcessorFactory = new Factory<TestClassProcessor>() {
public TestClassProcessor create() {
return new ForkingTestClassProcessor(workerFactory, testInstanceFactory, testTask, classpath, testFramework.getWorkerConfigurationAction(), moduleRegistry, currentOperation);
}
};
Factory<TestClassProcessor> reforkingProcessorFactory = new Factory<TestClassProcessor>() {
public TestClassProcessor create() {
return new RestartEveryNTestClassProcessor(forkingProcessorFactory, testTask.getForkEvery());
}
};
TestClassProcessor processor = new MaxNParallelTestClassProcessor(getMaxParallelForks(testTask), reforkingProcessorFactory, actorFactory);
final FileTree testClassFiles = testTask.getCandidateClassFiles();
Runnable detector;
if (testTask.isScanForTestClasses()) {
TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
testFrameworkDetector.setTestClasspath(classpath);
detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
} else {
detector = new DefaultTestClassScanner(testClassFiles, null, processor);
}
final Object testTaskOperationId = buildOperationExecutor.getCurrentOperation().getParentId();
new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider(), testTaskOperationId, testTask.getPath(), "Gradle Test Run " + testTask.getIdentityPath()).run();
}
use of org.gradle.api.file.FileTree in project rest.li by linkedin.
the class GenerateAvroSchemaTask method generate.
@TaskAction
public void generate() {
FileTree inputDataSchemaFiles = getSuffixedFiles(getProject(), _inputDir, PegasusPlugin.DATA_TEMPLATE_FILE_SUFFIXES);
List<String> inputDataSchemaFilenames = StreamSupport.stream(inputDataSchemaFiles.spliterator(), false).map(File::getPath).collect(Collectors.toList());
if (inputDataSchemaFilenames.isEmpty()) {
throw new StopExecutionException("There are no data schema input files. Skip generating avro schema.");
}
getProject().getLogger().info("Generating Avro schemas ...");
getProject().getLogger().lifecycle("There are {} data schema input files. Using input root folder: {}", inputDataSchemaFilenames.size(), _inputDir);
_destinationDir.mkdirs();
String resolverPathStr = _resolverPath.plus(getProject().files(_inputDir)).getAsPath();
FileCollection _pathedCodegenClasspath;
try {
_pathedCodegenClasspath = PathingJarUtil.generatePathingJar(getProject(), getName(), _codegenClasspath, false);
} catch (IOException e) {
throw new GradleException("Error occurred generating pathing JAR.", e);
}
getProject().javaexec(javaExecSpec -> {
String resolverPathArg = resolverPathStr;
if (isEnableArgFile()) {
resolverPathArg = ArgumentFileGenerator.getArgFileSyntax(ArgumentFileGenerator.createArgFile("generateAvro_resolverPath", Collections.singletonList(resolverPathArg), getTemporaryDir()));
}
javaExecSpec.setMain("com.linkedin.data.avro.generator.AvroSchemaGenerator");
javaExecSpec.setClasspath(_pathedCodegenClasspath);
javaExecSpec.jvmArgs("-Dgenerator.resolver.path=" + resolverPathArg);
String translateOptionalDefault = getTranslateOptionalDefault();
if (translateOptionalDefault != null) {
javaExecSpec.jvmArgs("-Dgenerator.avro.optional.default=" + translateOptionalDefault);
}
String overrideNamespace = getOverrideNamespace();
if (overrideNamespace != null) {
javaExecSpec.jvmArgs("-Dgenerator.avro.namespace.override=" + overrideNamespace);
}
String typeRefPropertiesExcludeList = getTypeRefPropertiesExcludeList();
if (typeRefPropertiesExcludeList == null) {
// unless overridden,
// by default gradle plugin tasks will set this to have "validate" "java" so it is backward compatible
typeRefPropertiesExcludeList = "validate,data";
}
javaExecSpec.jvmArgs(String.format("-D%s=%s", TYPERF_PROPERTIES_EXCLUDE, typeRefPropertiesExcludeList));
javaExecSpec.args(_destinationDir.getPath());
javaExecSpec.args(inputDataSchemaFilenames);
});
}
use of org.gradle.api.file.FileTree in project rest.li by linkedin.
the class GenerateDataTemplateTask method generate.
@TaskAction
public void generate() {
FileTree inputDataSchemaFiles = getSuffixedFiles(getProject(), _inputDir, PegasusPlugin.DATA_TEMPLATE_FILE_SUFFIXES);
List<String> inputDataSchemaFilenames = StreamSupport.stream(inputDataSchemaFiles.spliterator(), false).map(File::getPath).collect(Collectors.toList());
if (inputDataSchemaFilenames.isEmpty()) {
getLogger().lifecycle("There are no data schema input files. Skip generating data template.");
return;
}
getLogger().lifecycle("There are {} data schema input files. Using input root folder: {}", inputDataSchemaFilenames.size(), _inputDir);
_destinationDir.mkdirs();
String resolverPathStr = _resolverPath.plus(getProject().files(_inputDir)).getAsPath();
FileCollection _pathedCodegenClasspath;
try {
_pathedCodegenClasspath = PathingJarUtil.generatePathingJar(getProject(), "generateDataTemplate", _codegenClasspath, true);
} catch (IOException e) {
throw new GradleException("Error occurred generating pathing JAR.", e);
}
getProject().javaexec(javaExecSpec -> {
String resolverPathArg = resolverPathStr;
if (isEnableArgFile()) {
resolverPathArg = ArgumentFileGenerator.getArgFileSyntax(ArgumentFileGenerator.createArgFile("generateDataTemplate_resolverPath", Collections.singletonList(resolverPathArg), getTemporaryDir()));
}
javaExecSpec.setMain("com.linkedin.pegasus.generator.DataTemplateGeneratorCmdLineApp");
javaExecSpec.setClasspath(_pathedCodegenClasspath);
javaExecSpec.args("--resolverPath", resolverPathArg);
if (_generateLowercasePath != null && _generateLowercasePath == false) {
javaExecSpec.args("--generateCaseSensitivePath");
}
if (_generateImported != null && _generateImported == false) {
javaExecSpec.args("--skipImportedSchemas");
}
if (_generateFieldMask != null && _generateFieldMask == false) {
javaExecSpec.args("--skipFieldMask");
}
if (_resolverDirectories != null) {
javaExecSpec.args("--resolverSchemaDirectories", String.join(",", _resolverDirectories));
}
javaExecSpec.args("--rootPath", getProject().getRootDir().getPath());
javaExecSpec.args("--targetDir", _destinationDir.getPath());
javaExecSpec.args(_inputDir);
});
}
use of org.gradle.api.file.FileTree in project rest.li by linkedin.
the class ValidateExtensionSchemaTask method validateExtensionSchema.
@TaskAction
public void validateExtensionSchema() throws IOException {
FileTree inputDataSchemaFiles = getSuffixedFiles(getProject(), _inputDir, PegasusPlugin.DATA_TEMPLATE_FILE_SUFFIXES);
List<String> inputDataSchemaFilenames = StreamSupport.stream(inputDataSchemaFiles.spliterator(), false).map(File::getPath).collect(Collectors.toList());
if (inputDataSchemaFilenames.isEmpty()) {
getLogger().lifecycle("There are no extension schema input files. Skip validating extension schema");
return;
}
getProject().getLogger().info("Verifying extension schemas ...");
String resolverPathStr = _resolverPath.plus(getProject().files(_inputDir)).getAsPath();
FileCollection _pathedClasspath;
try {
_pathedClasspath = PathingJarUtil.generatePathingJar(getProject(), getName(), _classPath, false);
} catch (IOException e) {
throw new GradleException("Error occurred generating pathing JAR.", e);
}
getProject().javaexec(javaExecSpec -> {
String resolverPathArg = resolverPathStr;
if (isEnableArgFile()) {
resolverPathArg = ArgumentFileGenerator.getArgFileSyntax(ArgumentFileGenerator.createArgFile("validateExtensionSchema_resolverPath", Collections.singletonList(resolverPathArg), getTemporaryDir()));
}
javaExecSpec.setMain("com.linkedin.restli.tools.data.ExtensionSchemaValidationCmdLineApp");
javaExecSpec.setClasspath(_pathedClasspath);
javaExecSpec.args(resolverPathArg);
javaExecSpec.args(_inputDir.getAbsolutePath());
});
}
use of org.gradle.api.file.FileTree in project rest.li by linkedin.
the class GeneratePegasusSnapshotTask method generatePegasusSnapshot.
@TaskAction
public void generatePegasusSnapshot() {
FileTree inputDataSchemaFiles = _extensionSchema ? getSuffixedFiles(getProject(), _inputDir, PegasusPlugin.PDL_FILE_SUFFIX) : getSuffixedFiles(getProject(), _inputDir, PegasusPlugin.DATA_TEMPLATE_FILE_SUFFIXES);
List<String> inputDataSchemaFilenames = StreamSupport.stream(inputDataSchemaFiles.spliterator(), false).map(File::getPath).collect(Collectors.toList());
if (inputDataSchemaFilenames.isEmpty()) {
getLogger().lifecycle("There are no Pegasus schema input files. Skip generating Pegasus schema snapshots.");
return;
}
getLogger().info("Generating Pegasus schema snapshot...");
String resolverPathStr = _resolverPath.plus(getProject().files(_inputDir)).getAsPath();
FileCollection _pathedClasspath;
try {
_pathedClasspath = PathingJarUtil.generatePathingJar(getProject(), getName(), _classPath, false);
} catch (IOException e) {
throw new GradleException("Error occurred generating pathing JAR.", e);
}
getProject().javaexec(javaExecSpec -> {
String resolverPathArg = resolverPathStr;
if (isEnableArgFile()) {
resolverPathArg = ArgumentFileGenerator.getArgFileSyntax(ArgumentFileGenerator.createArgFile("generatePegasusSchemaSnapshot_resolverPath", Collections.singletonList(resolverPathArg), getTemporaryDir()));
}
javaExecSpec.setMain("com.linkedin.restli.tools.snapshot.gen.PegasusSchemaSnapshotGenerationCmdLineApp");
javaExecSpec.setClasspath(_pathedClasspath);
javaExecSpec.args(resolverPathArg);
javaExecSpec.args(_inputDir.getAbsolutePath());
javaExecSpec.args(_pegasusSchemaSnapshotDestinationDir);
});
}
Aggregations