/** * Returns the source set folder name given a file path. Assumes the source set name follows the "src" folder based on * the inputs received from GraphQLSourceDirectorySet. * * @return - sourceSet name */ private String getSourceSetNameFromFile(File file) { Path absolutePath = Paths.get(file.getAbsolutePath()); Path basePath = Paths.get(task.getProject().file("src").getAbsolutePath()); return basePath.relativize(absolutePath).toString().split(Matcher.quoteReplacement(File.separator))[0]; }
@Inject public OkBuckTask( OkBuckExtension okBuckExtension, KotlinExtension kotlinExtension, ScalaExtension scalaExtension, BuckFileManager buckFileManager) { this.okBuckExtension = okBuckExtension; this.kotlinExtension = kotlinExtension; this.scalaExtension = scalaExtension; this.buckFileManager = buckFileManager; // Never up to date; this task isn't safe to run incrementally. getOutputs().upToDateWhen(Specs.satisfyNone()); }
/** * Register an API Gateway API that should have its DefinitionBody property updated in the * Cloudformation template * * @param ref the Cloudformation Ref of the API to update * @param swagger the file containing the swagger definition of the API */ public void api(String ref, FileCollection swagger) { getInputs().files(swagger); apis.put(ref, swagger.getSingleFile()); }
schemaFile = Paths.get(schemaFilePath).toFile(); if (!schemaFile.exists()) { schemaFile = Paths.get(task.getProject().getProjectDir().getAbsolutePath(), schemaFilePath).toFile(); codegenArgs = codeGenArgs(task.getInputs().getSourceFiles().getFiles()); } else { Set<String> queryFilePaths = new HashSet<>(); for (File queryFile : queryFilesFrom(task.getInputs().getSourceFiles().getFiles())) { queryFilePaths.add(queryFile.getAbsolutePath());
private void configureApiTool(final Project project) { project.getTasks() .withType(ApiToolTask.class, task -> { ConventionMapping mapping = task.getConventionMapping(); mapping.map("mainClassName", () -> project.getProperties().get("mainClassName")); }); Map<String, Object> options = new HashMap<>(); options.put(Task.TASK_TYPE, ApiToolTask.class); options.put(Task.TASK_DEPENDS_ON, "classes"); options.put(Task.TASK_NAME, "joobyApiTool"); options .put(Task.TASK_DESCRIPTION, "Export your HTTP API to open standards like Swagger and RAML"); options.put(Task.TASK_GROUP, "jooby"); project.getTasks().create(options); }
@Override public void execute( final Report report ) { ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping(); reportMapping.map( "destination", new Callable<File>() { @Override public File call() { return reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() ); } } ); } } );
public static <T> CompositeDomainObjectSet<T> create(Class<T> type, DomainObjectCollection<? extends T>... collections) { //noinspection unchecked DefaultDomainObjectSet<T> backingSet = new DefaultDomainObjectSet<T>(type, new DomainObjectCompositeCollection()); CompositeDomainObjectSet<T> out = new CompositeDomainObjectSet<T>(backingSet); for (DomainObjectCollection<? extends T> c : collections) { out.addCollection(c); } return out; }
ClassPathRegistry createClassPathRegistry(ModuleRegistry moduleRegistry, PluginModuleRegistry pluginModuleRegistry) { return new DefaultClassPathRegistry( new DefaultClassPathProvider(moduleRegistry), new DynamicModulesClassPathProvider(moduleRegistry, pluginModuleRegistry)); }
public static Instantiator getOrCreate() { Instantiator instantiator = get(); if (instantiator != null) { return instantiator; } else { return new ClassGeneratorBackedInstantiator(new AsmBackedClassGenerator(), DirectInstantiator.INSTANCE); } } }
private LibraryVariant getLibraryVariant() { LibraryExtension libraryExtension = (LibraryExtension) getAndroidExtension(); Set<LibraryVariant> libraryVariants = libraryExtension .getLibraryVariants() .matching( libraryVariant -> libraryVariant.getName().equals(getMainTargetName(getName()))); Preconditions.checkArgument(libraryVariants.size() > 0); return libraryVariants.iterator().next(); } }
ClassPathRegistry createClassPathRegistry(ModuleRegistry moduleRegistry, WorkerProcessClassPathProvider workerProcessClassPathProvider) { return new DefaultClassPathRegistry( new DefaultClassPathProvider(moduleRegistry), workerProcessClassPathProvider ); }
public DefaultNamedDomainObjectCollection(Class<? extends T> type, Collection<T> store, Instantiator instantiator, Namer<? super T> namer) { super(type, store); this.instantiator = instantiator; this.namer = namer; this.index = new UnfilteredIndex<T>(); index(); }
@Override protected BaseVariant getBaseVariant() { LibraryExtension libraryExtension = (LibraryExtension) getAndroidExtension(); Optional<LibraryVariant> baseVariantOptional = libraryExtension .getLibraryVariants() .stream() .filter(variant -> variant.getName().equals(getName())) .findFirst(); Preconditions.checkArgument(baseVariantOptional.isPresent()); return baseVariantOptional.get(); }
/** * Returns the file path relative to the sourceSet directory * * @return path relative to sourceSet directory */ private String getPathRelativeToSourceSet(File file) { Path absolutePath = Paths.get(file.getAbsolutePath()); Path basePath = Paths.get(task.getProject().file("src").getAbsolutePath() + File.separator + getSourceSetNameFromFile(file)); return basePath.relativize(absolutePath).toString(); }
private void configureJoobyAssets(final Project project) { project.getTasks() .withType(AssetTask.class, task -> { ConventionMapping mapping = task.getConventionMapping(); mapping.map("env", () -> "dist"); mapping.map("maxAge", () -> "365d"); mapping.map("mainClassName", () -> project.getProperties().get("mainClassName")); mapping.map("output", () -> new JoobyProject(project).classes()); mapping.map("assemblyOutput", () -> new File(project.getBuildDir(), "__public_")); }); Map<String, Object> options = new HashMap<>(); options.put(Task.TASK_TYPE, AssetTask.class); options.put(Task.TASK_DEPENDS_ON, "classes"); options.put(Task.TASK_NAME, "joobyAssets"); options.put(Task.TASK_DESCRIPTION, "Process, optimize and compress static files"); options.put(Task.TASK_GROUP, "jooby"); project.getTasks().create(options); }
public ApolloCodegenInstallTask() { // TODO: set to const when ApolloPlugin is in java setGroup("apollo"); setDescription("Runs npm install for apollo-codegen"); installDir = getProject().file(getProject().getBuildDir() + File.separator + INSTALL_DIR); File workingDir = new File(getProject().getBuildDir(), "apollo-codegen"); setWorkingDir(workingDir); apolloPackageFile = getProject().file(workingDir + File.separator + "package.json"); final boolean isSameCodegenVersion = isSameApolloCodegenVersion(getApolloVersion()); if (!isSameCodegenVersion) { Utils.deleteDirectory(installDir); } getOutputs().upToDateWhen(new Spec<Task>() { public boolean isSatisfiedBy(Task element) { return apolloPackageFile.isFile() && isSameCodegenVersion; } }); }
/** * Register a lambda function that should have its CodeUri property updated in the Cloudformation * template * * @param ref the CloudFormation Ref of the function to update * @param zip the files containing the function's deployment package */ public void lambdaFunction(String ref, FileCollection zip) { getInputs().files(zip); lambdaFunctions.put(ref, zip.getSingleFile()); }
.getByType(LibraryExtension.class) .getLibraryVariants() .stream() .collect( ImmutableMap.toImmutableMap(
return file.getAbsolutePath(); }).toSet(), new File(outputFolder.getAbsolutePath() + File.separator + task.getProject().relativePath(f.getParent() ))));
private void configureJoobyRun(final Project project) { project.getTasks() .withType(JoobyTask.class, joobyRun -> { ConventionMapping mapping = joobyRun.getConventionMapping(); mapping.map("classpath", () -> new JoobyProject(project).classpath()); mapping.map("src", () -> new JoobyProject(project).sources()); mapping.map("mainClassName", () -> project.getProperties().get("mainClassName")); mapping.map("srcExtensions", () -> Arrays.asList(".java", ".conf", ".properties", ".kt")); mapping.map("compiler", () -> { File eclipseClasspath = new File(project.getProjectDir(), ".classpath"); return eclipseClasspath.exists() ? "off" : "on"; }); Gradle gradle = project.getGradle(); mapping.map("block", () -> !gradle.getStartParameter().isContinuous()); mapping.map("logLevel", () -> gradle.getStartParameter().getLogLevel().name()); }); Map<String, Object> options = new HashMap<>(); options.put(Task.TASK_TYPE, JoobyTask.class); options.put(Task.TASK_DEPENDS_ON, "classes"); options.put(Task.TASK_NAME, "joobyRun"); options.put(Task.TASK_DESCRIPTION, "Run, debug and hot reload applications"); options.put(Task.TASK_GROUP, "jooby"); project.getTasks().create(options); }