Search in sources :

Example 1 with DefaultExternalModuleDependency

use of org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency in project gradle by gradle.

the class ExternalModuleDependencyDescriptorFactoryTest method testAddWithNullGroupAndNullVersionShouldHaveEmptyStringModuleRevisionValues.

@Test
public void testAddWithNullGroupAndNullVersionShouldHaveEmptyStringModuleRevisionValues() {
    ModuleDependency dependency = new DefaultExternalModuleDependency(null, "gradle-core", null, TEST_DEP_CONF);
    DslOriginDependencyMetadata dependencyMetaData = externalModuleDependencyDescriptorFactory.createDependencyDescriptor(TEST_CONF, null, dependency);
    assertThat(dependencyMetaData.getRequested().getGroup(), equalTo(""));
    assertThat(dependencyMetaData.getRequested().getName(), equalTo("gradle-core"));
    assertThat(dependencyMetaData.getRequested().getVersion(), equalTo(""));
}
Also used : ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) DslOriginDependencyMetadata(org.gradle.internal.component.local.model.DslOriginDependencyMetadata) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Test(org.junit.Test)

Example 2 with DefaultExternalModuleDependency

use of org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency in project gradle by gradle.

the class ScalaRuntime method inferScalaClasspath.

/**
     * Searches the specified class path for a 'scala-library' Jar, and returns a class path
     * containing a corresponding (same version) 'scala-compiler' Jar and its dependencies.
     *
     * <p>The returned class path may be empty, or may fail to resolve when asked for its contents.
     *
     * @param classpath a class path containing a 'scala-library' Jar
     * @return a class path containing a corresponding 'scala-compiler' Jar and its dependencies
     */
public FileCollection inferScalaClasspath(final Iterable<File> classpath) {
    // would differ in the following ways: 1. live (not sure if we want live here) 2. no autowiring (probably want autowiring here)
    return new LazilyInitializedFileCollection() {

        @Override
        public String getDisplayName() {
            return "Scala runtime classpath";
        }

        @Override
        public FileCollection createDelegate() {
            if (project.getRepositories().isEmpty()) {
                throw new GradleException(String.format("Cannot infer Scala class path because no repository is declared in %s", project));
            }
            File scalaLibraryJar = findScalaJar(classpath, "library");
            if (scalaLibraryJar == null) {
                throw new GradleException(String.format("Cannot infer Scala class path because no Scala library Jar was found. " + "Does %s declare dependency to scala-library? Searched classpath: %s.", project, classpath));
            }
            String scalaVersion = getScalaVersion(scalaLibraryJar);
            if (scalaVersion == null) {
                throw new AssertionError(String.format("Unexpectedly failed to parse version of Scala Jar file: %s in %s", scalaLibraryJar, project));
            }
            return project.getConfigurations().detachedConfiguration(new DefaultExternalModuleDependency("org.scala-lang", "scala-compiler", scalaVersion));
        }

        // let's override this so that delegate isn't created at autowiring time (which would mean on every build)
        @Override
        public void visitDependencies(TaskDependencyResolveContext context) {
            if (classpath instanceof Buildable) {
                context.add(classpath);
            }
        }
    };
}
Also used : TaskDependencyResolveContext(org.gradle.api.internal.tasks.TaskDependencyResolveContext) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) LazilyInitializedFileCollection(org.gradle.api.internal.file.collections.LazilyInitializedFileCollection) File(java.io.File)

Example 3 with DefaultExternalModuleDependency

use of org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency in project gradle by gradle.

the class ExternalModuleDependencyDescriptorFactoryTest method testCreateFromModuleDependency.

@Test
public void testCreateFromModuleDependency() {
    DefaultExternalModuleDependency moduleDependency = new DefaultExternalModuleDependency("org.gradle", "gradle-core", "1.0", TEST_DEP_CONF);
    setUpDependency(moduleDependency);
    DslOriginDependencyMetadata dependencyMetaData = externalModuleDependencyDescriptorFactory.createDependencyDescriptor(TEST_CONF, null, moduleDependency);
    assertEquals(moduleDependency.isChanging(), dependencyMetaData.isChanging());
    assertEquals(moduleDependency.isForce(), dependencyMetaData.isForce());
    assertEquals(moduleDependency.getGroup(), dependencyMetaData.getRequested().getGroup());
    assertEquals(moduleDependency.getName(), dependencyMetaData.getRequested().getName());
    assertEquals(moduleDependency.getVersion(), dependencyMetaData.getRequested().getVersion());
    assertDependencyDescriptorHasCommonFixtureValues(dependencyMetaData);
}
Also used : DslOriginDependencyMetadata(org.gradle.internal.component.local.model.DslOriginDependencyMetadata) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Test(org.junit.Test)

Example 4 with DefaultExternalModuleDependency

use of org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency in project gradle by gradle.

the class PlayRunAdapterV23X method getRunsupportClasspathDependencies.

@Override
public Iterable<Dependency> getRunsupportClasspathDependencies(String playVersion, String scalaCompatibilityVersion) {
    ImmutableList.Builder<Dependency> listBuilder = ImmutableList.builder();
    String runsupportPlayVersion = playVersion;
    boolean transitive = true;
    // use run-support from 2.3.7 for versions before Play 2.3.7
    if (VersionNumber.parse(playVersion).compareTo(MINIMUM_PLAY_VERSION_WITH_RUN_SUPPORT) < 0) {
        runsupportPlayVersion = "2.3.7";
        transitive = false;
    }
    DefaultExternalModuleDependency runSupportDependency = new DefaultExternalModuleDependency("com.typesafe.play", RUN_SUPPORT_PLAY_MODULE + "_" + scalaCompatibilityVersion, runsupportPlayVersion);
    runSupportDependency.setTransitive(transitive);
    listBuilder.add(runSupportDependency);
    String name = scalaCompatibilityVersion.equals("2.10") ? "io" : ("io_" + scalaCompatibilityVersion);
    DefaultExternalModuleDependency dependency = new DefaultExternalModuleDependency("org.scala-sbt", name, getIOSupportDependencyVersion(), "runtime");
    dependency.setTransitive(false);
    listBuilder.add(dependency);
    return listBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) DefaultExternalModuleDependency(org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency) Dependency(org.gradle.api.artifacts.Dependency)

Aggregations

DefaultExternalModuleDependency (org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency)4 DslOriginDependencyMetadata (org.gradle.internal.component.local.model.DslOriginDependencyMetadata)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 File (java.io.File)1 Dependency (org.gradle.api.artifacts.Dependency)1 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 LazilyInitializedFileCollection (org.gradle.api.internal.file.collections.LazilyInitializedFileCollection)1 TaskDependencyResolveContext (org.gradle.api.internal.tasks.TaskDependencyResolveContext)1