Search in sources :

Example 16 with DependencyHandler

use of org.gradle.api.artifacts.dsl.DependencyHandler in project gradle-eta by typelead.

the class EtaInstallAllDependencies method installAllDependencies.

@TaskAction
public void installAllDependencies() {
    final File workingDir = getDestinationDir();
    /* Fork an etlas process to install the dependencies.  */
    final EtlasCommand etlas = new EtlasCommand(project);
    etlas.getWorkingDirectory().set(workingDir);
    boolean isUpToDate = etlas.deps(EtlasCommand.libTarget(getProject().getName()), dependencyGraph -> {
        for (Project p : project.getAllprojects()) {
            if (p.getConvention().findPlugin(EtaPluginConvention.class) != null) {
                DependencyHandler dependencies = p.getDependencies();
                for (Configuration c : p.getConfigurations()) {
                    final EtaConfiguration etaConfiguration = ExtensionHelper.getExtension(c, EtaConfiguration.class);
                    if (etaConfiguration != null) {
                        etaConfiguration.resolve(project, dependencies, dependencyGraph);
                    }
                }
            }
        }
        for (Project p : project.getAllprojects()) {
            if (p.getPlugins().findPlugin(EtaPlugin.class) == null && p.getConvention().findPlugin(JavaPluginConvention.class) != null) {
                p.getTasks().withType(EtaInjectDependencies.class).all(EtaInjectDependencies::injectDependencies);
            }
        }
    });
    setDidWork(!isUpToDate);
}
Also used : Project(org.gradle.api.Project) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) Configuration(org.gradle.api.artifacts.Configuration) EtaPluginConvention(com.typelead.gradle.eta.plugins.EtaPluginConvention) EtaConfiguration(com.typelead.gradle.eta.api.EtaConfiguration) File(java.io.File) RegularFile(org.gradle.api.file.RegularFile) InputFile(org.gradle.api.tasks.InputFile) EtlasCommand(com.typelead.gradle.utils.EtlasCommand) TaskAction(org.gradle.api.tasks.TaskAction)

Example 17 with DependencyHandler

use of org.gradle.api.artifacts.dsl.DependencyHandler in project atlas by alibaba.

the class AtlasDependencyGraph method handleSources.

private static void handleSources(@NonNull Project project, @NonNull Set<ComponentIdentifier> artifacts, @NonNull Consumer<SyncIssue> failureConsumer) {
    final DependencyHandler dependencies = project.getDependencies();
    try {
        ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery();
        query.forComponents(artifacts);
        @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[] { SourcesArtifact.class };
        query.withArtifacts(JvmLibrary.class, artifactTypesArray);
        query.execute().getResolvedComponents();
    } catch (Throwable t) {
        DependencyFailureHandlerKt.processDependencyThrowable(t, s -> null, (data, messages) -> failureConsumer.accept(new SyncIssueImpl(SyncIssue.TYPE_GENERIC, SyncIssue.SEVERITY_WARNING, null, String.format("Unable to download sources: %s", messages.get(0)), messages)));
    }
}
Also used : ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) AtlasPlugin(com.taobao.android.builder.AtlasPlugin) AtlasAndroidArtifacts(com.android.build.gradle.internal.publishing.AtlasAndroidArtifacts) CreatingCache(com.android.ide.common.caching.CreatingCache) Matcher(java.util.regex.Matcher) FileUtils(com.android.utils.FileUtils) ResolvedVariantResult(org.gradle.api.artifacts.result.ResolvedVariantResult) com.google.common.collect(com.google.common.collect) MavenCoordinatesImpl(com.android.builder.dependency.MavenCoordinatesImpl) Artifact(org.gradle.api.component.Artifact) GraphItem(com.android.builder.model.level2.GraphItem) Project(org.gradle.api.Project) Nullable(com.android.annotations.Nullable) AndroidArtifacts(com.android.build.gradle.internal.publishing.AndroidArtifacts) BooleanOption(com.android.build.gradle.options.BooleanOption) ComponentArtifactIdentifier(org.gradle.api.artifacts.component.ComponentArtifactIdentifier) ArtifactCollection(org.gradle.api.artifacts.ArtifactCollection) FilteredArtifactCollection(com.android.build.gradle.internal.dependency.FilteredArtifactCollection) Spec(org.gradle.api.specs.Spec) NonNull(com.android.annotations.NonNull) VariantType(com.android.builder.core.VariantType) ARTIFACT_TYPE(com.android.build.gradle.internal.publishing.AndroidArtifacts.ARTIFACT_TYPE) com.android.build.gradle.internal.ide.level2(com.android.build.gradle.internal.ide.level2) Pattern(java.util.regex.Pattern) ResolvedArtifactResult(org.gradle.api.artifacts.result.ResolvedArtifactResult) EMPTY_DEPENDENCY_GRAPH(com.android.build.gradle.internal.ide.ModelBuilder.EMPTY_DEPENDENCY_GRAPH) JvmLibrary(org.gradle.jvm.JvmLibrary) java.util(java.util) SdkConstants(com.android.SdkConstants) OpaqueComponentArtifactIdentifier(org.gradle.internal.component.local.model.OpaqueComponentArtifactIdentifier) VariantAttr(com.android.build.gradle.internal.dependency.VariantAttr) ComponentIdentifier(org.gradle.api.artifacts.component.ComponentIdentifier) ConfigurationDependencyGraphs(com.android.build.gradle.internal.dependency.ConfigurationDependencyGraphs) VariantScope(com.android.build.gradle.internal.scope.VariantScope) EMPTY_DEPENDENCIES_IMPL(com.android.build.gradle.internal.ide.ModelBuilder.EMPTY_DEPENDENCIES_IMPL) Configuration(org.gradle.api.artifacts.Configuration) ImmutableCollectors(com.android.utils.ImmutableCollectors) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) com.android.builder.model(com.android.builder.model) ArtifactResolutionQuery(org.gradle.api.artifacts.query.ArtifactResolutionQuery) SourcesArtifact(org.gradle.language.base.artifact.SourcesArtifact) Action(org.gradle.api.Action) Library(com.android.builder.model.level2.Library) File(java.io.File) ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) Consumer(java.util.function.Consumer) ArtifactCollectionWithExtraArtifact(com.android.build.gradle.internal.dependency.ArtifactCollectionWithExtraArtifact) JavaLibraryImpl(com.android.build.gradle.internal.ide.level2.JavaLibraryImpl) Preconditions(com.google.common.base.Preconditions) DependencyGraphs(com.android.builder.model.level2.DependencyGraphs) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) ArtifactResolutionQuery(org.gradle.api.artifacts.query.ArtifactResolutionQuery) Artifact(org.gradle.api.component.Artifact) SourcesArtifact(org.gradle.language.base.artifact.SourcesArtifact) ArtifactCollectionWithExtraArtifact(com.android.build.gradle.internal.dependency.ArtifactCollectionWithExtraArtifact)

