Search in sources :

Example 1 with RepositoriesModel

use of com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel in project android by JetBrains.

the class GradleBuildModel method repositories.

@NotNull
public RepositoriesModel repositories() {
    RepositoriesDslElement repositoriesDslElement = myGradleDslFile.getPropertyElement(REPOSITORIES_BLOCK_NAME, RepositoriesDslElement.class);
    if (repositoriesDslElement == null) {
        repositoriesDslElement = new RepositoriesDslElement(myGradleDslFile);
        myGradleDslFile.setNewElement(REPOSITORIES_BLOCK_NAME, repositoriesDslElement);
    }
    return new RepositoriesModel(repositoriesDslElement);
}
Also used : RepositoriesModel(com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel) RepositoriesDslElement(com.android.tools.idea.gradle.dsl.parser.repositories.RepositoriesDslElement) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with RepositoriesModel

use of com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel in project android by JetBrains.

the class BuildScriptModel method repositories.

@NotNull
public RepositoriesModel repositories() {
    RepositoriesDslElement repositoriesDslElement = myDslElement.getPropertyElement(REPOSITORIES_BLOCK_NAME, RepositoriesDslElement.class);
    if (repositoriesDslElement == null) {
        repositoriesDslElement = new RepositoriesDslElement(myDslElement);
        myDslElement.setNewElement(REPOSITORIES_BLOCK_NAME, repositoriesDslElement);
    }
    return new RepositoriesModel(repositoriesDslElement);
}
Also used : RepositoriesModel(com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel) RepositoriesDslElement(com.android.tools.idea.gradle.dsl.parser.repositories.RepositoriesDslElement) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with RepositoriesModel

use of com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel in project android by JetBrains.

the class BuildScriptModelTest method testParseRepositories.

public void testParseRepositories() throws IOException {
    String text = "buildscript {\n" + "  repositories {\n" + "    jcenter()\n" + "  }\n" + "}";
    writeToBuildFile(text);
    RepositoriesModel repositoriesModel = getGradleBuildModel().buildscript().repositories();
    List<RepositoryModel> repositories = repositoriesModel.repositories();
    assertThat(repositories).hasSize(1);
    RepositoryModel repositoryModel = repositories.get(0);
    assertTrue(repositoryModel instanceof JCenterDefaultRepositoryModel);
    JCenterDefaultRepositoryModel repository = (JCenterDefaultRepositoryModel) repositoryModel;
    assertEquals("name", "BintrayJCenter2", repository.name());
    assertEquals("url", "https://jcenter.bintray.com/", repository.url());
}
Also used : JCenterDefaultRepositoryModel(com.android.tools.idea.gradle.dsl.model.repositories.JCenterDefaultRepositoryModel) RepositoriesModel(com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel) JCenterDefaultRepositoryModel(com.android.tools.idea.gradle.dsl.model.repositories.JCenterDefaultRepositoryModel) RepositoryModel(com.android.tools.idea.gradle.dsl.model.repositories.RepositoryModel)

Aggregations

RepositoriesModel (com.android.tools.idea.gradle.dsl.model.repositories.RepositoriesModel)3 RepositoriesDslElement (com.android.tools.idea.gradle.dsl.parser.repositories.RepositoriesDslElement)2 NotNull (org.jetbrains.annotations.NotNull)2 JCenterDefaultRepositoryModel (com.android.tools.idea.gradle.dsl.model.repositories.JCenterDefaultRepositoryModel)1 RepositoryModel (com.android.tools.idea.gradle.dsl.model.repositories.RepositoryModel)1