Search in sources :

Example 11 with GradleVersion

use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.

the class GradleVersionsUnitTest method rc.

@Test
public void rc() {
    // Regression test for https://code.google.com/p/android/issues/detail?id=179838
    File jarFile = new File("gradle-core-2.5-rc-1.jar");
    GradleVersion gradleVersion = GradleVersions.getGradleVersionFromJar(jarFile);
    assertNotNull(gradleVersion);
    assertEquals(GradleVersion.parse("2.5"), gradleVersion);
}
Also used : GradleVersion(com.android.ide.common.repository.GradleVersion) File(java.io.File) Test(org.junit.Test)

Example 12 with GradleVersion

use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.

the class GradleVersionsUnitTest method getGradleVersionFromJarUsingNonGradleLibraryJar.

@Test
public void getGradleVersionFromJarUsingNonGradleLibraryJar() {
    File jarFile = new File("ant-1.9.3.jar");
    GradleVersion gradleVersion = GradleVersions.getGradleVersionFromJar(jarFile);
    assertNull(gradleVersion);
}
Also used : GradleVersion(com.android.ide.common.repository.GradleVersion) File(java.io.File) Test(org.junit.Test)

Example 13 with GradleVersion

use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.

the class GradleVersionsUnitTest method nightly.

@Test
public void nightly() {
    File jarFile = new File("gradle-core-2.10-20151029230024+0000.jar");
    GradleVersion gradleVersion = GradleVersions.getGradleVersionFromJar(jarFile);
    assertNotNull(gradleVersion);
    assertEquals(GradleVersion.parse("2.10"), gradleVersion);
}
Also used : GradleVersion(com.android.ide.common.repository.GradleVersion) File(java.io.File) Test(org.junit.Test)

Example 14 with GradleVersion

use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.

the class AndroidGradleJavaProjectModelModifier method findNewExternalDependency.

@Nullable
private static ArtifactDependencySpec findNewExternalDependency(@NotNull Library library, @NotNull AndroidModuleModel androidModel) {
    GradleVersion modelVersion = androidModel.getModelVersion();
    JavaLibrary matchedLibrary = null;
    for (BaseArtifact testArtifact : androidModel.getTestArtifactsInSelectedVariant()) {
        matchedLibrary = findMatchedLibrary(library, testArtifact, modelVersion);
        if (matchedLibrary != null) {
            break;
        }
    }
    if (matchedLibrary == null) {
        Variant selectedVariant = androidModel.getSelectedVariant();
        matchedLibrary = findMatchedLibrary(library, selectedVariant.getMainArtifact(), modelVersion);
    }
    if (matchedLibrary == null) {
        return null;
    }
    // TODO use getRequestedCoordinates once the interface is fixed.
    MavenCoordinates coordinates = matchedLibrary.getResolvedCoordinates();
    if (coordinates == null) {
        return null;
    }
    return new ArtifactDependencySpec(coordinates.getArtifactId(), coordinates.getGroupId(), coordinates.getVersion());
}
Also used : GradleVersion(com.android.ide.common.repository.GradleVersion) ArtifactDependencySpec(com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencySpec) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with GradleVersion

use of com.android.ide.common.repository.GradleVersion in project android by JetBrains.

the class AndroidContentEntriesSetup method addGeneratedSourceFolders.

private void addGeneratedSourceFolders(@NotNull BaseArtifact artifact, @NotNull List<ContentEntry> contentEntries, boolean isTest) {
    JpsModuleSourceRootType sourceType = getSourceType(isTest);
    GradleVersion modelVersion = myAndroidModel.getModelVersion();
    if (artifact instanceof AndroidArtifact || (modelVersion != null && modelVersion.compareIgnoringQualifiers("1.2") >= 0)) {
        // getGeneratedSourceFolders used to be in AndroidArtifact only.
        Collection<File> generatedSourceFolders = getGeneratedSourceFolders(artifact);
        //noinspection ConstantConditions - this returned null in 1.2
        if (generatedSourceFolders != null) {
            addSourceFolders(generatedSourceFolders, contentEntries, sourceType, true);
        }
    }
    if (artifact instanceof AndroidArtifact) {
        sourceType = getResourceSourceType(isTest);
        AndroidArtifact androidArtifact = (AndroidArtifact) artifact;
        addSourceFolders(androidArtifact.getGeneratedResourceFolders(), contentEntries, sourceType, true);
    }
}
Also used : JpsModuleSourceRootType(org.jetbrains.jps.model.module.JpsModuleSourceRootType) GradleVersion(com.android.ide.common.repository.GradleVersion) File(java.io.File)

Aggregations

GradleVersion (com.android.ide.common.repository.GradleVersion)77 File (java.io.File)25 Test (org.junit.Test)16 Module (com.intellij.openapi.module.Module)12 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)11 Nullable (org.jetbrains.annotations.Nullable)10 Project (com.intellij.openapi.project.Project)6 NotNull (org.jetbrains.annotations.NotNull)6 ArtifactDependencyModel (com.android.tools.idea.gradle.dsl.model.dependencies.ArtifactDependencyModel)5 IOException (java.io.IOException)5 AndroidPluginInfo (com.android.tools.idea.gradle.plugin.AndroidPluginInfo)4 FixAndroidGradlePluginVersionHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.FixAndroidGradlePluginVersionHyperlink)3 NotificationHyperlink (com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink)3 SyncMessage (com.android.tools.idea.gradle.project.sync.messages.SyncMessage)3 ZipFile (java.util.zip.ZipFile)3 VisibleForTesting (com.android.annotations.VisibleForTesting)2 Variant (com.android.builder.model.Variant)2 IDevice (com.android.ddmlib.IDevice)2 Revision (com.android.repository.Revision)2 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)2