Example 18 with DependencyHandler

use of org.gradle.api.artifacts.dsl.DependencyHandler in project curiostack by curioswitch.

the class CuriostackPlugin method addStandardJavaTestDependencies.

private static void addStandardJavaTestDependencies(Project project) {
    Configuration testConfiguration = project.getPlugins().hasPlugin(JavaLibraryPlugin.class) ? project.getConfigurations().getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME) : project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME);
    DependencyHandler dependencies = project.getDependencies();
    dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305");
    dependencies.add(testConfiguration.getName(), "org.curioswitch.curiostack:curio-testing-framework");
    dependencies.add(testConfiguration.getName(), "org.assertj:assertj-core");
    dependencies.add(testConfiguration.getName(), "org.awaitility:awaitility");
    dependencies.add(testConfiguration.getName(), "junit:junit");
    dependencies.add(testConfiguration.getName(), "org.mockito:mockito-core");
    dependencies.add(testConfiguration.getName(), "info.solidsoft.mockito:mockito-java8");
    dependencies.add(testConfiguration.getName(), "org.junit.jupiter:junit-jupiter-api");
    dependencies.add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.jupiter:junit-jupiter-engine");
    dependencies.add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.vintage:junit-vintage-engine");
}
Also used : DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) Configuration(org.gradle.api.artifacts.Configuration) JavaLibraryPlugin(org.gradle.api.plugins.JavaLibraryPlugin)

Aggregations

DependencyHandler (org.gradle.api.artifacts.dsl.DependencyHandler)18 Configuration (org.gradle.api.artifacts.Configuration)12 Project (org.gradle.api.Project)7 File (java.io.File)6 EtaConfiguration (com.typelead.gradle.eta.api.EtaConfiguration)3 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)3 DependencySet (org.gradle.api.artifacts.DependencySet)3 Usage (org.gradle.api.attributes.Usage)3 FileCollection (org.gradle.api.file.FileCollection)3 AndroidArtifacts (com.android.build.gradle.internal.publishing.AndroidArtifacts)2 AtlasAndroidArtifacts (com.android.build.gradle.internal.publishing.AtlasAndroidArtifacts)2 EtlasCommand (com.typelead.gradle.utils.EtlasCommand)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Properties (java.util.Properties)2 Callable (java.util.concurrent.Callable)2 Action (org.gradle.api.Action)2 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)2 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)2 AttributeContainer (org.gradle.api.attributes.AttributeContainer)2