This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
Fix Android container not exported in m2e 1.6 #363
Merged
rgladwell
merged 1 commit into
rgladwell:master
from
WonderCsabo:fixAndroidContainerNotExported
Jul 3, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import com.google.inject.AbstractModule; | ||
import com.google.inject.Provides; | ||
|
||
import me.gladwell.eclipse.m2e.android.AndroidMavenProjectConfigurator; | ||
|
||
public class ClasspathModule extends AbstractModule { | ||
|
||
@Override | ||
|
@@ -44,7 +46,9 @@ List<ClasspathConfigurer> provideClasspathConfigurers(final AddNonRuntimeClasspa | |
classpathConfigurers.add(new ModifySourceFolderOutputClasspathConfigurer()); | ||
classpathConfigurers.add(new RemoveJREClasspathContainerConfigurer()); | ||
classpathConfigurers.add(new MarkMavenClasspathContianerExportedConfigurer()); | ||
classpathConfigurers.add(new MarkAndroidClasspathContainerNotExportedConfigurer()); | ||
if (!AndroidMavenProjectConfigurator.usesM2E1_6OrNewer()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Nice way of maintaining backwards compatibility. |
||
classpathConfigurers.add(new MarkAndroidClasspathContainerNotExportedConfigurer()); | ||
} | ||
classpathConfigurers.add(new IgnoreOptionalWarningsConfigurer()); | ||
|
||
return Collections.unmodifiableList(classpathConfigurers); | ||
|
67 changes: 67 additions & 0 deletions
67
...e/android/configuration/workspace/MarkAndroidClasspathContainerNotExportedConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2013, 2014, 2015 Ricardo Gladwell | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't forget to update the copyright notices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not really matter, and actually i just copied this class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're sure you should make sure you get credit. |
||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*******************************************************************************/ | ||
|
||
package me.gladwell.eclipse.m2e.android.configuration.workspace; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.jdt.core.IClasspathEntry; | ||
import org.eclipse.jdt.core.IJavaProject; | ||
import org.eclipse.jdt.core.JavaCore; | ||
import org.eclipse.jdt.core.JavaModelException; | ||
import org.eclipse.m2e.jdt.IClasspathDescriptor; | ||
import org.eclipse.m2e.jdt.IClasspathEntryDescriptor; | ||
import org.eclipse.m2e.jdt.internal.ClasspathDescriptor; | ||
|
||
import com.google.inject.Inject; | ||
|
||
import me.gladwell.eclipse.m2e.android.configuration.ProjectConfigurationException; | ||
import me.gladwell.eclipse.m2e.android.project.IDEAndroidProject; | ||
import me.gladwell.eclipse.m2e.android.project.IDEAndroidProjectFactory; | ||
import me.gladwell.eclipse.m2e.android.project.MavenAndroidProject; | ||
|
||
public class MarkAndroidClasspathContainerNotExportedConfigurer implements WorkspaceConfigurer { | ||
|
||
private final IDEAndroidProjectFactory factory; | ||
|
||
@Inject | ||
public MarkAndroidClasspathContainerNotExportedConfigurer(IDEAndroidProjectFactory factory) { | ||
this.factory = factory; | ||
} | ||
|
||
public boolean isConfigured(IDEAndroidProject project) { | ||
return false; | ||
} | ||
|
||
public boolean isValid(MavenAndroidProject project) { | ||
return true; | ||
} | ||
|
||
public void configure(IDEAndroidProject eclipseProject, MavenAndroidProject mavenProject) { | ||
try { | ||
IJavaProject javaProject = JavaCore.create(eclipseProject.getProject()); | ||
IClasspathDescriptor classpath = new ClasspathDescriptor(javaProject); | ||
IDEAndroidProject androidProject = factory.createAndroidProject(javaProject.getProject(), classpath); | ||
|
||
androidProject.getClasspath().getAndroidClasspathContainer().markNotExported(); | ||
|
||
List<IClasspathEntryDescriptor> descriptors = classpath.getEntryDescriptors(); | ||
IClasspathEntry[] entries = new IClasspathEntry[descriptors.size()]; | ||
|
||
for (int i = 0; i < descriptors.size(); ++i) { | ||
entries[i] = descriptors.get(i).toClasspathEntry(); | ||
} | ||
|
||
javaProject.setRawClasspath(entries, new NullProgressMonitor()); | ||
} catch (JavaModelException e) { | ||
throw new ProjectConfigurationException("Could not mark ADT libraries container as not exported", e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved descriptive method name, but I think its better to have a method that returns whether we're using M2E 1.5 or earlier instead to avoid the use of the negation
!
operators which can be confusing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we test against the
true
case here: https://github.com/rgladwell/m2e-android/pull/363/files#diff-b7c4af84c9011346c7842073feca3d61R26There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 good point, didn't spot that