org.gradle.api.plugins.WarPlugin Java Examples

The following examples show how to use org.gradle.api.plugins.WarPlugin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureAbstractJettyTask(final Project project, final JettyPluginConvention jettyConvention, AbstractJettyRunTask jettyTask) {
    jettyTask.setDaemon(false);
    jettyTask.setReload(RELOAD_AUTOMATIC);
    jettyTask.setScanIntervalSeconds(0);
    jettyTask.getConventionMapping().map("contextPath", new Callable<Object>() {
        public Object call() throws Exception {
            return ((War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME)).getBaseName();
        }
    });
    jettyTask.getConventionMapping().map("httpPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getHttpPort();
        }
    });
    jettyTask.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyTask.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #2
Source File: ThorntailUtils.java    From thorntail with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the most suitable Archive-Task for wrapping in the swarm jar - in the following order:
 * <p>
 * 1. Custom-JAR-Task defined in ThorntailExtension 'archiveTask'
 * 2. WAR-Task
 * 3. JAR-Task
 */
public static Jar getArchiveTask(Project project) {

    TaskCollection<Jar> existingArchiveTasks = project.getTasks().withType(Jar.class);
    Jar customArchiveTask = project.getExtensions().getByType(ThorntailExtension.class).getArchiveTask();

    if (customArchiveTask != null) {
        return existingArchiveTasks.getByName(customArchiveTask.getName());

    } else if (existingArchiveTasks.findByName(WarPlugin.WAR_TASK_NAME) != null) {
        return existingArchiveTasks.getByName(WarPlugin.WAR_TASK_NAME);

    } else if (existingArchiveTasks.findByName(JavaPlugin.JAR_TASK_NAME) != null) {
        return existingArchiveTasks.getByName(JavaPlugin.JAR_TASK_NAME);
    }

    throw new GradleException("Unable to detect Archive-Task: project contains neither 'war' nor 'jar', " +
            "nor is custom Archive-Task specified in the \"thorntail\" extension.");
}
 
Example #3
Source File: MultiModuleTestProject.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Build and evaluate multi-module project.
 *
 * @return root project
 */
public Project build() throws IOException {
  Project rootProject = ProjectBuilder.builder().withProjectDir(projectRoot).build();
  for (String module : modules) {
    Project p = ProjectBuilder.builder().withName(module).withParent(rootProject).build();

    // Create an appengine-web.xml for each module
    Path webInf = p.getProjectDir().toPath().resolve("src/main/webapp/WEB-INF");
    Files.createDirectories(webInf);
    File appengineWebXml = Files.createFile(webInf.resolve("appengine-web.xml")).toFile();
    Files.write(appengineWebXml.toPath(), "<appengine-web-app/>".getBytes(Charsets.UTF_8));

    p.getPluginManager().apply(JavaPlugin.class);
    p.getPluginManager().apply(WarPlugin.class);
    p.getPluginManager().apply(AppEngineStandardPlugin.class);

    DeployExtension deploy =
        p.getExtensions().getByType(AppEngineStandardExtension.class).getDeploy();
    deploy.setProjectId("project");
    deploy.setVersion("version");
  }
  ((ProjectInternal) rootProject).evaluate();
  return rootProject;
}
 
Example #4
Source File: WarAttachClassesPlugin.java    From gradle-plugins with MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);

    WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention();

    project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class, war ->
            war.getConvention().getPlugins().put("attachClasses", attachClassesConvention)
    );

    project.afterEvaluate(p -> {
        if (attachClassesConvention.isAttachClasses()) {
            TaskProvider<Jar> jar = project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class, j ->
                    j.getArchiveClassifier().convention(attachClassesConvention.getClassesClassifier())
            );

            project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar);
        }
    });
}
 
