logging IDEA-90325

This commit is contained in:
Eugene Kudelevsky
2012-08-22 19:18:32 +04:00
parent a3a2e1572a
commit d3092844ee
3 changed files with 62 additions and 17 deletions
@@ -430,4 +430,6 @@ android.extract.as.include.title=Extract Android Layout
android.inline.layout.command.name=Inline Layout File ''{0}''
android.inline.file.inline.all.text=Inline &all references and remove the file
android.inline.file.inline.this.text=Inline &this usage and keep the file
android.inline.layout.title=Inline Android Layout
android.inline.layout.title=Inline Android Layout
android.facet.importing.notification.group=Importing Error
android.facet.importing.title=Error when importing module ''{0}''
@@ -152,16 +152,18 @@ public class AndroidExternalApklibDependenciesManager implements PersistentState
private String myVersion;
private String myType;
private String myLibraryName;
private String myScope;
public MavenDependencyInfo() {
}
public MavenDependencyInfo(@NotNull MavenId mavenId, @NotNull String type, @NotNull String libraryName) {
public MavenDependencyInfo(@NotNull MavenId mavenId, @NotNull String type, @NotNull String scope, @NotNull String libraryName) {
myGroupId = mavenId.getGroupId();
myArtifactId = mavenId.getArtifactId();
myVersion = mavenId.getVersion();
myType = type;
myLibraryName = libraryName;
myScope = scope;
}
public String getGroupId() {
@@ -184,6 +186,10 @@ public class AndroidExternalApklibDependenciesManager implements PersistentState
return myLibraryName;
}
public String getScope() {
return myScope;
}
public void setGroupId(String groupId) {
myGroupId = groupId;
}
@@ -203,5 +209,9 @@ public class AndroidExternalApklibDependenciesManager implements PersistentState
public void setLibraryName(String libraryName) {
myLibraryName = libraryName;
}
public void setScope(String scope) {
myScope = scope;
}
}
}
@@ -48,6 +48,7 @@ import org.jetbrains.android.facet.AndroidFacetConfiguration;
import org.jetbrains.android.facet.AndroidFacetType;
import org.jetbrains.android.facet.AndroidRootUtil;
import org.jetbrains.android.sdk.*;
import org.jetbrains.android.util.AndroidBundle;
import org.jetbrains.android.util.AndroidNativeLibData;
import org.jetbrains.android.util.AndroidUtils;
import org.jetbrains.annotations.NonNls;
@@ -57,6 +58,7 @@ import org.jetbrains.idea.maven.importing.FacetImporter;
import org.jetbrains.idea.maven.importing.MavenModifiableModelsProvider;
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
import org.jetbrains.idea.maven.model.MavenArtifact;
import org.jetbrains.idea.maven.model.MavenConstants;
import org.jetbrains.idea.maven.model.MavenId;
import org.jetbrains.idea.maven.project.*;
import org.jetbrains.idea.maven.server.MavenEmbedderWrapper;
@@ -119,10 +121,8 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
}
if (hasApkSources) {
Notifications.Bus.notify(new Notification("Importing Error", "Error when importing module " + facet.getModule().getName(),
"'apksources' dependency is deprecated and can be poorly supported by IDE. " +
"It is strongly recommended to use 'apklib' dependency instead.",
NotificationType.ERROR, null));
reportError("'apksources' dependency is deprecated and can be poorly supported by IDE. " +
"It is strongly recommended to use 'apklib' dependency instead.", facet.getModule().getName());
}
}
@@ -372,7 +372,7 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
}
}
else {
LOG.info("Cannot find file " + artifactFile.getPath());
reportError("Cannot find file " + artifactFile.getPath(), genModuleName);
}
final VirtualFile vApklibDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(targetDirPath);
@@ -394,7 +394,8 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
contentEntry.addSourceFolder(sourceRoot, false);
}
else {
LOG.info("Cannot find " + AndroidMavenUtil.APK_LIB_ARTIFACT_SOURCE_ROOT + " directory in " + vApklibDir.getPath());
reportError("Cannot find " + AndroidMavenUtil.APK_LIB_ARTIFACT_SOURCE_ROOT + " directory in " + vApklibDir.getPath(),
genModuleName);
}
final AndroidFacet facet = AndroidUtils.addAndroidFacet(apklibModuleModel.getModule(), vApklibDir, true);
@@ -421,6 +422,7 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
MavenProjectsTree mavenTree,
MavenArtifact artifact,
Map<MavenProject, String> mavenProject2ModuleName) {
final String apklibModuleName = apklibModuleModel.getModule().getName();
final AndroidExternalApklibDependenciesManager adm = AndroidExternalApklibDependenciesManager.getInstance(project);
final AndroidExternalApklibDependenciesManager.MyResolvedInfo resolvedInfo =
adm.getResolvedInfoForArtifact(artifact.getMavenId());
@@ -438,16 +440,20 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
apklibModuleModel.setSdk(sdk);
moveJdkOrderEntryDown(apklibModuleModel);
}
else {
reportError("Cannot find appropriate Android platform", apklibModuleName);
}
for (AndroidExternalApklibDependenciesManager.MavenDependencyInfo depArtifactInfo : resolvedInfo.getApklibDependencies()) {
final MavenId depMavenId = new MavenId(depArtifactInfo.getGroupId(), depArtifactInfo.getArtifactId(),
final MavenId depMavenId = new MavenId(depArtifactInfo.getGroupId(), depArtifactInfo.getArtifactId(),
depArtifactInfo.getVersion());
final String type = depArtifactInfo.getType();
final String scope = depArtifactInfo.getScope();
if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(type)) {
final MavenProject depProject = mavenTree.findProject(depMavenId);
if (depProject != null) {
final String depModuleName = mavenProject2ModuleName.get(depProject);
@@ -474,14 +480,37 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
newLibEntry.setScope(libEntry.getScope());
}
}
else {
final String message = "Cannot find library " + libraryName + " in the dependencies of module '" +
rootModel.getModule().getName() + "'";
if (MavenConstants.SCOPE_COMPILE.equals(scope) ||
MavenConstants.SCOPE_RUNTIME.equals(scope) ||
MavenConstants.SCOPE_PROVIDEED.equals(scope)) {
reportError(message, apklibModuleName);
}
else {
LOG.info(message);
}
}
}
}
}
else {
LOG.info("Cannot find sdk info for artifact " + artifact.getMavenId().getKey());
reportError("Cannot find sdk info for artifact " + artifact.getMavenId().getKey(), apklibModuleName);
}
}
private static void reportError(String message, String modName) {
reportMessage(message, modName, NotificationType.ERROR);
}
private static void reportMessage(String message, String modName, NotificationType notificationType) {
Notifications.Bus.notify(new Notification(AndroidBundle.message("android.facet.importing.notification.group"),
AndroidBundle.message("android.facet.importing.title", modName),
message, notificationType, null));
LOG.debug(message);
}
@Nullable
private static LibraryOrderEntry findLibraryByName(ModifiableRootModel model, final String libraryName) {
final Ref<LibraryOrderEntry> result = Ref.create(null);
@@ -515,7 +544,7 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(depArtifact.getType()) &&
mavenProjectsManager.findProject(depArtifact) == null) {
doResolveApklibArtifact(project, depArtifact, embedder, mavenProjectsManager);
doResolveApklibArtifact(project, depArtifact, embedder, mavenProjectsManager, mavenProject.getName());
}
}
}
@@ -523,16 +552,17 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
private void doResolveApklibArtifact(Project project,
MavenArtifact artifact,
MavenEmbedderWrapper embedder,
MavenProjectsManager mavenProjectsManager) throws MavenProcessCanceledException {
MavenProjectsManager mavenProjectsManager,
String moduleName) throws MavenProcessCanceledException {
final File depArtifacetFile = new File(FileUtil.getNameWithoutExtension(artifact.getPath()) + ".pom");
if (!depArtifacetFile.exists()) {
LOG.info("Cannot find file " + depArtifacetFile.getPath());
reportError("Cannot find file " + depArtifacetFile.getPath(), moduleName);
return;
}
final VirtualFile vDepArtifactFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(depArtifacetFile);
if (vDepArtifactFile == null) {
LOG.error("Cannot find file " + depArtifacetFile.getPath() + " in VFS");
reportError("Cannot find file " + depArtifacetFile.getPath() + " in VFS", moduleName);
return;
}
@@ -561,7 +591,7 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
final String depArtifactLibraryName = depArtifact.getLibraryName();
dependencies.add(new AndroidExternalApklibDependenciesManager.MavenDependencyInfo(
depArtifact.getMavenId(), depArtifact.getType(), depArtifactLibraryName));
depArtifact.getMavenId(), depArtifact.getType(), depArtifact.getScope(), depArtifactLibraryName));
}
final AndroidExternalApklibDependenciesManager apklibDependenciesManager =
@@ -590,6 +620,9 @@ public abstract class AndroidFacetImporterBase extends FacetImporter<AndroidFace
if (platformLib != null) {
model.setSdk(platformLib);
}
else {
reportError("Cannot find appropriate Android platform", model.getModule().getName());
}
}
moveJdkOrderEntryDown(model);
}