本文整理汇总了Java中org.gradle.api.plugins.ExtensionAware类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionAware类的具体用法?Java ExtensionAware怎么用?Java ExtensionAware使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionAware类属于org.gradle.api.plugins包,在下文中一共展示了ExtensionAware类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@Override
public void apply(Project project) {
final ConfigurationContainer configurations = project.getConfigurations();
configurations.maybeCreate("test");
configurations.maybeCreate("build");
configurations.maybeCreate("tool");
final ExtensionContainer extensions = project.getExtensions();
final ExtensionAware golang = (ExtensionAware) extensions.create("golang", GolangSettings.class, true, project);
golang.getExtensions().create("build", BuildSettings.class, true, project);
golang.getExtensions().create("toolchain", ToolchainSettings.class, true, project);
golang.getExtensions().create("dependencies", DependenciesSettings.class, true, project);
golang.getExtensions().create("testing", TestingSettings.class, true, project);
extensions.create(INSTANCE_PROPERTY_NAME, Reference.class, this);
final TaskContainer tasks = project.getTasks();
addTasks(tasks);
}
示例2: testDefaultConfiguration
import org.gradle.api.plugins.ExtensionAware; //导入依赖的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());
}
示例3: testFileAsString
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@Test
public void testFileAsString() throws IOException {
Project p = setUpTestProject("file-as-string");
ExtensionAware ext =
(ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION);
StageStandardExtension stage =
new ExtensionUtil(ext).get(AppEngineStandardPlugin.STAGE_EXTENSION);
RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION);
ToolsExtension tools = new ExtensionUtil(ext).get(AppEngineCorePlugin.TOOLS_EXTENSION);
Assert.assertEquals(deploy.getDeployables().size(), 1);
Assert.assertEquals("test", deploy.getDeployables().get(0).getName());
Assert.assertEquals(run.getServices().size(), 1);
Assert.assertEquals("test", run.getServices().get(0).getName());
Assert.assertEquals("test", stage.getSourceDirectory().getName());
Assert.assertEquals("test", stage.getStagingDirectory().getName());
Assert.assertEquals("test", stage.getDockerfile().getName());
Assert.assertEquals("test", tools.getCloudSdkHome().getName());
}
示例4: testFilesAsString
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@Test
public void testFilesAsString() throws IOException {
Project p = setUpTestProject("files-as-string");
ExtensionAware ext =
(ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION);
RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION);
Assert.assertEquals(deploy.getDeployables().size(), 2);
Assert.assertEquals("test0", deploy.getDeployables().get(0).getName());
Assert.assertEquals("test1", deploy.getDeployables().get(1).getName());
Assert.assertEquals(run.getServices().size(), 2);
Assert.assertEquals("test0", run.getServices().get(0).getName());
Assert.assertEquals("test1", run.getServices().get(1).getName());
}
示例5: testFileAsFile
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@Test
public void testFileAsFile() throws IOException {
Project p = setUpTestProject("file-as-file");
ExtensionAware ext =
(ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION);
StageStandardExtension stage =
new ExtensionUtil(ext).get(AppEngineStandardPlugin.STAGE_EXTENSION);
RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION);
ToolsExtension tools = new ExtensionUtil(ext).get(AppEngineCorePlugin.TOOLS_EXTENSION);
Assert.assertEquals(deploy.getDeployables().size(), 1);
Assert.assertEquals("test", deploy.getDeployables().get(0).getName());
Assert.assertEquals(run.getServices().size(), 1);
Assert.assertEquals("test", run.getServices().get(0).getName());
Assert.assertEquals("test", stage.getSourceDirectory().getName());
Assert.assertEquals("test", stage.getStagingDirectory().getName());
Assert.assertEquals("test", stage.getDockerfile().getName());
Assert.assertEquals("test", tools.getCloudSdkHome().getName());
}
示例6: testFilesAsFiles
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@Test
public void testFilesAsFiles() throws IOException {
Project p = setUpTestProject("files-as-files");
ExtensionAware ext =
(ExtensionAware) p.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
DeployExtension deploy = new ExtensionUtil(ext).get(AppEngineCorePlugin.DEPLOY_EXTENSION);
RunExtension run = new ExtensionUtil(ext).get(AppEngineStandardPlugin.RUN_EXTENSION);
Assert.assertEquals(deploy.getDeployables().size(), 2);
Assert.assertEquals("test0", deploy.getDeployables().get(0).getName());
Assert.assertEquals("test1", deploy.getDeployables().get(1).getName());
Assert.assertEquals(run.getServices().size(), 2);
Assert.assertEquals("test0", run.getServices().get(0).getName());
Assert.assertEquals("test1", run.getServices().get(1).getName());
}
示例7: testDefaultConfiguration
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@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);
((ProjectInternal) project).evaluate();
ExtensionAware ext =
(ExtensionAware) project.getExtensions().getByName(AppEngineCorePlugin.APPENGINE_EXTENSION);
GenRepoInfoFileExtension genRepoInfoExt =
new ExtensionUtil(ext).get(SourceContextPlugin.SOURCE_CONTEXT_EXTENSION);
Assert.assertEquals(
new File(project.getBuildDir(), "sourceContext"), genRepoInfoExt.getOutputDirectory());
}
示例8: testGetAllFields_NestedExtensions
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@Test
public void testGetAllFields_NestedExtensions() throws IllegalAccessException {
String expected =
""
+ "root {\n"
+ " x {\n"
+ " y {\n"
+ " (int) yy = 0\n"
+ " z {\n"
+ " (String) zz = hello\n"
+ " (Map<String, List<String>>) zzNested = {a=[a1, a2], b=[b1, b2]}\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}\n";
Project p = ProjectBuilder.builder().build();
ExtensionAware root = (ExtensionAware) p.getExtensions().create("root", ExtX.class);
ExtensionAware x = (ExtensionAware) root.getExtensions().create("x", ExtX.class);
ExtensionAware y = (ExtensionAware) x.getExtensions().create("y", ExtY.class);
y.getExtensions().create("z", ExtZ.class);
String result = ShowConfigurationTask.getExtensionData("root", root, 0);
Assert.assertEquals(expected, result);
}
示例9: configureResourceCompileTask
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
private void configureResourceCompileTask(WindowsResourceCompile task, final NativeBinarySpecInternal binary, final WindowsResourceSet sourceSet) {
task.setDescription(String.format("Compiles resources of the %s of %s", sourceSet, binary));
task.setToolChain(binary.getToolChain());
task.setTargetPlatform(binary.getTargetPlatform());
task.includes(new Callable<Set<File>>() {
public Set<File> call() {
return sourceSet.getExportedHeaders().getSrcDirs();
}
});
task.source(sourceSet.getSource());
final Project project = task.getProject();
task.setOutputDir(project.file(String.valueOf(project.getBuildDir()) + "/objs/" + binary.getNamingScheme().getOutputDirectoryBase() + "/" + ((LanguageSourceSetInternal) sourceSet).getFullName()));
PreprocessingTool rcCompiler = (PreprocessingTool) ((ExtensionAware) binary).getExtensions().getByName("rcCompiler");
task.setMacros(rcCompiler.getMacros());
task.setCompilerArgs(rcCompiler.getArgs());
FileTree resourceOutputs = task.getOutputs().getFiles().getAsFileTree().matching(new PatternSet().include("**/*.res"));
binary.getTasks().getCreateOrLink().source(resourceOutputs);
if (binary instanceof StaticLibraryBinarySpecInternal) {
((StaticLibraryBinarySpecInternal) binary).additionalLinkFiles(resourceOutputs);
}
}
示例10: apply
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
public void apply(final CUnitTestSuite cUnitTestSuite, final BinaryContainer binaries) {
cUnitTestSuite.getTestedComponent().getBinaries().withType(ProjectNativeBinaryInternal.class).all(new Action<ProjectNativeBinaryInternal>() {
public void execute(ProjectNativeBinaryInternal testedBinary) {
final ProjectNativeBinary cunitExe = createTestBinary(cUnitTestSuite, testedBinary, project);
((ExtensionAware) cunitExe).getExtensions().create("cCompiler", DefaultPreprocessingTool.class);
cUnitTestSuite.getBinaries().add(cunitExe);
binaries.add(cunitExe);
testedBinary.getSource().all(new Action<LanguageSourceSet>() {
public void execute(LanguageSourceSet languageSourceSet) {
cunitExe.source(languageSourceSet);
}
});
}
});
}
示例11: apply
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
public void apply(Project project) {
project.getPluginManager().apply(BasePlugin.class);
project.getExtensions().create(JavaScriptExtension.NAME, JavaScriptExtension.class);
((ExtensionAware) project.getRepositories()).getExtensions().create(
JavaScriptRepositoriesExtension.NAME,
JavaScriptRepositoriesExtension.class,
project.getRepositories());
}
示例12: apply
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
public void apply(Project project) {
project.getPluginManager().apply(JavaScriptBasePlugin.class);
JavaScriptExtension jsExtension = project.getExtensions().findByType(JavaScriptExtension.class);
final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().create(RhinoExtension.NAME, RhinoExtension.class);
final Configuration configuration = addClasspathConfiguration(project.getConfigurations());
configureDefaultRhinoDependency(configuration, project.getDependencies(), rhinoExtension);
ConventionMapping conventionMapping = ((IConventionAware) rhinoExtension).getConventionMapping();
conventionMapping.map("classpath", new Callable<Configuration>() {
public Configuration call() {
return configuration;
}
});
conventionMapping.map("version", new Callable<String>() {
public String call() {
return RhinoExtension.DEFAULT_RHINO_DEPENDENCY_VERSION;
}
});
project.getTasks().withType(RhinoShellExec.class, new Action<RhinoShellExec>() {
public void execute(RhinoShellExec task) {
task.getConventionMapping().map("classpath", new Callable<FileCollection>() {
public FileCollection call() {
return rhinoExtension.getClasspath();
}
});
task.getConventionMapping().map("main", new Callable<String>() {
public String call() {
return RhinoExtension.RHINO_SHELL_MAIN;
}
});
task.setClasspath(rhinoExtension.getClasspath());
}
});
}
示例13: apply
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
public void apply(final Project project) {
project.getPluginManager().apply(RhinoPlugin.class);
project.getPluginManager().apply(ReportingBasePlugin.class);
JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
final EnvJsExtension envJsExtension = ((ExtensionAware) jsExtension).getExtensions().create(EnvJsExtension.NAME, EnvJsExtension.class);
final Configuration configuration = addConfiguration(project.getConfigurations(), project.getDependencies(), envJsExtension);
final ConventionMapping conventionMapping = ((IConventionAware) envJsExtension).getConventionMapping();
conventionMapping.map("js", new Callable<Configuration>() {
public Configuration call() {
return configuration;
}
});
conventionMapping.map("version", new Callable<String>() {
public String call() {
return EnvJsExtension.DEFAULT_DEPENDENCY_VERSION;
}
});
final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().getByType(RhinoExtension.class);
project.getTasks().withType(BrowserEvaluate.class, new Action<BrowserEvaluate>() {
public void execute(BrowserEvaluate task) {
((IConventionAware) task).getConventionMapping().map("evaluator", new Callable<EnvJsBrowserEvaluator>() {
public EnvJsBrowserEvaluator call() {
RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(workerProcessBuilderFactory);
File workDir = project.getProjectDir();
Factory<File> envJsFactory = new Factory<File>() {
public File create() {
return envJsExtension.getJs().getSingleFile();
}
};
return new EnvJsBrowserEvaluator(handleFactory, rhinoExtension.getClasspath(), envJsFactory, project.getGradle().getStartParameter().getLogLevel(), workDir);
}
});
}
});
}
示例14: Settings
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
_project = project;
_golang = container.getByType(GolangSettings.class);
if (!(_golang instanceof ExtensionAware)) {
throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
}
final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
_build = globalExtensions.getByType(BuildSettings.class);
_toolchain = globalExtensions.getByType(ToolchainSettings.class);
_dependencies = globalExtensions.getByType(DependenciesSettings.class);
_testing = globalExtensions.getByType(TestingSettings.class);
}
示例15: getExtensionData
import org.gradle.api.plugins.ExtensionAware; //导入依赖的package包/类
@VisibleForTesting
// recursive (but doesn't search through nested objects, only nested extensions)
static String getExtensionData(String extensionName, Object extensionInstance, int depth)
throws IllegalAccessException {
StringBuilder result = new StringBuilder("");
// extension start block
result.append(spaces(depth)).append(extensionName).append(" {\n");
// all non-extension fields
for (Field field : extensionInstance.getClass().getSuperclass().getDeclaredFields()) {
// ignore synthetic fields (stuff added by compiler or instrumenter)
if (field.isSynthetic()) {
continue;
}
// This is just a helper for the extensions, don't show it
if (field.getType().equals(org.gradle.api.Project.class)) {
continue;
}
result.append(getFieldData(field, extensionInstance, depth + 1));
}
// all extension fields
Map<String, Object> map =
((ExtensionContainerInternal) ((ExtensionAware) extensionInstance).getExtensions())
.getAsMap();
for (String childExtensionName : map.keySet()) {
Object childExtensionInstance = map.get(childExtensionName);
// only expand out extensions we understand (we're ignoring the default ext group here, which
// is not ExtensionAware)
if (childExtensionInstance instanceof ExtensionAware) {
result.append(getExtensionData(childExtensionName, map.get(childExtensionName), depth + 1));
}
}
// extension end block
result.append(spaces(depth)).append("}\n");
return result.toString();
}