Search in sources :

Example 16 with AndroidProject

use of com.android.builder.model.AndroidProject in project android by JetBrains.

the class PluginVersionUpgradeTest method simulateAndroidModule.

private static void simulateAndroidModule(@NotNull Module module, int pluginGeneration) {
    AndroidProject androidProject = mock(AndroidProject.class);
    when(androidProject.getPluginGeneration()).thenReturn(pluginGeneration);
    AndroidModuleModel androidModel = mock(AndroidModuleModel.class);
    when(androidModel.getAndroidProject()).thenReturn(androidProject);
    AndroidFacet facet = createAndAddAndroidFacet(module);
    facet.setAndroidModel(androidModel);
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) AndroidProject(com.android.builder.model.AndroidProject) Facets.createAndAddAndroidFacet(com.android.tools.idea.testing.Facets.createAndAddAndroidFacet) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 17 with AndroidProject

use of com.android.builder.model.AndroidProject in project android by JetBrains.

the class AndroidGeneratedSourcesFilterTest method createAndroidModel.

@NotNull
private static AndroidModuleModel createAndroidModel(@NotNull VirtualFile buildFolder) {
    AndroidProject androidProject = mock(AndroidProject.class);
    when(androidProject.getBuildFolder()).thenReturn(virtualToIoFile(buildFolder));
    AndroidModuleModel androidModel = mock(AndroidModuleModel.class);
    when(androidModel.getAndroidProject()).thenReturn(androidProject);
    return androidModel;
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) AndroidProject(com.android.builder.model.AndroidProject) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with AndroidProject

use of com.android.builder.model.AndroidProject in project gradle by gradle.

the class GetModel method execute.

@Override
public Map<String, AndroidProject> execute(BuildController controller) {
    System.out.println("* Building models");
    Timer timer = new Timer();
    GradleBuild build = controller.getBuildModel();
    Map<String, AndroidProject> result = new TreeMap<String, AndroidProject>();
    for (BasicGradleProject project : build.getProjects()) {
        AndroidProject androidProject = controller.findModel(project, AndroidProject.class);
        result.put(project.getPath(), androidProject);
    }
    timer.stop();
    System.out.println("building models took " + timer.duration());
    //            new Inspector().inspectModel(result);
    return result;
}
Also used : BasicGradleProject(org.gradle.tooling.model.gradle.BasicGradleProject) AndroidProject(com.android.builder.model.AndroidProject) TreeMap(java.util.TreeMap) GradleBuild(org.gradle.tooling.model.gradle.GradleBuild)

Example 19 with AndroidProject

use of com.android.builder.model.AndroidProject in project gradle by gradle.

the class Inspector method inspectModel.

void inspectModel(Map<String, AndroidProject> models) {
    System.out.println("* Inspecting");
    Timer timer = new Timer();
    for (AndroidProject androidProject : models.values()) {
        if (androidProject == null) {
            continue;
        }
        inspect(androidProject);
    }
    timer.stop();
    System.out.println("Inspect took " + timer.duration());
    System.out.println("---");
    System.out.println("Android libs: " + libsByEquality.size());
    System.out.println("Android libs by file: " + libsByFile.size());
    System.out.println("Android libs by id: " + libsByIdentity.size());
    System.out.println("Android libs by id (backing): " + libsBackingByIdentity.size());
    System.out.println("Java libs: " + javaLibsByEquality.size());
    System.out.println("Java libs by file: " + javaLibsByFile.size());
    System.out.println("Java libs by id: " + javaLibsByIdentity.size());
    System.out.println("Java libs by id (backing): " + javaLibsBackingByIdentity.size());
    System.out.println("---");
}
Also used : AndroidProject(com.android.builder.model.AndroidProject)

Example 20 with AndroidProject

use of com.android.builder.model.AndroidProject in project kotlin by JetBrains.

the class RegistrationDetector method reportMissing.

private static void reportMissing(@NonNull JavaContext context, @NonNull PsiClass node, @NonNull String className, @NonNull String tag) {
    if (tag.equals(TAG_RECEIVER)) {
        // Receivers can be registered in code; don't flag these.
        return;
    }
    // Don't flag activities registered in test source sets
    if (context.getProject().isGradleProject()) {
        AndroidProject model = context.getProject().getGradleProjectModel();
        if (model != null) {
            String javaSource = context.file.getPath();
            for (SourceProviderContainer extra : model.getDefaultConfig().getExtraSourceProviders()) {
                String artifactName = extra.getArtifactName();
                if (AndroidProject.ARTIFACT_ANDROID_TEST.equals(artifactName)) {
                    for (File file : extra.getSourceProvider().getJavaDirectories()) {
                        if (SdkUtils.startsWithIgnoreCase(javaSource, file.getPath())) {
                            return;
                        }
                    }
                }
            }
            for (ProductFlavorContainer container : model.getProductFlavors()) {
                for (SourceProviderContainer extra : container.getExtraSourceProviders()) {
                    String artifactName = extra.getArtifactName();
                    if (AndroidProject.ARTIFACT_ANDROID_TEST.equals(artifactName)) {
                        for (File file : extra.getSourceProvider().getJavaDirectories()) {
                            if (SdkUtils.startsWithIgnoreCase(javaSource, file.getPath())) {
                                return;
                            }
                        }
                    }
                }
            }
        }
    }
    Location location = context.getNameLocation(node);
    String message = String.format("The `<%1$s> %2$s` is not registered in the manifest", tag, className);
    context.report(ISSUE, node, location, message);
}
Also used : ProductFlavorContainer(com.android.builder.model.ProductFlavorContainer) AndroidProject(com.android.builder.model.AndroidProject) SourceProviderContainer(com.android.builder.model.SourceProviderContainer) File(java.io.File) Location(com.android.tools.klint.detector.api.Location)

Aggregations

AndroidProject (com.android.builder.model.AndroidProject)35 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)12 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)7 File (java.io.File)7 Variant (com.android.builder.model.Variant)6 Module (com.intellij.openapi.module.Module)6 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)6 NotNull (org.jetbrains.annotations.NotNull)6 ModuleNodeBuilder (com.android.tools.idea.gradle.AndroidModelView.ModuleNodeBuilder)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 NonNull (com.android.annotations.NonNull)3 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)3 Project (com.intellij.openapi.project.Project)3 IOException (java.io.IOException)3 AndroidLibrary (com.android.builder.model.AndroidLibrary)2 LintOptions (com.android.builder.model.LintOptions)2 ProductFlavorContainer (com.android.builder.model.ProductFlavorContainer)2 LibraryDependency (com.android.tools.idea.gradle.project.sync.setup.module.dependency.LibraryDependency)2 GradleUtil.getAndroidProject (com.android.tools.idea.gradle.util.GradleUtil.getAndroidProject)2 GradleUtil.getNativeAndroidProject (com.android.tools.idea.gradle.util.GradleUtil.getNativeAndroidProject)2