protected void copyManifest ( ) throws MojoExecutionException { getLog ( ) . debug ( "copyManifest: " + androidManifestFile + " -> " + destinationManifestFile ) ; if ( androidManifestFile == null ) { getLog ( ) . debug ( "Manifest copying disabled. Using default manifest only" ) ; return ; } try { DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder db = dbf . newDocumentBuilder ( ) ; Document doc = db . parse ( androidManifestFile ) ; Source source = new DOMSource ( doc ) ; TransformerFactory xfactory = TransformerFactory . newInstance ( ) ; Transformer xformer = xfactory . newTransformer ( ) ; xformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; FileWriter writer = null ; try { destinationManifestFile . getParentFile ( ) . mkdirs ( ) ; writer = new FileWriter ( destinationManifestFile , false ) ; if ( doc . getXmlEncoding ( ) != null && doc . getXmlVersion ( ) != null ) { String xmldecl = String . format ( "<?xml version=\"%s\" encoding=\"%s\"?>%n" , doc . getXmlVersion ( ) , doc . getXmlEncoding ( ) ) ; writer . write ( xmldecl ) ; } Result result = new StreamResult ( writer ) ; xformer . transform ( source , result ) ; getLog ( ) . info ( "Manifest copied from " + androidManifestFile + " to " + destinationManifestFile ) ; } finally { IOUtils . closeQuietly ( writer ) ; } } catch ( Exception e ) { getLog ( ) . error ( "Error during copyManifest" ) ; throw new MojoExecutionException ( "Error during copyManifest" , e ) ; } }
Copy the AndroidManifest . xml from androidManifestFile to destinationManifestFile