Example #5
Source File: AppEngineStandardExtensionTest.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
private Project setUpTestProject(String buildFileName) throws IOException {
  Path buildFile = testProjectDir.getRoot().toPath().resolve("build.gradle");
  InputStream buildFileContent =
      getClass()
          .getClassLoader()
          .getResourceAsStream(
              "projects/AppEnginePluginTest/Extension/" + buildFileName + ".gradle");
  Files.copy(buildFileContent, buildFile);

  Path webInf = testProjectDir.getRoot().toPath().resolve("src/main/webapp/WEB-INF");
  Files.createDirectories(webInf);
  File appengineWebXml = Files.createFile(webInf.resolve("appengine-web.xml")).toFile();
  Files.write(appengineWebXml.toPath(), "<appengine-web-app/>".getBytes(Charsets.UTF_8));

  Project p = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build();
  p.getPluginManager().apply(JavaPlugin.class);
  p.getPluginManager().apply(WarPlugin.class);
  p.getPluginManager().apply(AppEngineStandardPlugin.class);
  ((ProjectInternal) p).evaluate();

  return p;
}
 
Example #6
Source File: JSassWarPlugin.java    From gradle-plugins with MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {

    project.getPlugins().apply(JSassWebjarsPlugin.class);
    project.getPlugins().apply(WarPlugin.class);

    TaskProvider<SassCompile> sassCompileTaskProvider = project.getTasks().register("compileWebappSass", SassCompile.class, compileWebappSass -> {
        compileWebappSass.setGroup(BasePlugin.BUILD_GROUP);
        compileWebappSass.setDescription("Compile sass and scss files for the webapp");

        WarPluginConvention warPluginConvention = project.getConvention().getPlugin(WarPluginConvention.class);
        compileWebappSass.source(warPluginConvention.getWebAppDir());

        compileWebappSass.getDestinationDir().set(new File(project.getBuildDir(), "jsass/webapp"));
    });

    project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class)
            .configure(war -> war.from(sassCompileTaskProvider));
}
 
Example #7
Source File: AppEngineStandardPlugin.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
private void createExplodedWarTask() {
  project
      .getTasks()
      .create(
          EXPLODE_WAR_TASK_NAME,
          ExplodeWarTask.class,
          explodeWar -> {
            explodeWar.setExplodedAppDirectory(explodedWarDir);
            explodeWar.dependsOn(WarPlugin.WAR_TASK_NAME);
            explodeWar.setGroup(APP_ENGINE_STANDARD_TASK_GROUP);
            explodeWar.setDescription("Explode a war into a directory");

            project.afterEvaluate(
                project ->
                    explodeWar.setWarFile(
                        ((War) project.getTasks().getByPath(WarPlugin.WAR_TASK_NAME))
                            .getArchivePath()));
          });
  project.getTasks().getByName(BasePlugin.ASSEMBLE_TASK_NAME).dependsOn(EXPLODE_WAR_TASK_NAME);
}
 
Example #8
Source File: JSassWarPlugin.java    From gradle-plugins with MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {

    project.getPlugins().apply(JSassWebjarsPlugin.class);
    project.getPlugins().apply(WarPlugin.class);

    TaskProvider<SassCompile> sassCompileTaskProvider = project.getTasks().register("compileWebappSass", SassCompile.class, compileWebappSass -> {
        compileWebappSass.setGroup(BasePlugin.BUILD_GROUP);
        compileWebappSass.setDescription("Compile sass and scss files for the webapp");

        WarPluginConvention warPluginConvention = project.getConvention().getPlugin(WarPluginConvention.class);
        compileWebappSass.source(warPluginConvention.getWebAppDir());

        compileWebappSass.getDestinationDir().set(new File(project.getBuildDir(), "jsass/webapp"));
    });

    project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class)
            .configure(war -> war.from(sassCompileTaskProvider));
}
 
Example #9
Source File: JettyServerBuilder.java    From putnami-gradle-plugin with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void configure(Project project, JettyOption jettyOption, File jettyConf) {
	ConfigurationContainer configs = project.getConfigurations();

	Configuration runtimeConf = configs.getByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME);
	Configuration jettyClassPath = configs.getByName(PwtLibPlugin.CONF_JETTY);

	configureJavaArgs(jettyOption);

	addClassPath(jettyClassPath.getAsPath());
	addClassPath(runtimeConf.getAsPath());

	if (jettyOption.getLogRequestFile() != null) {
		ResourceUtils.ensureDir(jettyOption.getLogRequestFile().getParentFile());
		addArg("--log", jettyOption.getLogRequestFile());
	}
	if (jettyOption.getLogFile() != null) {
		ResourceUtils.ensureDir(jettyOption.getLogFile().getParentFile());
		addArg("--out", jettyOption.getLogFile());
	}
	addArg("--host", jettyOption.getBindAddress());
	addArg("--port", jettyOption.getPort());
	addArg("--stop-port", jettyOption.getStopPort());
	addArg("--stop-key", jettyOption.getStopKey());

	addArg(jettyConf.getAbsolutePath());
}
 
