@NotNull
  static String doValidatePackageName(
      boolean library, @NotNull String candidate, @Nullable ModulesProvider modulesProvider) {
    if (candidate.length() == 0) {
      return AndroidBundle.message("specify.package.name.error");
    }
    if (!AndroidUtils.isValidAndroidPackageName(candidate)) {
      return candidate;
    }
    if (!AndroidCommonUtils.contains2Identifiers(candidate)) {
      return AndroidBundle.message("package.name.must.contain.2.ids.error");
    }

    if (!library) {
      for (Module module : modulesProvider.getModules()) {
        final AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet != null && !facet.isLibraryProject()) {
          final Manifest manifest = facet.getManifest();
          if (manifest != null) {
            final String packageName = manifest.getPackage().getValue();
            if (candidate.equals(packageName)) {
              return "Package name '"
                  + packageName
                  + "' is already used by module '"
                  + module.getName()
                  + "'";
            }
          }
        }
      }
    }
    return "";
  }
  @NotNull
  @Override
  public List<? extends ArtifactTemplate> getNewArtifactTemplates(
      @NotNull PackagingElementResolvingContext context) {
    final List<AndroidFacet> facets = new ArrayList<AndroidFacet>();

    for (Module module : context.getModulesProvider().getModules()) {
      final FacetModel facetModel = context.getModulesProvider().getFacetModel(module);
      final AndroidFacet facet = facetModel.getFacetByType(AndroidFacet.ID);

      if (facet != null && !facet.isLibraryProject()) {
        facets.add(facet);
      }
    }

    if (facets.size() == 0) {
      return Collections.emptyList();
    }
    return Collections.singletonList(new MyTemplate(context.getProject(), facets));
  }