use of org.gradle.api.artifacts.dsl.DependencyHandler in project gradle-eta by typelead.
the class DefaultEtaConfiguration method doResolve.
public void doResolve(final Project project, final DependencyHandler handler, final ImmutableDAG<String, PackageInfo> dependencyGraph, Set<String> resolvedDependencies) {
final Logger logger = project.getLogger();
final String configurationName = parentConfiguration.getName();
Set<String> resolvedDeps = new HashSet<String>();
for (Configuration configuration : parentConfiguration.getExtendsFrom()) {
DefaultEtaConfiguration etaConfiguration = ExtensionHelper.getExtension(configuration, DefaultEtaConfiguration.class);
etaConfiguration.doResolve(project, handler, dependencyGraph, resolvedDeps);
}
List<String> keys = new ArrayList<String>();
for (EtaDependency dep : dependencies) {
if (dep instanceof HasPackageName) {
keys.add(((HasPackageName) dep).getPackageName());
}
}
if (!resolved.get() && resolved.compareAndSet(false, true)) {
logger.info("Resolving Eta Configuration '" + parentConfiguration.getIncoming().getPath() + "'");
List<PackageInfo> packageInfos = dependencyGraph.differenceClosure(keys, resolvedDeps);
if (packageInfos.size() > 0) {
mavenRepository.installPackages(packageInfos, dependencyGraph);
resolvedMavenDependencies = packageInfos.stream().filter(packageInfo -> keys.contains(packageInfo.getName())).map(mavenRepository::getMavenDependency).collect(Collectors.toList());
for (String mavenDep : resolvedMavenDependencies) {
handler.add(configurationName, mavenDep);
logger.info("Injecting maven dependency '" + mavenDep + "'");
}
} else {
resolvedMavenDependencies = Collections.emptyList();
}
}
resolvedDependencies.addAll(resolvedDeps);
resolvedDependencies.addAll(keys);
}
use of org.gradle.api.artifacts.dsl.DependencyHandler in project component-runtime by Talend.
the class TaCoKitPlugin method apply.
@Override
public void apply(final Project project) {
// setup the global config
project.getExtensions().add("talendComponentKit", TaCoKitExtension.class);
// ensure we can find our dependencies
project.afterEvaluate(actionProject -> actionProject.getRepositories().mavenCentral());
// create the configuration for our task execution
final Configuration configuration = project.getConfigurations().maybeCreate("talendComponentKit");
configuration.getIncoming().beforeResolve(resolvableDependencies -> {
TaCoKitExtension extension = TaCoKitExtension.class.cast(project.getExtensions().findByName("talendComponentKit"));
if (extension == null) {
extension = new TaCoKitExtension();
}
final DependencyHandler dependencyHandler = project.getDependencies();
final DependencySet dependencies = configuration.getDependencies();
dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-api:" + extension.getApiVersion()));
dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-tools:" + extension.getSdkVersion()));
dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-runtime-design-extension:" + extension.getSdkVersion()));
});
// create the web configuration for our web task
final Configuration webConfiguration = project.getConfigurations().maybeCreate("talendComponentKitWeb");
webConfiguration.getIncoming().beforeResolve(resolvableDependencies -> {
TaCoKitExtension extension = TaCoKitExtension.class.cast(project.getExtensions().findByName("talendComponentKitWeb"));
if (extension == null) {
extension = new TaCoKitExtension();
}
final DependencyHandler dependencyHandler = project.getDependencies();
final DependencySet dependencies = configuration.getDependencies();
dependencies.add(dependencyHandler.create("org.talend.sdk.component:component-tools-webapp:" + extension.getSdkVersion()));
});
// tasks
final String group = "Talend Component Kit";
// TALEND-INF/dependencies.txt
project.task(new HashMap<String, Object>() {
{
put("type", DependenciesTask.class);
put("group", group);
put("description", "Creates the Talend Component Kit dependencies file used by the runtime to build the component classloader");
}
}, "talendComponentKitDependencies");
project.afterEvaluate(p -> p.getTasksByName("compileJava", false).stream().findFirst().ifPresent(compileJava -> compileJava.setFinalizedBy(singleton("talendComponentKitDependencies"))));
// validation
project.task(new HashMap<String, Object>() {
{
put("type", ValidateTask.class);
put("group", group);
put("description", "Validates that the module components are respecting the component standards.");
}
}, "talendComponentKitValidation");
project.afterEvaluate(p -> p.getTasksByName("classes", false).stream().findFirst().ifPresent(compileJava -> compileJava.setFinalizedBy(singleton("talendComponentKitValidation"))));
// documentation
project.task(new HashMap<String, Object>() {
{
put("type", DocumentationTask.class);
put("group", group);
put("description", "Generates an asciidoc file with the documentation of the components.");
}
}, "talendComponentKitDocumentation");
project.afterEvaluate(p -> p.getTasksByName("classes", false).stream().findFirst().ifPresent(compileJava -> compileJava.setFinalizedBy(singleton("talendComponentKitDocumentation"))));
// web
project.task(new HashMap<String, Object>() {
{
put("type", WebTask.class);
put("group", group);
put("description", "Starts a web server allowing you to browse your components (requires the component to be installed before).");
}
}, "talendComponentKitWebServer");
// car
project.task(new HashMap<String, Object>() {
{
put("type", CarTask.class);
put("group", group);
put("description", "Creates a Component ARchive (.car) based on current project.");
}
}, "talendComponentKitComponentArchive");
}
use of org.gradle.api.artifacts.dsl.DependencyHandler in project atlas by alibaba.
the class AtlasConfigurationHelper method registAtlasStreams.
// public void configDexPatchTasksAfterEvaluate() {
// if (PluginTypeUtils.isAppProject(project)) {
// AppExtension appExtension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(
// project.getExtensions(),
// "android"), AppExtension.class);
// new DexPatchTaskManager(AtlasBuildContext.androidBuilderMap.get(project),
// appExtension,
// project,
// atlasExtension).run();
// }
//
// }
public void registAtlasStreams() {
DependencyHandler dependencyHandler = project.getDependencies();
final String explodedAwbType = AtlasAndroidArtifacts.TYPE_EXPLODED_AWB;
final String explodedApType = AtlasAndroidArtifacts.TYPE_EXPLODED_AP;
final String explodedSolibType = AtlasAndroidArtifacts.TYPE_EXPLODED_SOLIB;
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, AtlasAndroidArtifacts.TYPE_AWB);
reg.getTo().attribute(ARTIFACT_FORMAT, explodedAwbType);
reg.artifactTransform(ExtractAwbTransform.class);
});
for (AndroidArtifacts.ArtifactType transformTarget : AarTransform.getTransformTargets()) {
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, explodedAwbType);
reg.getTo().attribute(ARTIFACT_FORMAT, transformTarget.getType());
reg.artifactTransform(AarTransform.class, config -> config.params(transformTarget));
});
}
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, explodedAwbType);
reg.getTo().attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.SYMBOL_LIST_WITH_PACKAGE_NAME.getType());
reg.artifactTransform(LibrarySymbolTableTransform.class);
});
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, AtlasAndroidArtifacts.TYPE_AP);
reg.getTo().attribute(ARTIFACT_FORMAT, explodedApType);
reg.artifactTransform(ExtractApTransform.class);
});
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, AtlasAndroidArtifacts.TYPE_SOLIB);
reg.getTo().attribute(ARTIFACT_FORMAT, explodedSolibType);
reg.artifactTransform(ExtractSolibTransform.class);
});
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, explodedSolibType);
reg.getTo().attribute(ARTIFACT_FORMAT, AndroidArtifacts.ArtifactType.JNI.getType());
reg.artifactTransform(LoadSolibTransform.class);
});
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, explodedAwbType);
reg.getTo().attribute(ARTIFACT_FORMAT, AtlasAndroidArtifacts.TYPE_LIBS);
reg.artifactTransform(LoadSolibFromLibsTransform.class);
});
dependencyHandler.registerTransform(reg -> {
reg.getFrom().attribute(ARTIFACT_FORMAT, AtlasAndroidArtifacts.AtlasArtifactType.EXPLODED_AAR.getType());
reg.getTo().attribute(ARTIFACT_FORMAT, AtlasAndroidArtifacts.TYPE_LIBS);
reg.artifactTransform(LoadSolibFromLibsTransform.class);
});
}
use of org.gradle.api.artifacts.dsl.DependencyHandler in project tomee by apache.
the class TomEEEmbeddedPlugin method apply.
@Override
public void apply(final Project project) {
final List<String> extensions = asList(TomEEEmbeddedExtension.NAME, TomEEEmbeddedExtension.ALIAS);
for (final String name : extensions) {
project.getExtensions().create(name, TomEEEmbeddedExtension.class);
}
project.afterEvaluate(new Action<Project>() {
@Override
public void execute(final Project actionProject) {
for (final String name : extensions) {
final TomEEEmbeddedExtension extension = TomEEEmbeddedExtension.class.cast(actionProject.getExtensions().findByName(name));
if (extension == null) {
return;
}
if (extension.isSkipDefaultRepository() != null && !extension.isSkipDefaultRepository()) {
actionProject.getRepositories().mavenCentral();
return;
}
}
actionProject.getRepositories().mavenCentral();
}
});
String configName = TomEEEmbeddedExtension.ALIAS;
try {
project.getConfigurations().getByName(configName);
} catch (final UnknownConfigurationException uce) {
configName = TomEEEmbeddedExtension.NAME;
}
final Configuration configuration = project.getConfigurations().maybeCreate(configName);
configuration.getIncoming().beforeResolve(new Action<ResolvableDependencies>() {
@Override
public void execute(final ResolvableDependencies resolvableDependencies) {
String tomeeVersion = null;
for (final String name : extensions) {
final TomEEEmbeddedExtension extension = TomEEEmbeddedExtension.class.cast(project.getExtensions().findByName(name));
if (extension == null) {
return;
}
tomeeVersion = extension.getTomeeVersion();
if (tomeeVersion != null) {
break;
}
}
if (tomeeVersion == null) {
try {
try (final InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/maven/org.apache.tomee.gradle/tomee-embedded/pom.properties")) {
final Properties p = new Properties();
p.load(is);
tomeeVersion = p.getProperty("version");
}
} catch (final IOException e) {
// we should never be there
tomeeVersion = "7.0.2";
}
}
final DependencyHandler dependencyHandler = project.getDependencies();
final DependencySet dependencies = configuration.getDependencies();
dependencies.add(dependencyHandler.create("org.apache.tomee:tomee-embedded:" + tomeeVersion));
}
});
project.task(new HashMap<String, Object>() {
{
put("type", TomEEEmbeddedTask.class);
put("group", "Embedded Application Server");
put("description", "Start an embedded Apache TomEE server deploying application classpath");
}
}, TomEEEmbeddedExtension.NAME);
}
use of org.gradle.api.artifacts.dsl.DependencyHandler in project gradle by gradle.
the class PomProjectInitDescriptor method configureClasspath.
@Override
public void configureClasspath(ProjectInternal.DetachedResolver detachedResolver, ObjectFactory objects) {
DependencyHandler dependencies = detachedResolver.getDependencies();
Configuration config = detachedResolver.getConfigurations().detachedConfiguration(dependencies.create("org.apache.maven:maven-core:" + MAVEN_VERSION), dependencies.create("org.apache.maven:maven-plugin-api:" + MAVEN_VERSION), dependencies.create("org.apache.maven:maven-compat:" + MAVEN_VERSION), dependencies.create("org.apache.maven.wagon:wagon-http:" + MAVEN_WAGON_VERSION), dependencies.create("org.apache.maven.wagon:wagon-provider-api:" + MAVEN_WAGON_VERSION), dependencies.create("org.eclipse.aether:aether-connector-basic:" + AETHER_VERSION), dependencies.create("org.eclipse.aether:aether-transport-wagon:" + AETHER_VERSION));
config.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.class, Usage.JAVA_RUNTIME));
detachedResolver.getRepositories().mavenCentral();
mavenClasspath = config;
}
Aggregations