Example #10
Source File: WarAttachClassesPlugin.java    From gradle-plugins with MIT License 6 votes vote down vote up
@Override
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);

    WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention();

    project.getTasks().named(WarPlugin.WAR_TASK_NAME, War.class, war ->
            war.getConvention().getPlugins().put("attachClasses", attachClassesConvention)
    );

    project.afterEvaluate(p -> {
        if (attachClassesConvention.isAttachClasses()) {
            TaskProvider<Jar> jar = project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class, j ->
                    j.getArchiveClassifier().convention(attachClassesConvention.getClassesClassifier())
            );

            project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar);
        }
    });
}
 
Example #11
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureAbstractJettyTask(final Project project, final JettyPluginConvention jettyConvention, AbstractJettyRunTask jettyTask) {
    jettyTask.setDaemon(false);
    jettyTask.setReload(RELOAD_AUTOMATIC);
    jettyTask.setScanIntervalSeconds(0);
    jettyTask.getConventionMapping().map("contextPath", new Callable<Object>() {
        public Object call() throws Exception {
            return ((War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME)).getBaseName();
        }
    });
    jettyTask.getConventionMapping().map("httpPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getHttpPort();
        }
    });
    jettyTask.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyTask.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #12
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureAbstractJettyTask(final Project project, final JettyPluginConvention jettyConvention, AbstractJettyRunTask jettyTask) {
    jettyTask.setDaemon(false);
    jettyTask.setReload(RELOAD_AUTOMATIC);
    jettyTask.setScanIntervalSeconds(0);
    jettyTask.getConventionMapping().map("contextPath", new Callable<Object>() {
        public Object call() throws Exception {
            return ((War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME)).getBaseName();
        }
    });
    jettyTask.getConventionMapping().map("httpPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getHttpPort();
        }
    });
    jettyTask.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyTask.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #13
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureAbstractJettyTask(final Project project, final JettyPluginConvention jettyConvention, AbstractJettyRunTask jettyTask) {
    jettyTask.setDaemon(false);
    jettyTask.setReload(RELOAD_AUTOMATIC);
    jettyTask.setScanIntervalSeconds(0);
    jettyTask.getConventionMapping().map("contextPath", new Callable<Object>() {
        public Object call() throws Exception {
            return ((War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME)).getBaseName();
        }
    });
    jettyTask.getConventionMapping().map("httpPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getHttpPort();
        }
    });
    jettyTask.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyTask.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #14
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);
    JettyPluginConvention jettyConvention = new JettyPluginConvention();
    Convention convention = project.getConvention();
    convention.getPlugins().put("jetty", jettyConvention);

    configureMappingRules(project, jettyConvention);
    configureJettyRun(project);
    configureJettyRunWar(project);
    configureJettyStop(project, jettyConvention);
}
 
Example #15
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJettyStop(Project project, final JettyPluginConvention jettyConvention) {
    JettyStop jettyStop = project.getTasks().create(JETTY_STOP, JettyStop.class);
    jettyStop.setDescription("Stops Jetty.");
    jettyStop.setGroup(WarPlugin.WEB_APP_GROUP);
    jettyStop.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyStop.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #16
Source File: PwtPlugin.java    From putnami-gradle-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void apply(final Project project) {
	LOGGER.debug("apply pwt plugin");
	project.getPlugins().apply(PwtLibPlugin.class);
	project.getPlugins().apply(WarPlugin.class);

	// createSetUpTask(project);
	createCheckTask(project);
	createCompileTask(project);
	createCodeServerTask(project);
	createDevTask(project);
	createRunTask(project);
	createStopTask(project);
}
 
Example #17
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);
    JettyPluginConvention jettyConvention = new JettyPluginConvention();
    Convention convention = project.getConvention();
    convention.getPlugins().put("jetty", jettyConvention);

    configureMappingRules(project, jettyConvention);
    configureJettyRun(project);
    configureJettyRunWar(project);
    configureJettyStop(project, jettyConvention);
}
 
