private boolean isJavaProject() { return getProject().getPluginManager().hasPlugin("java"); } }
/** * Apply the Checkstyle rules for Eclipse Java projects * * @param project Project to apply rules to */ protected void applyEclipseRules(Project project) { if (project.getPluginManager().hasPlugin("java") && project.getPluginManager().hasPlugin("eclipse")) { getProject().getPluginManager().apply(EclipseJavaRules.class); } } }
/** * Apply the Checkstyle rules for Eclipse Java projects * * @param project Project to apply rules to */ protected void applyEclipseRules(Project project) { if (project.getPluginManager().hasPlugin("java") && project.getPluginManager().hasPlugin("eclipse")) { getProject().getPluginManager().apply(EclipseJavaRules.class); } } }
public static BouquetPluginConfig create(Project project) { if (project.getPluginManager().hasPlugin(ANDROID_APP.getPluginName())) { return new BouquetPluginAndroidConfig(project, ANDROID_APP); } else if (project.getPluginManager().hasPlugin(ANDROID_LIBRARY.getPluginName())) { return new BouquetPluginAndroidConfig(project, ANDROID_LIBRARY); } else if (project.getPluginManager().hasPlugin(JAVA_APP.getPluginName())) { return new BouquetPluginJavaConfig(project, JAVA_APP); } else if (project.getPluginManager().hasPlugin(JAVA_LIBRARY.getPluginName())) { return new BouquetPluginJavaConfig(project, JAVA_LIBRARY); } else { throw new TaskInstantiationException("Android or Java plugins required"); } }
@Test(expected = TaskInstantiationException.class) public void createInvalidProjectType() { PluginManager pluginManager = mock(PluginManager.class); when(project.getPluginManager()).thenReturn(pluginManager); when(pluginManager.hasPlugin(anyString())).thenReturn(false); BouquetPluginConfigFactory.create(project); } }
private void assertAppYaml(Project p) { assertTrue(p.getPluginManager().hasPlugin("com.google.cloud.tools.appengine")); assertTrue(p.getPluginManager().hasPlugin("com.google.cloud.tools.appengine-appyaml")); assertFalse(p.getPluginManager().hasPlugin("com.google.cloud.tools.appengine-standard")); } }
private void assertStandard(Project p) { assertTrue(p.getPluginManager().hasPlugin("com.google.cloud.tools.appengine")); assertTrue(p.getPluginManager().hasPlugin("com.google.cloud.tools.appengine-standard")); assertFalse(p.getPluginManager().hasPlugin("com.google.cloud.tools.appengine-appyaml")); }
@Test public void create() { PluginManager pluginManager = mock(PluginManager.class); when(project.getPluginManager()).thenReturn(pluginManager); when(pluginManager.hasPlugin(ANDROID_APP.getPluginName())).thenReturn(true).thenReturn(false).thenReturn(false).thenReturn(false); when(pluginManager.hasPlugin(ANDROID_LIBRARY.getPluginName())).thenReturn(true).thenReturn(false).thenReturn(false); when(pluginManager.hasPlugin(JAVA_APP.getPluginName())).thenReturn(true).thenReturn(false); when(pluginManager.hasPlugin(JAVA_LIBRARY.getPluginName())).thenReturn(true); BouquetPluginConfig bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginAndroidConfig.class); bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginAndroidConfig.class); bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginJavaConfig.class); bouquetPluginConfig = BouquetPluginConfigFactory.create(project); assertEquals(bouquetPluginConfig.getClass(), BouquetPluginJavaConfig.class); }
@Override public void execute(Task task) { if (configuration.getFiles().size() != 1) { throw new IllegalArgumentException("Expected to find exactly one config dependency in the " + "'baseline' configuration, found: " + configuration.getFiles()); } rootProject.copy(copySpec -> { copySpec.from(rootProject.zipTree(configuration.getSingleFile())); copySpec.into(BaselineConfig.this.getConfigDir()); copySpec.exclude("**/scalastyle_config.xml"); copySpec.setIncludeEmptyDirs(false); }); if (rootProject .getAllprojects() .stream() .anyMatch(p -> p.getPluginManager().hasPlugin("scala") && p .getPluginManager() .hasPlugin("com.palantir.baseline-scalastyle"))) { // Matches intellij scala plugin settings per // https://github.com/JetBrains/intellij-scala/blob/baaa7c1dabe5222c4bca7c4dd8d80890ad2a8c6b/scala/scala-impl/src/org/jetbrains/plugins/scala/codeInspection/scalastyle/ScalastyleCodeInspection.scala#L19 rootProject.copy(copySpec -> { copySpec.from(rootProject .zipTree(configuration.getSingleFile()) .filter(file -> file.getName().equals("scalastyle_config.xml"))); copySpec.into(rootProject.getRootDir().toPath().resolve("project")); copySpec.setIncludeEmptyDirs(false); }); } } }