public void execute(final DefaultPluginManager.PluginWithId pluginWithId) { matching(new Spec<Plugin>() { public boolean isSatisfiedBy(Plugin element) { return pluginWithId.clazz.equals(element.getClass()); } }).all(action); } };
@Nullable private static String getTestBuildType(Project project) { PluginCollection<AppPlugin> appPlugins = project.getPlugins().withType(AppPlugin.class); if (!appPlugins.isEmpty()) { AppExtension androidExtension = project.getExtensions().getByType(AppExtension.class); return androidExtension.getTestBuildType(); } PluginCollection<LibraryPlugin> libPlugins = project.getPlugins().withType(LibraryPlugin.class); if (!libPlugins.isEmpty()) { LibraryExtension androidExtension = project.getExtensions().getByType(LibraryExtension.class); return androidExtension.getTestBuildType(); } return null; }
private void applyJavaBased( final Project project ) { if ( project.getPlugins().hasPlugin( JavaPlugin.class ) ) { createUnpackDevTask( project ); } else { project.getPlugins().withType( JavaPlugin.class ).whenPluginAdded( plugin -> createUnpackDevTask( project ) ); } }
private void applyJavaBased( final Project project ) { if ( project.getPlugins().hasPlugin( JavaPlugin.class ) ) { createUnpackDevTask( project ); } else { project.getPlugins().withType( JavaPlugin.class ).whenPluginAdded( plugin -> createUnpackDevTask( project ) ); } }
/** * Configure things that need to be configured exactly if the WarPlugin has been enabled */ private void configureWarPluginSettings(final Project project, final RebelGenerateTask generateRebelTask, final IConventionAware conventionAwareRebelTask, final RebelDslMain rebelExtension) { // 'execute' will be run if WarPlugin is already applied, or if it will be applied later during the configuration lifecycle project.getPlugins().withType(WarPlugin.class).all(new Action<Plugin>() { public void execute(Plugin p) { generateRebelTask.setPackaging(RebelGenerateTask.PACKAGING_TYPE_WAR); // Propagate 'defaultWebappDirectory' conventionAwareRebelTask.getConventionMapping().map(RebelGenerateTask.NAME_DEFAULT_WEBAPP_DIRECTORY, new Callable<Object>() { public Object call() throws Exception { try { WarPluginConvention warConvention = project.getConvention().getPlugin(WarPluginConvention.class); return warConvention.getWebAppDir(); } catch (Exception e) { return null; } } }); } }); }
@Nullable private static String getTestBuildType(Project project) { PluginCollection<AppPlugin> appPlugins = project.getPlugins().withType(AppPlugin.class); if (!appPlugins.isEmpty()) { AppExtension androidExtension = project.getExtensions().getByType(AppExtension.class); return androidExtension.getTestBuildType(); } PluginCollection<LibraryPlugin> libPlugins = project.getPlugins().withType(LibraryPlugin.class); if (!libPlugins.isEmpty()) { LibraryExtension androidExtension = project.getExtensions().getByType(LibraryExtension.class); return androidExtension.getTestBuildType(); } return null; }
/** * Configure things that need to be configured exactly if the WarPlugin has been enabled */ private void configureWarPluginSettings(final Project project, final RebelGenerateTask generateRebelTask, final IConventionAware conventionAwareRebelTask, final RebelDslMain rebelExtension) { // 'execute' will be run if WarPlugin is already applied, or if it will be applied later during the configuration lifecycle project.getPlugins().withType(WarPlugin.class).all(new Action<Plugin>() { public void execute(Plugin p) { generateRebelTask.setPackaging(RebelGenerateTask.PACKAGING_TYPE_WAR); // Propagate 'defaultWebappDirectory' conventionAwareRebelTask.getConventionMapping().map(RebelGenerateTask.NAME_DEFAULT_WEBAPP_DIRECTORY, new Callable<Object>() { public Object call() throws Exception { try { WarPluginConvention warConvention = project.getConvention().getPlugin(WarPluginConvention.class); return warConvention.getWebAppDir(); } catch (Exception e) { return null; } } }); } }); }
@Nullable private static List<File> getBootClasspath(Project project) { PluginCollection<AppPlugin> appPlugins = project.getPlugins().withType(AppPlugin.class); if (!appPlugins.isEmpty()) { AppExtension androidExtension = project.getExtensions().getByType(AppExtension.class); return androidExtension.getBootClasspath(); } PluginCollection<LibraryPlugin> libPlugins = project.getPlugins().withType(LibraryPlugin.class); if (!libPlugins.isEmpty()) { LibraryExtension androidExtension = project.getExtensions().getByType(LibraryExtension.class); return androidExtension.getBootClasspath(); } PluginCollection<TestPlugin> testPlugins = project.getPlugins().withType(TestPlugin.class); if (!testPlugins.isEmpty()) { TestExtension androidExtension = project.getExtensions().getByType(TestExtension.class); return androidExtension.getBootClasspath(); } return null; }
private static void configureIntelliJ(final Project project) { project.getPlugins().withType(IdeaPlugin.class).all(new Action<IdeaPlugin>() { @Override public void execute(IdeaPlugin ideaPlugin) {
@Nullable private static List<File> getBootClasspath(Project project) { PluginCollection<AppPlugin> appPlugins = project.getPlugins().withType(AppPlugin.class); if (!appPlugins.isEmpty()) { AppExtension androidExtension = project.getExtensions().getByType(AppExtension.class); return androidExtension.getBootClasspath(); } PluginCollection<LibraryPlugin> libPlugins = project.getPlugins().withType(LibraryPlugin.class); if (!libPlugins.isEmpty()) { LibraryExtension androidExtension = project.getExtensions().getByType(LibraryExtension.class); return androidExtension.getBootClasspath(); } PluginCollection<TestPlugin> testPlugins = project.getPlugins().withType(TestPlugin.class); if (!testPlugins.isEmpty()) { TestExtension androidExtension = project.getExtensions().getByType(TestExtension.class); return androidExtension.getBootClasspath(); } return null; }
public void apply(final Project project) { log = new LoggerWrapper(project.getLogger()); // register the Rebel task project.getTasks().create(GENERATE_REBEL_TASK_NAME, RebelGenerateTask.class).setDescription("Generate rebel.xml mappings file to use this project with JRebel."); // only configure the real one if JavaPlugin gets enabled (it is pulled in by Groovy, Scala, War, ...) project.getLogger().info("Registering deferred Rebel plugin configuration..."); project.getPlugins().withType(JavaPlugin.class).all(new Action<Plugin>() { public void execute(Plugin p) { configure(project); } }); }
@Nullable static BaseVariant findVariant(Project project, @Nullable String userConfiguredBuildVariantName) { String testBuildType = getTestBuildType(project); PluginCollection<AppPlugin> appPlugins = project.getPlugins().withType(AppPlugin.class); if (!appPlugins.isEmpty()) { AppExtension androidExtension = project.getExtensions().getByType(AppExtension.class); return findVariant(new ArrayList<>(androidExtension.getApplicationVariants()), testBuildType, userConfiguredBuildVariantName); } PluginCollection<LibraryPlugin> libPlugins = project.getPlugins().withType(LibraryPlugin.class); if (!libPlugins.isEmpty()) { LibraryExtension androidExtension = project.getExtensions().getByType(LibraryExtension.class); return findVariant(new ArrayList<>(androidExtension.getLibraryVariants()), testBuildType, userConfiguredBuildVariantName); } PluginCollection<TestPlugin> testPlugins = project.getPlugins().withType(TestPlugin.class); if (!testPlugins.isEmpty()) { TestExtension androidExtension = project.getExtensions().getByType(TestExtension.class); return findVariant(new ArrayList<>(androidExtension.getApplicationVariants()), testBuildType, userConfiguredBuildVariantName); } return null; }
public void apply(final Project project) { log = new LoggerWrapper(project.getLogger()); // register the Rebel task project.getTasks().create(GENERATE_REBEL_TASK_NAME, RebelGenerateTask.class).setDescription("Generate rebel.xml mappings file to use this project with JRebel."); // only configure the real one if JavaPlugin gets enabled (it is pulled in by Groovy, Scala, War, ...) project.getLogger().info("Registering deferred Rebel plugin configuration..."); project.getPlugins().withType(JavaPlugin.class).all(new Action<Plugin>() { public void execute(Plugin p) { configure(project); } }); }
@Nullable static BaseVariant findVariant(Project project, @Nullable String userConfiguredBuildVariantName) { String testBuildType = getTestBuildType(project); PluginCollection<AppPlugin> appPlugins = project.getPlugins().withType(AppPlugin.class); if (!appPlugins.isEmpty()) { AppExtension androidExtension = project.getExtensions().getByType(AppExtension.class); return findVariant(new ArrayList<>(androidExtension.getApplicationVariants()), testBuildType, userConfiguredBuildVariantName); } PluginCollection<LibraryPlugin> libPlugins = project.getPlugins().withType(LibraryPlugin.class); if (!libPlugins.isEmpty()) { LibraryExtension androidExtension = project.getExtensions().getByType(LibraryExtension.class); return findVariant(new ArrayList<>(androidExtension.getLibraryVariants()), testBuildType, userConfiguredBuildVariantName); } PluginCollection<TestPlugin> testPlugins = project.getPlugins().withType(TestPlugin.class); if (!testPlugins.isEmpty()) { TestExtension androidExtension = project.getExtensions().getByType(TestExtension.class); return findVariant(new ArrayList<>(androidExtension.getApplicationVariants()), testBuildType, userConfiguredBuildVariantName); } return null; }
@Override public void apply(Project project) { project.getPlugins().matching(p -> p instanceof AppPlugin || p instanceof LibraryPlugin) .all(c -> { BaseExtension baseExtension = (BaseExtension) project.getExtensions().getByName("android"); project.getExtensions().create(NAME, GradleCaptExtension.class, project.container(CaptPluginExtension.class)); VariantManager variantManager = new VariantManager(createGlobalResource(project, baseExtension), baseExtension, project); // callCreate configurations for separate variant variantManager.createConfigurationForVariant(); CaptTransform captTransform = new CaptTransform(variantManager); baseExtension.registerTransform(captTransform); }); }