Example #18
Source File: WarOverlayPluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void testProperties() {
    Project project = ProjectBuilder.builder().build();

    project.getPlugins().apply(WarPlugin.class);
    project.getPlugins().apply(WarOverlayPlugin.class);

    Task warTask = project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);

    assertThat(warTask.hasProperty("overlays")).isTrue();
    assertThat(warTask.property("overlays")).isInstanceOf(DomainObjectCollection.class);
}
 
Example #19
Source File: WarAttachClassesPluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void testProperties() {
    project.getPlugins().apply(WarPlugin.class);
    project.getPlugins().apply(WarAttachClassesPlugin.class);

    War warTask = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);

    assertThat(warTask.hasProperty("attachClasses")).isTrue();
    assertThat(warTask.property("attachClasses")).isInstanceOf(Boolean.class);

    assertThat(warTask.hasProperty("classesClassifier")).isTrue();
    assertThat(warTask.property("classesClassifier")).isInstanceOf(String.class);
}
 
Example #20
Source File: WarArchiveClassesPluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void testArchiveClassesProperty() {
    project.getPlugins().apply(WarPlugin.class);
    project.getPlugins().apply(WarArchiveClassesPlugin.class);

    War warTask = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);

    assertThat(warTask.hasProperty("archiveClasses")).isTrue();
    assertThat(warTask.property("archiveClasses")).isInstanceOf(Boolean.class);
}
 
Example #21
Source File: JettyPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJettyStop(Project project, final JettyPluginConvention jettyConvention) {
    JettyStop jettyStop = project.getTasks().create(JETTY_STOP, JettyStop.class);
    jettyStop.setDescription("Stops Jetty.");
    jettyStop.setGroup(WarPlugin.WEB_APP_GROUP);
    jettyStop.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyStop.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #22
Source File: WarOverlayPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    this.project = project;
    project.getPluginManager().apply(WarPlugin.class);

    project.getTasks().withType(War.class, warTask -> {
        NamedDomainObjectContainer<WarOverlay> warOverlays = project.container(WarOverlay.class, name -> new WarOverlay(name, warTask));
        warTask.getExtensions().add("overlays", warOverlays);

        Configuration warOverlayClasspath = project.getConfigurations().create(warTask.getName() + "OverlayClasspath");
        warTask.getExtensions().add("overlayClasspath", warOverlayClasspath);

        if (warTask.getName().equals(WarPlugin.WAR_TASK_NAME)) {
            project.getConfigurations().getByName(COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(warOverlayClasspath);
            project.getConfigurations().getByName(TEST_IMPLEMENTATION_CONFIGURATION_NAME).extendsFrom(warOverlayClasspath);
        }

        project.afterEvaluate(p -> warOverlays.all(overlay -> {

            if (overlay.isEnabled()) {
                configureOverlay(overlay);
            } else {
                Collection<CopySpecInternal> children = (Collection<CopySpecInternal>) overlay.getWarTask().getRootSpec().getChildren();
                children.remove(overlay.getWarCopySpec());
            }

        }));
    });

}
 
Example #23
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJettyStop(Project project, final JettyPluginConvention jettyConvention) {
    JettyStop jettyStop = project.getTasks().create(JETTY_STOP, JettyStop.class);
    jettyStop.setDescription("Stops Jetty.");
    jettyStop.setGroup(WarPlugin.WEB_APP_GROUP);
    jettyStop.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyStop.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #24
Source File: SourceContextPluginTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultConfiguration() throws IOException {
  File appengineWebXml =
      new File(testProjectDir.getRoot(), "src/main/webapp/WEB-INF/appengine-web.xml");
  appengineWebXml.getParentFile().mkdirs();
  appengineWebXml.createNewFile();
  Files.write(appengineWebXml.toPath(), "<web-app/>".getBytes());

  Project project = ProjectBuilder.builder().withProjectDir(testProjectDir.getRoot()).build();
  project.getPluginManager().apply(JavaPlugin.class);
  project.getPluginManager().apply(WarPlugin.class);
  project.getPluginManager().apply(AppEngineStandardPlugin.class);
  project.getPluginManager().apply(SourceContextPlugin.class);

  DeployExtension deploy =
      project.getExtensions().getByType(AppEngineStandardExtension.class).getDeploy();
  deploy.setProjectId("project");
  deploy.setVersion("version");
  ((ProjectInternal) project).evaluate();

  ExtensionAware ext =
      (ExtensionAware)
          project.getExtensions().getByName(AppEngineCorePluginConfiguration.APPENGINE_EXTENSION);
  GenRepoInfoFileExtension genRepoInfoExt =
      new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION);
  Assert.assertEquals(
      new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory());
}
 
Example #25
Source File: WarOverlayPluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void testProperties() {
    Project project = ProjectBuilder.builder().build();

    project.getPlugins().apply(WarPlugin.class);
    project.getPlugins().apply(WarOverlayPlugin.class);

    Task warTask = project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);

    assertThat(warTask.hasProperty("overlays")).isTrue();
    assertThat(warTask.property("overlays")).isInstanceOf(DomainObjectCollection.class);
}
 
