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

Use even more injected properties #473

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,6 +32,7 @@
import com.jayway.maven.plugins.android.config.ConfigPojo;
import com.jayway.maven.plugins.android.configuration.Ndk;
import com.jayway.maven.plugins.android.configuration.Sdk;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.TrueFileFilter;
import org.apache.commons.jxpath.JXPathContext;
Expand All @@ -42,6 +43,7 @@
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -146,11 +148,23 @@ public abstract class AbstractAndroidMojo extends AbstractMojo
protected File sourceDirectory;

/**
* The java target directory. Ie target/classes.
* The project build directory. Ie target.
*/
@Parameter( defaultValue = "${project.build.directory}", readonly = true )
protected File targetDirectory;

/**
* The output directory. Ie target/classes.
*/
@Parameter( defaultValue = "${project.build.outputDirectory}", readonly = true )
protected File projectOutputDirectory;

/**
* The project resources. By default a list containing src/main/resources.
*/
@Parameter( defaultValue = "${project.build.resources}", readonly = true )
protected List<Resource> resources;

/**
* The final name of the artifact.
*/
Expand Down
Expand Up @@ -614,7 +614,7 @@ protected boolean isEnableIntegrationTest() throws MojoFailureException, MojoExe
getLog().info( "No InstrumentationRunner found - skipping tests" );
return false;
}
return AndroidTestFinder.containsAndroidTests( new File( project.getBuild().getOutputDirectory() ) );
return AndroidTestFinder.containsAndroidTests( projectOutputDirectory );
}

throw new MojoFailureException( "android.test.skip must be configured as 'true', 'false' or 'auto'." );
Expand Down
Expand Up @@ -536,7 +536,7 @@ private List< ProGuardInput > getProgramInputFiles()
}

// we first add the application's own class files
inJars.add( createProguardInput( project.getBuild().getOutputDirectory() ) );
inJars.add( createProguardInput( projectOutputDirectory.getAbsolutePath() ) );

// we then add all its dependencies (incl. transitive ones), unless they're blacklisted
for ( Artifact artifact : getTransitiveDependencyArtifacts() )
Expand Down
Expand Up @@ -282,7 +282,7 @@ private Set< File > getDexInputFiles() throws MojoExecutionException
{
getLog().debug( "Using non-obfuscated input" );
// no proguard, use original config
inputs.add( new File( project.getBuild().getOutputDirectory() ) );
inputs.add( projectOutputDirectory );
getLog().debug( "Adding dex input : " + project.getBuild().getOutputDirectory() );
for ( Artifact artifact : getTransitiveDependencyArtifacts() )
{
Expand Down Expand Up @@ -626,7 +626,7 @@ protected File createApkSourcesFile() throws MojoExecutionException
addDirectory( jarArchiver, assetsDirectory, "assets" );
addDirectory( jarArchiver, resourceDirectory, "res" );
addDirectory( jarArchiver, sourceDirectory, "src/main/java" );
addJavaResources( jarArchiver, project.getBuild().getResources() );
addJavaResources( jarArchiver, resources );

jarArchiver.createArchive();
}
Expand Down
Expand Up @@ -153,7 +153,7 @@ protected File createAarClassesJar() throws MojoExecutionException
{
JarArchiver jarArchiver = new JarArchiver();
jarArchiver.setDestFile( classesJar );
jarArchiver.addDirectory( new File( project.getBuild().getOutputDirectory() ),
jarArchiver.addDirectory( projectOutputDirectory,
classesJarIncludes,
classesJarExcludes );
jarArchiver.createArchive();
Expand Down
Expand Up @@ -476,7 +476,7 @@ private void doAPKWithAPKBuilder( File outputFile, File dexFile, File zipArchive
boolean signWithDebugKeyStore ) throws MojoExecutionException
{
getLog().debug( "Building APK with internal APKBuilder" );
sourceFolders.add( new File( project.getBuild().getOutputDirectory() ) );
sourceFolders.add( projectOutputDirectory );

for ( Artifact artifact : getRelevantCompileArtifacts() )
{
Expand Down Expand Up @@ -625,7 +625,7 @@ public boolean accept( File dir, String name )

private File removeDuplicatesFromJar( File in, List<String> duplicates )
{
String target = project.getBuild().getOutputDirectory();
String target = projectOutputDirectory.getAbsolutePath();
File tmp = new File( target, "unpacked-embedded-jars" );
tmp.mkdirs();
File out = new File( tmp, in.getName() );
Expand Down
Expand Up @@ -157,7 +157,7 @@ private File createApkLibraryFile() throws MojoExecutionException
}
}

addJavaResources( jarArchiver, project.getBuild().getResources(), "src" );
addJavaResources( jarArchiver, resources, "src" );

// Lastly, add any native libraries
addNativeLibraries( jarArchiver );
Expand Down
Expand Up @@ -572,7 +572,7 @@ private String getClasspath()
{
if ( parsedClasspath == null )
{
parsedClasspath = new File( project.getBuild().getOutputDirectory() ).getAbsolutePath();
parsedClasspath = projectOutputDirectory.getAbsolutePath();
}
return parsedClasspath;
}
Expand Down
Expand Up @@ -141,8 +141,7 @@ public boolean include( JarEntry jarEntry )

try
{
File sourceDirectory = new File( project.getBuild().getOutputDirectory() );
FileUtils.copyDirectory( sourceDirectory, outputDirectory );
FileUtils.copyDirectory( projectOutputDirectory, outputDirectory );
}
catch ( IOException e )
{
Expand Down