本文整理匯總了Java中org.gradle.api.Plugin類的典型用法代碼示例。如果您正苦於以下問題:Java Plugin類的具體用法?Java Plugin怎麽用?Java Plugin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Plugin類屬於org.gradle.api包,在下文中一共展示了Plugin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configureExtensionRule
import org.gradle.api.Plugin; //導入依賴的package包/類
private void configureExtensionRule() {
final ConventionMapping extensionMapping = conventionMappingOf(extension);
extensionMapping.map("sourceSets", Callables.returning(new ArrayList()));
extensionMapping.map("reportsDir", new Callable<File>() {
@Override
public File call() {
return project.getExtensions().getByType(ReportingExtension.class).file(getReportName());
}
});
withBasePlugin(new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
extensionMapping.map("sourceSets", new Callable<SourceSetContainer>() {
@Override
public SourceSetContainer call() {
return getJavaPluginConvention().getSourceSets();
}
});
}
});
}
示例2: apply
import org.gradle.api.Plugin; //導入依賴的package包/類
public void apply(final Project project) {
project.getPlugins().apply(GitHubPlugin.class);
project.getPlugins().apply(BintrayReleasePlugin.class);
project.getPlugins().apply(TravisPlugin.class);
project.allprojects(new Action<Project>() {
public void execute(final Project subproject) {
subproject.getPlugins().withId("java", new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
subproject.getPlugins().apply(JavaBintrayPlugin.class);
}
});
}
});
}
示例3: apply
import org.gradle.api.Plugin; //導入依賴的package包/類
@Override
public void apply(final Project project) {
project.getPlugins().apply(GitHubContributorsPlugin.class);
project.allprojects(new Action<Project>() {
public void execute(final Project subproject) {
subproject.getPlugins().withType(JavaPublishPlugin.class, new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
final Task fetcher = project.getTasks().getByName(GitHubContributorsPlugin.FETCH_CONTRIBUTORS);
//Because maven-publish plugin uses new configuration model, we cannot get the task directly
//So we use 'matching' technique
subproject.getTasks().matching(withName(POM_TASK)).all(new Action<Task>() {
public void execute(Task t) {
t.dependsOn(fetcher);
}
});
}
});
}
});
}
示例4: resolve
import org.gradle.api.Plugin; //導入依賴的package包/類
public void resolve(PluginRequest pluginRequest, PluginResolutionResult result) {
PluginId id = pluginRequest.getId();
if (!id.isQualified() || id.inNamespace(CorePluginRegistry.CORE_PLUGIN_NAMESPACE)) {
try {
Class<? extends Plugin> typeForId = pluginRegistry.getTypeForId(id.getName());
if (pluginRequest.getVersion() != null) {
throw new InvalidPluginRequestException(pluginRequest,
"Plugin '" + id + "' is a core Gradle plugin, which cannot be specified with a version number. "
+ "Such plugins are versioned as part of Gradle. Please remove the version number from the declaration."
);
}
result.found(getDescription(), new SimplePluginResolution(id, typeForId));
} catch (UnknownPluginException e) {
result.notFound(getDescription(), String.format("not a core plugin, please see %s for available core plugins", documentationRegistry.getDocumentationFor("standard_plugins")));
}
} else {
result.notFound(getDescription(), String.format("plugin is not in '%s' namespace", CorePluginRegistry.CORE_PLUGIN_NAMESPACE));
}
}
示例5: load
import org.gradle.api.Plugin; //導入依賴的package包/類
@Override
public Boolean load(@SuppressWarnings("NullableProblems") IdLookupCacheKey key) throws Exception {
Class<?> pluginClass = key.pluginClass;
// Plugin registry will have the mapping cached in memory for most plugins, try first
try {
Class<? extends Plugin<?>> typeForId = pluginRegistry.getTypeForId(key.id);
if (typeForId.equals(pluginClass)) {
return true;
}
} catch (UnknownPluginException ignore) {
// ignore
}
PluginDescriptorLocator locator = new ClassloaderBackedPluginDescriptorLocator(pluginClass.getClassLoader());
PluginDescriptor pluginDescriptor = locator.findPluginDescriptor(key.id);
return pluginDescriptor != null && pluginDescriptor.getImplementationClassName().equals(pluginClass.getName());
}
示例6: configureSourceSetRule
import org.gradle.api.Plugin; //導入依賴的package包/類
private void configureSourceSetRule() {
withBasePlugin(new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
configureForSourceSets(getJavaPluginConvention().getSourceSets());
}
});
}
示例7: configureCheckTask
import org.gradle.api.Plugin; //導入依賴的package包/類
private void configureCheckTask() {
withBasePlugin(new Action<Plugin>() {
@Override
public void execute(Plugin plugin) {
configureCheckTaskDependents();
}
});
}
示例8: createActionApplyingEclipseWtpPlugin
import org.gradle.api.Plugin; //導入依賴的package包/類
private Action<Plugin<Project>> createActionApplyingEclipseWtpPlugin() {
return new Action<Plugin<Project>>() {
@Override
public void execute(Plugin<Project> plugin) {
project.getPluginManager().apply(EclipseWtpPlugin.class);
}
};
}
示例9: plugin
import org.gradle.api.Plugin; //導入依賴的package包/類
public ObjectConfigurationAction plugin(final Class<? extends Plugin> pluginClass) {
actions.add(new Runnable() {
public void run() {
applyPlugin(pluginClass);
}
});
return this;
}
示例10: DefaultPluginContainer
import org.gradle.api.Plugin; //導入依賴的package包/類
public DefaultPluginContainer(PluginRegistry pluginRegistry, final PluginManagerInternal pluginManager) {
super(Plugin.class);
this.pluginRegistry = pluginRegistry;
this.pluginManager = pluginManager;
// Need this to make withId() work when someone does project.plugins.add(new SomePlugin());
whenObjectAdded(new Action<Plugin>() {
public void execute(Plugin plugin) {
pluginManager.addImperativePlugin(plugin.getClass());
}
});
}
示例11: apply
import org.gradle.api.Plugin; //導入依賴的package包/類
public Plugin apply(String id) {
PluginImplementation plugin = pluginRegistry.lookup(PluginId.unvalidated(id));
if (plugin == null) {
throw new UnknownPluginException("Plugin with id '" + id + "' not found.");
}
if (!Plugin.class.isAssignableFrom(plugin.asClass())) {
throw new IllegalArgumentException("Plugin implementation '" + plugin.asClass().getName() + "' does not implement the Plugin interface. This plugin cannot be applied directly via the PluginContainer.");
} else {
return pluginManager.addImperativePlugin(plugin);
}
}
示例12: findPlugin
import org.gradle.api.Plugin; //導入依賴的package包/類
public <P extends Plugin> P findPlugin(Class<P> type) {
for (Plugin plugin : this) {
if (plugin.getClass().equals(type)) {
return type.cast(plugin);
}
}
return null;
}
示例13: getPlugin
import org.gradle.api.Plugin; //導入依賴的package包/類
public Plugin getPlugin(String id) {
Plugin plugin = findPlugin(id);
if (plugin == null) {
throw new UnknownPluginException("Plugin with id " + id + " has not been used.");
}
return plugin;
}
示例14: withId
import org.gradle.api.Plugin; //導入依賴的package包/類
public void withId(final String pluginId, final Action<? super Plugin> action) {
Action<DefaultPluginManager.PluginWithId> wrappedAction = new Action<DefaultPluginManager.PluginWithId>() {
public void execute(final DefaultPluginManager.PluginWithId pluginWithId) {
matching(new Spec<Plugin>() {
public boolean isSatisfiedBy(Plugin element) {
return pluginWithId.clazz.equals(element.getClass());
}
}).all(action);
}
};
pluginManager.pluginsForId(pluginId).all(wrappedAction);
}
示例15: withType
import org.gradle.api.Plugin; //導入依賴的package包/類
@Override
public <S extends Plugin> PluginCollection<S> withType(Class<S> type) {
// runtime check because method is used from Groovy where type bounds are not respected
if (!Plugin.class.isAssignableFrom(type)) {
throw new IllegalArgumentException(String.format("'%s' does not implement the Plugin interface.", type.getName()));
}
return super.withType(type);
}