Example #26
Source File: WarAttachClassesPluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void testProperties() {
    project.getPlugins().apply(WarPlugin.class);
    project.getPlugins().apply(WarAttachClassesPlugin.class);

    War warTask = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);

    assertThat(warTask.hasProperty("attachClasses")).isTrue();
    assertThat(warTask.property("attachClasses")).isInstanceOf(Boolean.class);

    assertThat(warTask.hasProperty("classesClassifier")).isTrue();
    assertThat(warTask.property("classesClassifier")).isInstanceOf(String.class);
}
 
Example #27
Source File: WarArchiveClassesPluginTest.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Test
public void testArchiveClassesProperty() {
    project.getPlugins().apply(WarPlugin.class);
    project.getPlugins().apply(WarArchiveClassesPlugin.class);

    War warTask = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);

    assertThat(warTask.hasProperty("archiveClasses")).isTrue();
    assertThat(warTask.property("archiveClasses")).isInstanceOf(Boolean.class);
}
 
Example #28
Source File: WarOverlayPlugin.java    From gradle-plugins with MIT License 5 votes vote down vote up
@Override
public void apply(Project project) {
    this.project = project;
    project.getPluginManager().apply(WarPlugin.class);

    project.getTasks().withType(War.class, warTask -> {
        NamedDomainObjectContainer<WarOverlay> warOverlays = project.container(WarOverlay.class, name -> new WarOverlay(name, warTask));
        warTask.getExtensions().add("overlays", warOverlays);

        Configuration warOverlayClasspath = project.getConfigurations().create(warTask.getName() + "OverlayClasspath");
        warTask.getExtensions().add("overlayClasspath", warOverlayClasspath);

        if (warTask.getName().equals(WarPlugin.WAR_TASK_NAME)) {
            project.getConfigurations().getByName(COMPILE_CLASSPATH_CONFIGURATION_NAME).extendsFrom(warOverlayClasspath);
            project.getConfigurations().getByName(TEST_IMPLEMENTATION_CONFIGURATION_NAME).extendsFrom(warOverlayClasspath);
        }

        project.afterEvaluate(p -> warOverlays.all(overlay -> {

            if (overlay.isEnabled()) {
                configureOverlay(overlay);
            } else {
                Collection<CopySpecInternal> children = (Collection<CopySpecInternal>) overlay.getWarTask().getRootSpec().getChildren();
                children.remove(overlay.getWarCopySpec());
            }

        }));
    });

}
 
Example #29
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureJettyStop(Project project, final JettyPluginConvention jettyConvention) {
    JettyStop jettyStop = project.getTasks().create(JETTY_STOP, JettyStop.class);
    jettyStop.setDescription("Stops Jetty.");
    jettyStop.setGroup(WarPlugin.WEB_APP_GROUP);
    jettyStop.getConventionMapping().map("stopPort", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopPort();
        }
    });
    jettyStop.getConventionMapping().map("stopKey", new Callable<Object>() {
        public Object call() throws Exception {
            return jettyConvention.getStopKey();
        }
    });
}
 
Example #30
Source File: JettyPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(Project project) {
    project.getPlugins().apply(WarPlugin.class);
    JettyPluginConvention jettyConvention = new JettyPluginConvention();
    Convention convention = project.getConvention();
    convention.getPlugins().put("jetty", jettyConvention);

    configureMappingRules(project, jettyConvention);
    configureJettyRun(project);
    configureJettyRunWar(project);
    configureJettyStop(project, jettyConvention);
}