Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing #529 #565

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,15 @@ private void addClassesToClasspath( UnpackedLibHelper helper, MavenProject proje
throw new MavenExecutionException( "Could not add " + classesJar.getName() + " as dependency", e );
}

// Add the classes to the classpath
final Dependency dependency = createSystemScopeDependency( artifact, classesJar, "extracted" );

// Modify the classpath to use an extracted dex file. This will overwrite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not using an extracted dex file though is it?
It's using the classes.jar from an unpacked aar lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm used to the classes.dex in an apk. I'll fix the doc.

// any exisiting dependencies with the same information.
final Dependency dependency = createSystemScopeDependency( artifact, classesJar, null );
final Dependency providedJar = findProvidedDependencies( dependency, project );
if ( providedJar != null )
{
project.getModel().removeDependency( providedJar );
}
project.getModel().addDependency( dependency );
}

Expand All @@ -285,5 +292,25 @@ private Dependency createSystemScopeDependency( Artifact artifact, File location
dependency.setSystemPath( location.getAbsolutePath() );
return dependency;
}

private Dependency findProvidedDependencies( Dependency dexDependency, MavenProject project )
{
for ( Dependency dependency : project.getDependencies() )
{
if ( dependency.getScope().equals( Artifact.SCOPE_PROVIDED ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they always going to be SCOPE_PROVIDED?

What dependency are you looking for the AAR or it's contained JAR?
NB dexDependency.getType() hasn't been defined when it was constructed so at best you are getting the default type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they always going to be SCOPE_PROVIDED?
HRM... Scope provided was put in there before because in the 3.x plugin series Maven would unpack both the jar and the library and then Android would blow up with conflicts. If we just always remove it then it would remove the need for provided. I like provided in the pom because it makes what is happening explicit, but I don't think it is necessary to check for it.

What dependency are you looking for the AAR or it's contained JAR?
Neither. I am looking for a jar dependency that will conflict with the system jar dependency which is about to be created.

I'll update to explicitly look for jar types.
I'm not sold on removing the provided type requirement.

{
if ( dependency.getArtifactId().equals( dexDependency.getArtifactId() )
&& dependency.getGroupId().equals( dexDependency.getGroupId() )
&& dependency.getType().equals( dexDependency.getType() )
&& dependency.getVersion().equals( dexDependency.getVersion() ) )
{
return dependency;
}
}
}
return null;

}

}