本文整理汇总了Java中org.gradle.api.internal.plugins.DslObject类的典型用法代码示例。如果您正苦于以下问题:Java DslObject类的具体用法?Java DslObject怎么用?Java DslObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DslObject类属于org.gradle.api.internal.plugins包,在下文中一共展示了DslObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: optionMap
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
public Map<String, Object> optionMap() {
final Map<String, Object> map = Maps.newHashMap();
Class<?> currClass = new DslObject(this).getDeclaredType();
while (currClass != AbstractOptions.class) {
for (final Field field : currClass.getDeclaredFields()) {
if (isOptionField(field)) {
DeprecationLogger.whileDisabled(new Runnable() {
@Override
public void run() {
addValueToMapIfNotNull(map, field);
}
});
}
}
currClass = currClass.getSuperclass();
}
return map;
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:AbstractOptions.java
示例2: configureSourceSetDefaults
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
public void execute(SourceSet sourceSet) {
final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), sourceDirectorySetFactory);
new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);
groovySourceSet.getGroovy().srcDir("src/" + sourceSet.getName() + "/groovy");
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
public boolean isSatisfiedBy(FileTreeElement element) {
return groovySourceSet.getGroovy().contains(element.getFile());
}
});
sourceSet.getAllJava().source(groovySourceSet.getGroovy());
sourceSet.getAllSource().source(groovySourceSet.getGroovy());
String compileTaskName = sourceSet.getCompileTaskName("groovy");
GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
javaBasePlugin.configureForSourceSet(sourceSet, compile);
compile.dependsOn(sourceSet.getCompileJavaTaskName());
compile.setDescription("Compiles the " + sourceSet.getName() + " Groovy source.");
compile.setSource(groovySourceSet.getGroovy());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:27,代码来源:GroovyBasePlugin.java
示例3: configureTestDefaults
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
DslObject htmlReport = new DslObject(test.getReports().getHtml());
DslObject xmlReport = new DslObject(test.getReports().getJunitXml());
xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), test.getName());
}
});
htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestReportDir(), test.getName());
}
});
test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), test.getName() + "/binary");
}
});
test.workingDir(project.getProjectDir());
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:22,代码来源:JavaBasePlugin.java
示例4: createGeneratePomTask
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void createGeneratePomTask(CollectionBuilder<Task> tasks, final MavenPublicationInternal publication, String publicationName) {
String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
tasks.create(descriptorTaskName, GenerateMavenPom.class, new Action<GenerateMavenPom>() {
public void execute(final GenerateMavenPom generatePomTask) {
generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
generatePomTask.setPom(publication.getPom());
ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(generatePomTask.getProject().getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
}
});
// Wire the generated pom into the publication.
publication.setPomFile(generatePomTask.getOutputs().getFiles());
}
});
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:21,代码来源:MavenPublishPlugin.java
示例5: addPropertiesToProject
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void addPropertiesToProject(Project project) {
Properties projectProperties = new Properties();
File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
if (projectPropertiesFile.isFile()) {
projectProperties = GUtil.loadProperties(projectPropertiesFile);
LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
projectProperties.keySet());
} else {
LOGGER.debug("project property file does not exists. We continue!");
}
Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
try {
project.setProperty(entry.getKey(), entry.getValue());
} catch (MissingPropertyException e) {
if (!entry.getKey().equals(e.getProperty())) {
throw e;
}
// Ignore and define as an extra property
extraProperties.set(entry.getKey(), entry.getValue());
}
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:27,代码来源:ProjectPropertySettingBuildLoader.java
示例6: configureSourceSetDefaults
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
public void execute(SourceSet sourceSet) {
final DefaultGroovySourceSet groovySourceSet = new DefaultGroovySourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver);
new DslObject(sourceSet).getConvention().getPlugins().put("groovy", groovySourceSet);
groovySourceSet.getGroovy().srcDir(String.format("src/%s/groovy", sourceSet.getName()));
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
public boolean isSatisfiedBy(FileTreeElement element) {
return groovySourceSet.getGroovy().contains(element.getFile());
}
});
sourceSet.getAllJava().source(groovySourceSet.getGroovy());
sourceSet.getAllSource().source(groovySourceSet.getGroovy());
String compileTaskName = sourceSet.getCompileTaskName("groovy");
GroovyCompile compile = project.getTasks().create(compileTaskName, GroovyCompile.class);
javaBasePlugin.configureForSourceSet(sourceSet, compile);
compile.dependsOn(sourceSet.getCompileJavaTaskName());
compile.setDescription(String.format("Compiles the %s Groovy source.", sourceSet.getName()));
compile.setSource(groovySourceSet.getGroovy());
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compileTaskName);
}
});
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:27,代码来源:GroovyBasePlugin.java
示例7: createProcessResourcesTaskForBinary
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) {
final BinaryNamingScheme namingScheme = binary.getNamingScheme();
binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() {
public void execute(JvmResourceSet resourceSet) {
Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class);
resourcesTask.setDescription(String.format("Processes %s.", resourceSet));
new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
public File call() throws Exception {
return binary.getResourcesDir();
}
});
binary.getTasks().add(resourcesTask);
binary.builtBy(resourcesTask);
resourcesTask.from(resourceSet.getSource());
}
});
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:LegacyJavaComponentPlugin.java
示例8: configureTestDefaults
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureTestDefaults(final Test test, Project project, final JavaPluginConvention convention) {
DslObject htmlReport = new DslObject(test.getReports().getHtml());
DslObject xmlReport = new DslObject(test.getReports().getJunitXml());
xmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return convention.getTestResultsDir();
}
});
htmlReport.getConventionMapping().map("destination", new Callable<Object>() {
public Object call() throws Exception {
return convention.getTestReportDir();
}
});
test.getConventionMapping().map("binResultsDir", new Callable<Object>() {
public Object call() throws Exception {
return new File(convention.getTestResultsDir(), String.format("binary/%s", test.getName()));
}
});
test.workingDir(project.getProjectDir());
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:22,代码来源:JavaBasePlugin.java
示例9: createGeneratePomTask
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void createGeneratePomTask(final MavenPublicationInternal publication, String publicationName) {
String descriptorTaskName = String.format("generatePomFileFor%sPublication", capitalize(publicationName));
GenerateMavenPom generatePomTask = project.getTasks().create(descriptorTaskName, GenerateMavenPom.class);
generatePomTask.setDescription(String.format("Generates the Maven POM file for publication '%s'.", publication.getName()));
generatePomTask.setGroup(PublishingPlugin.PUBLISH_TASK_GROUP);
generatePomTask.setPom(publication.getPom());
ConventionMapping descriptorTaskConventionMapping = new DslObject(generatePomTask).getConventionMapping();
descriptorTaskConventionMapping.map("destination", new Callable<Object>() {
public Object call() throws Exception {
return new File(project.getBuildDir(), "publications/" + publication.getName() + "/pom-default.xml");
}
});
// Wire the generated pom into the publication.
publication.setPomFile(generatePomTask.getOutputs().getFiles());
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:18,代码来源:MavenPublishTaskModelRule.java
示例10: addPropertiesToProject
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void addPropertiesToProject(Project project) {
Properties projectProperties = new Properties();
File projectPropertiesFile = new File(project.getProjectDir(), Project.GRADLE_PROPERTIES);
LOGGER.debug("Looking for project properties from: {}", projectPropertiesFile);
if (projectPropertiesFile.isFile()) {
projectProperties = GUtil.loadProperties(projectPropertiesFile);
LOGGER.debug("Adding project properties (if not overwritten by user properties): {}",
projectProperties.keySet());
} else {
LOGGER.debug("project property file does not exists. We continue!");
}
Map<String, String> mergedProperties = propertiesLoader.mergeProperties(new HashMap(projectProperties));
ExtraPropertiesExtension extraProperties = new DslObject(project).getExtensions().getExtraProperties();
for (Map.Entry<String, String> entry: mergedProperties.entrySet()) {
if (project.hasProperty(entry.getKey())) {
project.setProperty(entry.getKey(), entry.getValue());
} else {
extraProperties.set(entry.getKey(), entry.getValue());
}
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:23,代码来源:ProjectPropertySettingBuildLoader.java
示例11: apply
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
public void apply(final Project project) {
project.getPluginManager().apply(ReportingBasePlugin.class);
final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
buildDashboardTask.setGroup("reporting");
DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
htmlReportConventionMapping.map("destination", new Callable<Object>() {
public Object call() throws Exception {
return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
}
});
Action<Task> captureReportingTasks = new Action<Task>() {
public void execute(Task task) {
if (!(task instanceof Reporting)) {
return;
}
Reporting reporting = (Reporting) task;
buildDashboardTask.aggregate(reporting);
if (!task.equals(buildDashboardTask)) {
task.finalizedBy(buildDashboardTask);
}
}
};
for (Project aProject : project.getAllprojects()) {
aProject.getTasks().all(captureReportingTasks);
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:36,代码来源:BuildDashboardPlugin.java
示例12: configureUploadTasks
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureUploadTasks(final DefaultDeployerFactory deployerFactory) {
project.getTasks().withType(Upload.class, new Action<Upload>() {
public void execute(Upload upload) {
RepositoryHandler repositories = upload.getRepositories();
DefaultRepositoryHandler handler = (DefaultRepositoryHandler) repositories;
DefaultMavenRepositoryHandlerConvention repositoryConvention = new DefaultMavenRepositoryHandlerConvention(handler, deployerFactory);
new DslObject(repositories).getConvention().getPlugins().put("maven", repositoryConvention);
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:MavenPlugin.java
示例13: configureInstall
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureInstall(Project project) {
Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class);
Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION);
installUpload.setConfiguration(configuration);
MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class);
repositories.mavenInstaller();
installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository.");
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:MavenPlugin.java
示例14: addDefaultDependenciesReportConfiguration
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
@Defaults
void addDefaultDependenciesReportConfiguration(@Path("tasks.dependencyInsight") DependencyInsightReportTask task, final ServiceRegistry services) {
new DslObject(task).getConventionMapping().map("configuration", new Callable<Object>() {
public Object call() {
BuildableJavaComponent javaProject = services.get(ComponentRegistry.class).getMainComponent();
return javaProject == null ? null : javaProject.getCompileDependencies();
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:HelpTasksPlugin.java
示例15: getDeclaredTaskType
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private Class getDeclaredTaskType(Task original) {
Class clazz = new DslObject(original).getDeclaredType();
if (clazz.equals(DefaultTask.class)) {
return org.gradle.api.Task.class;
} else {
return clazz;
}
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:TaskDetailPrinter.java
示例16: conventionMapOutputDirectory
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private static void conventionMapOutputDirectory(TestNGOptions options, final DirectoryReport html) {
new DslObject(options).getConventionMapping().map("outputDirectory", new Callable<File>() {
public File call() {
return html.getDestination();
}
});
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:TestNGTestFramework.java
示例17: createDefaultIvyArtifact
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private DefaultIvyArtifact createDefaultIvyArtifact(File file, String extension, String type, String classifier) {
DefaultIvyArtifact ivyArtifact = instantiator.newInstance(
DefaultIvyArtifact.class,
file, null, extension, type, classifier
);
new DslObject(ivyArtifact).getConventionMapping().map("name", new Callable<String>() {
public String call() throws Exception {
return publicationIdentity.getModule();
}
});
return ivyArtifact;
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:IvyArtifactNotationParserFactory.java
示例18: configureGroovydoc
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureGroovydoc(final Project project) {
Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class);
groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code.");
groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath()));
GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
groovyDoc.setSource(groovySourceSet.getGroovy());
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:13,代码来源:GroovyPlugin.java
示例19: createProcessResourcesTaskForBinary
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void createProcessResourcesTaskForBinary(final SourceSet sourceSet, SourceDirectorySet resourceSet, final Project target) {
Copy resourcesTask = target.getTasks().create(sourceSet.getProcessResourcesTaskName(), ProcessResources.class);
resourcesTask.setDescription("Processes " + resourceSet + ".");
new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
public File call() throws Exception {
return sourceSet.getOutput().getResourcesDir();
}
});
resourcesTask.from(resourceSet);
}
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:JavaBasePlugin.java
示例20: configureSourceSetDefaults
import org.gradle.api.internal.plugins.DslObject; //导入依赖的package包/类
private void configureSourceSetDefaults(Project project) {
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(sourceSet -> {
ClojureSourceSet clojureSourceSet = new DefaultClojureSourceSet("clojure", sourceDirectorySetFactory);
new DslObject(sourceSet).getConvention().getPlugins().put("clojure", clojureSourceSet);
clojureSourceSet.getClojure().srcDir(String.format("src/%s/clojure", sourceSet.getName()));
// in case the clojure source overlaps with the resources source, exclude any clojure code
// from resources
sourceSet.getResources().getFilter().exclude(element -> clojureSourceSet.getClojure().contains(element.getFile()));
sourceSet.getAllSource().source(clojureSourceSet.getClojure());
String compileTaskName = sourceSet.getCompileTaskName("clojure");
ClojureCompile compile = project.getTasks().create(compileTaskName, ClojureCompile.class);
compile.setDescription(String.format("Compiles the %s Clojure source.", sourceSet.getName()));
compile.setSource(clojureSourceSet.getClojure());
// TODO presumably at some point this will allow providers, so we should switch to that
// instead of convention mapping
compile.getConventionMapping().map("classpath", () -> {
return sourceSet.getCompileClasspath()
.plus(project.files(sourceSet.getJava().getOutputDir()))
.plus(project.files(sourceSet.getOutput().getResourcesDir()));
});
// TODO switch to provider
compile.getConventionMapping().map("namespaces", compile::findNamespaces);
SourceSetUtil.configureOutputDirectoryForSourceSet(sourceSet, clojureSourceSet.getClojure(), compile, project);
compile.dependsOn(project.getTasks().getByName(sourceSet.getCompileJavaTaskName()));
compile.dependsOn(project.getTasks().getByName(sourceSet.getProcessResourcesTaskName()));
project.getTasks().getByName(sourceSet.getClassesTaskName()).dependsOn(compile);
});
}
开发者ID:gradle-clojure,项目名称:gradle-clojure,代码行数:34,代码来源:ClojureBasePlugin.java
注:本文中的org.gradle.api.internal.plugins.DslObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论