本文整理汇总了Java中org.gradle.api.tasks.bundling.War类的典型用法代码示例。如果您正苦于以下问题:Java War类的具体用法?Java War怎么用?Java War使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
War类属于org.gradle.api.tasks.bundling包,在下文中一共展示了War类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureAbstractJettyTask
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
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();
}
});
}
示例2: apply
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@Override
public void apply(Project project) {
jSassBasePlugin = project.getPlugins().apply(JSassBasePlugin.class);
project.getPlugins().apply(WarPlugin.class);
SassCompile compileWebappSass = project.getTasks().create("compileWebappSass", SassCompile.class);
compileWebappSass.setGroup(BasePlugin.BUILD_GROUP);
compileWebappSass.setDescription("Compile sass and scss files for the webapp");
WarPluginConvention warPluginConvention = project.getConvention().getPlugin(WarPluginConvention.class);
compileWebappSass.setSourceDir(warPluginConvention.getWebAppDir());
project.afterEvaluate(p -> {
War war = (War) p.getTasks().getByName(WarPlugin.WAR_TASK_NAME);
if (jSassBasePlugin.getExtension().isInplace()) {
compileWebappSass.setDestinationDir(warPluginConvention.getWebAppDir());
} else {
compileWebappSass.setDestinationDir(new File(p.getBuildDir(), "generated/webappCss"));
war.from(compileWebappSass.getDestinationDir());
}
war.dependsOn(compileWebappSass);
});
}
示例3: apply
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@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);
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());
}
}));
});
}
示例4: apply
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getPlugins().apply(WarPlugin.class);
WarAttachClassesConvention attachClassesConvention = new WarAttachClassesConvention();
War war = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);
war.getConvention().getPlugins().put("attachClasses", attachClassesConvention);
project.afterEvaluate(p -> {
if (attachClassesConvention.isAttachClasses()) {
Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
jar.setClassifier(attachClassesConvention.getClassesClassifier());
project.getArtifacts().add(Dependency.ARCHIVES_CONFIGURATION, jar);
}
});
}
示例5: testDefaultConfiguration
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@Test
public void testDefaultConfiguration() throws IOException {
Project p = new TestProject(testProjectDir.getRoot()).applyFlexibleWarProjectBuilder();
ExtensionAware ext = (ExtensionAware) p.getExtensions().getByName("appengine");
DeployExtension deployExt = new ExtensionUtil(ext).get("deploy");
StageFlexibleExtension stageExt = new ExtensionUtil(ext).get("stage");
assertEquals(new File(p.getBuildDir(), "staged-app"), stageExt.getStagingDirectory());
assertEquals(
testProjectDir.getRoot().toPath().toRealPath().resolve("src/main/appengine"),
stageExt.getAppEngineDirectory().toPath());
assertEquals(
testProjectDir.getRoot().toPath().toRealPath().resolve("src/main/appengine"),
deployExt.getAppEngineDirectory().toPath());
assertEquals((((War) p.getProperties().get("war")).getArchivePath()), stageExt.getArtifact());
assertFalse(new File(testProjectDir.getRoot(), "src/main/docker").exists());
assertEquals(
Collections.singletonList(new File(p.getBuildDir(), "staged-app/app.yaml")),
deployExt.getDeployables());
}
示例6: createCompileTask
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
private void createCompileTask(final Project project) {
project.getTasks().create(GwtCompileTask.NAME, GwtCompileTask.class);
final PutnamiExtension extension = project.getExtensions().getByType(PutnamiExtension.class);
final War warTask = project.getTasks().withType(War.class).getByName("war");
warTask.dependsOn(GwtCompileTask.NAME);
project.getTasks().withType(GwtCompileTask.class, new Action<GwtCompileTask>() {
@Override
public void execute(final GwtCompileTask task) {
task.configure(project, extension);
warTask.from(extension.getCompile().getWar());
}
});
ConfigurationContainer configurationContainer = project.getConfigurations();
// Configuration gwtConfig = configurationContainer.getByName(PwtLibPlugin.CONF_GWT_SDM);
// FileCollection warClasspath = warTask.getClasspath().minus(gwtConfig);
// warTask.setClasspath(warClasspath);
}
示例7: getTypeIdentifier
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
private String getTypeIdentifier(PublishArtifact artifact) {
if (artifact instanceof ArchivePublishArtifact) {
ArchivePublishArtifact publishArtifact = (ArchivePublishArtifact) artifact;
AbstractArchiveTask task = publishArtifact.getArchiveTask();
// There is an inheritance hierarchy in play here, so the order
// of the clauses is very important.
if (task instanceof War) {
return WAR_ARTIFACT.getTypeIdentifier();
} else if (task instanceof Ear) {
return EAR_ARTIFACT.getTypeIdentifier();
} else if (task instanceof Jar) {
return JAR_ARTIFACT.getTypeIdentifier();
} else if (task instanceof Zip) {
return ZIP_ARTIFACT.getTypeIdentifier();
} else if (task instanceof Tar) {
return TAR_ARTIFACT.getTypeIdentifier();
} else {
// we don't know about this kind of archive task
return ARCHIVE_ARTIFACT.getTypeIdentifier();
}
} else {
// This could very well be a zip (or something else we understand), but we can't know for sure.
// The client may try to infer from the file extension.
return UNKNOWN_ARTIFACT.getTypeIdentifier();
}
}
示例8: apply
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
public void apply(final Project project) {
project.getPluginManager().apply(JavaPlugin.class);
final WarPluginConvention pluginConvention = new WarPluginConvention(project);
project.getConvention().getPlugins().put("war", pluginConvention);
project.getTasks().withType(War.class, new Action<War>() {
public void execute(War task) {
task.from(new Callable() {
public Object call() throws Exception {
return pluginConvention.getWebAppDir();
}
});
task.dependsOn(new Callable() {
public Object call() throws Exception {
return project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName(
SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
}
});
task.classpath(new Object[] {new Callable() {
public Object call() throws Exception {
FileCollection runtimeClasspath = project.getConvention().getPlugin(JavaPluginConvention.class)
.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getRuntimeClasspath();
Configuration providedRuntime = project.getConfigurations().getByName(
PROVIDED_RUNTIME_CONFIGURATION_NAME);
return runtimeClasspath.minus(providedRuntime);
}
}});
}
});
War war = project.getTasks().create(WAR_TASK_NAME, War.class);
war.setDescription("Generates a war archive with all the compiled classes, the web-app content and the libraries.");
war.setGroup(BasePlugin.BUILD_GROUP);
ArchivePublishArtifact warArtifact = new ArchivePublishArtifact(war);
project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(warArtifact);
configureConfigurations(project.getConfigurations());
configureComponent(project, warArtifact);
}
示例9: configureOverlay
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
private void configureOverlay(WarOverlay overlay, Project otherProject) {
project.evaluationDependsOn(otherProject.getPath());
War otherWar = (War) otherProject.getTasks().getByName(WAR_TASK_NAME);
configureOverlay(overlay, otherWar);
if (overlay.isEnableCompilation()) {
project.getDependencies().add(COMPILE_CLASSPATH_CONFIGURATION_NAME, otherProject);
project.getDependencies().add(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME, otherProject);
}
}
示例10: WarOverlay
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
public WarOverlay(String name, War warTask) {
this.name = name;
this.warTask = warTask;
this.warCopySpec = warTask.getRootSpec().addChild();
warCopySpec.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
exclude("META-INF/maven/**");
exclude("META-INF/MANIFEST.MF");
}
示例11: apply
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@Override
public void apply(Project project) {
project.getTasks().withType(War.class, war -> {
WarArchiveClassesConvention archiveClassesConvention = new WarArchiveClassesConvention();
war.getConvention().getPlugins().put("archiveClasses", archiveClassesConvention);
Jar warClassesJar = project.getTasks().create(war.getName() + "ClassesJar", Jar.class);
warClassesJar.getConventionMapping().map("baseName", war::getBaseName);
warClassesJar.getConventionMapping().map("appendix", war::getAppendix);
warClassesJar.getConventionMapping().map("version", war::getVersion);
warClassesJar.getConventionMapping().map("classifier", war::getClassifier);
project.afterEvaluate(p -> {
warClassesJar.setEnabled(archiveClassesConvention.isArchiveClasses());
if (archiveClassesConvention.isArchiveClasses()) {
FileCollection warClasspath = war.getClasspath();
warClassesJar.from(warClasspath != null ? warClasspath.filter(File::isDirectory) : Collections.emptyList());
war.setClasspath(warClasspath == null ? null : warClasspath.filter(File::isFile).plus(project.files(warClassesJar)));
}
});
});
}
示例12: testArchiveClassesProperty
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@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);
}
示例13: testProperties
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@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);
}
示例14: exec
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
@TaskAction
public void exec() throws Exception {
War warTask = (War) getProject().getTasks().getByName("war");
jettyConf = new File(getProject().getBuildDir(), "putnami/conf/jetty-run-conf.xml");
Map<String, String> model = new ImmutableMap.Builder<String, String>()
.put("__WAR_FILE__", warTask.getArchivePath().getAbsolutePath())
.build();
ResourceUtils.copy("/stub.jetty-conf.xml", jettyConf, model);
JavaAction jetty = execJetty();
jetty.join();
}
示例15: getWebXml
import org.gradle.api.tasks.bundling.War; //导入依赖的package包/类
private Object getWebXml(Project project) {
War war = (War) project.getTasks().getByName(WarPlugin.WAR_TASK_NAME);
File webXml;
if (war.getWebXml() != null) {
webXml = war.getWebXml();
} else {
webXml = new File(getWarConvention(project).getWebAppDir(), "WEB-INF/web.xml");
}
return webXml;
}