private void attachTasksToBinary( ClassDirectoryBinarySpecInternal binary, SourceSet sourceSet, Project target) { Task compileTask = target.getTasks().getByPath(sourceSet.getCompileJavaTaskName()); Task resourcesTask = target.getTasks().getByPath(sourceSet.getProcessResourcesTaskName()); Task classesTask = target.getTasks().getByPath(sourceSet.getClassesTaskName()); binary.getTasks().add(compileTask); binary.getTasks().add(resourcesTask); binary.getTasks().add(classesTask); binary.setBuildTask(classesTask); }
private void configureTest(final Project project, final JavaPluginConvention convention) { project .getTasks() .withType( Test.class, new Action<Test>() { public void execute(Test test) { configureTestDefaults(test, project, convention); } }); project.afterEvaluate( new Action<Project>() { public void execute(Project project) { project .getTasks() .withType( Test.class, new Action<Test>() { public void execute(Test test) { overwriteIncludesIfSinglePropertyIsSet(test); overwriteDebugIfDebugPropertyIsSet(test); } }); } }); }
private void configureBuildDependents(Project project) { DefaultTask buildTask = project.getTasks().add(BUILD_DEPENDENTS_TASK_NAME, DefaultTask.class); buildTask.setDescription( "Assembles and tests this project and all projects that depend on it."); buildTask.setGroup(BasePlugin.BUILD_GROUP); buildTask.dependsOn(BUILD_TASK_NAME); }
private void configureBuild(Project project) { DefaultTask buildTask = project.getTasks().add(BUILD_TASK_NAME, DefaultTask.class); buildTask.setDescription("Assembles and tests this project."); buildTask.setGroup(BasePlugin.BUILD_GROUP); buildTask.dependsOn(BasePlugin.ASSEMBLE_TASK_NAME); buildTask.dependsOn(CHECK_TASK_NAME); }
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) { project .getTasks() .withType( Javadoc.class, new Action<Javadoc>() { public void execute(Javadoc javadoc) { javadoc .getConventionMapping() .map( "destinationDir", new Callable<Object>() { public Object call() throws Exception { return new File(convention.getDocsDir(), "javadoc"); } }); javadoc .getConventionMapping() .map( "title", new Callable<Object>() { public Object call() throws Exception { return project .getExtensions() .getByType(ReportingExtension.class) .getApiDocTitle(); } }); } }); }
private void configureCompileDefaults( final Project project, final JavaPluginConvention javaConvention) { project .getTasks() .withType( AbstractCompile.class, new Action<AbstractCompile>() { public void execute(final AbstractCompile compile) { ConventionMapping conventionMapping = compile.getConventionMapping(); conventionMapping.map( "sourceCompatibility", new Callable<Object>() { public Object call() throws Exception { return javaConvention.getSourceCompatibility().toString(); } }); conventionMapping.map( "targetCompatibility", new Callable<Object>() { public Object call() throws Exception { return javaConvention.getTargetCompatibility().toString(); } }); } }); project .getTasks() .withType( JavaCompile.class, new Action<JavaCompile>() { public void execute(final JavaCompile compile) { ConventionMapping conventionMapping = compile.getConventionMapping(); conventionMapping.map( "dependencyCacheDir", new Callable<Object>() { public Object call() throws Exception { return javaConvention.getDependencyCacheDir(); } }); } }); }
private void createProcessResourcesTaskForBinary( final SourceSet sourceSet, JvmResourceSet resourceSet, final Project target) { Copy resourcesTask = target.getTasks().create(sourceSet.getProcessResourcesTaskName(), ProcessResources.class); resourcesTask.setDescription(String.format("Processes %s.", resourceSet)); new DslObject(resourcesTask) .getConventionMapping() .map( "destinationDir", new Callable<File>() { public File call() throws Exception { return sourceSet.getOutput().getResourcesDir(); } }); resourcesTask.from(resourceSet.getSource()); }
public void apply(final Project project) { RepositoryHandler repositories = publicationServices.createRepositoryHandler(); PublicationContainer publications = instantiator.newInstance(DefaultPublicationContainer.class, instantiator); // TODO Registering an extension should register it with the model registry as well final PublishingExtension extension = project .getExtensions() .create( PublishingExtension.NAME, DefaultPublishingExtension.class, repositories, publications); project.afterEvaluate( new Action<Project>() { public void execute(Project project) { for (Publication publication : extension.getPublications()) { PublicationInternal internalPublication = (PublicationInternal) publication; publicationRegistry.registerPublication( project.getPath(), new DefaultProjectPublication(internalPublication.getCoordinates())); } } }); ModelPath extensionModelPath = ModelPath.path(PublishingExtension.NAME); modelRules.register(extensionModelPath.toString(), extension); modelRules.rule( new ModelRule() { public void triggerDeferredConfigurables(PublishingExtension publishingExtension) { project.getExtensions().getByType(DefaultPublishingExtension.class); } }); Task publishLifecycleTask = project.getTasks().create(PUBLISH_LIFECYCLE_TASK_NAME); publishLifecycleTask.setDescription("Publishes all publications produced by this project."); publishLifecycleTask.setGroup(PUBLISH_TASK_GROUP); }
private void createCompileJavaTaskForBinary( final SourceSet sourceSet, final JavaSourceSet javaSourceSet, Project target) { JavaCompile compileTask = target.getTasks().create(sourceSet.getCompileJavaTaskName(), JavaCompile.class); compileTask.setDescription(String.format("Compiles %s.", javaSourceSet)); compileTask.setSource(javaSourceSet.getSource()); compileTask.dependsOn(javaSourceSet); ConventionMapping conventionMapping = compileTask.getConventionMapping(); conventionMapping.map( "classpath", new Callable<Object>() { public Object call() throws Exception { return javaSourceSet.getCompileClasspath().getFiles(); } }); conventionMapping.map( "destinationDir", new Callable<Object>() { public Object call() throws Exception { return sourceSet.getOutput().getClassesDir(); } }); }
private void configureBuildNeeded(Project project) { DefaultTask buildTask = project.getTasks().add(BUILD_NEEDED_TASK_NAME, DefaultTask.class); buildTask.setDescription("Assembles and tests this project and all projects it depends on."); buildTask.setGroup(BasePlugin.BUILD_GROUP); buildTask.dependsOn(BUILD_TASK_NAME); }
private void configureCheck(final Project project) { Task checkTask = project.getTasks().add(CHECK_TASK_NAME); checkTask.setDescription("Runs all checks."); checkTask.setGroup(VERIFICATION_GROUP); }