Back to project page masa.
The source code is released under:
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUC...
If you think the Android project masa listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.jvending.masa.plugin.apkbuilder; /*from www . j av a2s. c o m*/ import java.util.ArrayList; import java.util.List; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.jvending.masa.CommandExecutor; import org.jvending.masa.ExecutionException; /** * @goal verify * @phase verify * @description */ public class ApkVerifierMojo extends AbstractMojo { /** * The maven project. * * @parameter expression="${project}" */ public MavenProject project; public void execute() throws MojoExecutionException { CommandExecutor executor = CommandExecutor.Factory.createDefaultCommmandExecutor(); executor.setLogger( this.getLog() ); List<String> commands = new ArrayList<String>(); commands.add( "-verify" ); String apk = null; for ( Artifact a : (List<Artifact>) project.getAttachedArtifacts() ) { if ( a.getType().equals( "apk" ) && "signed-aligned".equals(a.getClassifier())) { apk = a.getFile().getAbsolutePath(); break; } } if ( apk == null ) { throw new MojoExecutionException( "Could not find source apk" ); } commands.add( apk ); this.getLog().info( "jarsigner" + commands.toString() ); try { executor.executeCommand( "jarsigner", commands, project.getBasedir(), false ); } catch ( ExecutionException e ) { throw new MojoExecutionException( "", e ); } if ( executor.getResult() == 1 ) { throw new MojoExecutionException( "Unable to validate apk" ); } getLog().info( "Apk is valid"); } }