/** Generates a manifest file to be included in the .hpi file */ protected void generateManifest(MavenArchiveConfiguration archive, File manifestFile) throws MojoExecutionException { // create directory if it doesn't exist yet if (!manifestFile.getParentFile().exists()) manifestFile.getParentFile().mkdirs(); getLog().info("Generating " + manifestFile); MavenArchiver ma = new MavenArchiver(); ma.setOutputFile(manifestFile); PrintWriter printWriter = null; try { Manifest mf = ma.getManifest(project, archive.getManifest()); Section mainSection = mf.getMainSection(); setAttributes(mainSection); printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(manifestFile), "UTF-8")); mf.write(printWriter); } catch (ManifestException e) { throw new MojoExecutionException("Error preparing the manifest: " + e.getMessage(), e); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Error preparing the manifest: " + e.getMessage(), e); } catch (IOException e) { throw new MojoExecutionException("Error preparing the manifest: " + e.getMessage(), e); } finally { IOUtil.close(printWriter); } }
private void createHeaderArchive( List<HeaderFilesDirective> finalHeaderFilesDirectives, String ndkArchitecture) throws MojoExecutionException { try { MavenArchiver mavenArchiver = new MavenArchiver(); mavenArchiver.setArchiver(jarArchiver); final File jarFile = new File( new File(project.getBuild().getDirectory()), project.getBuild().getFinalName() + ".har"); mavenArchiver.setOutputFile(jarFile); for (HeaderFilesDirective headerFilesDirective : finalHeaderFilesDirectives) { mavenArchiver .getArchiver() .addDirectory( new File(headerFilesDirective.getDirectory()), headerFilesDirective.getIncludes(), headerFilesDirective.getExcludes()); } final MavenArchiveConfiguration mavenArchiveConfiguration = new MavenArchiveConfiguration(); mavenArchiveConfiguration.setAddMavenDescriptor(false); mavenArchiver.createArchive(project, mavenArchiveConfiguration); String classifier = ndkArchitecture; if (ndkClassifier != null) { classifier += "-" + ndkClassifier; } getLog().debug("Attaching 'har' classifier=" + classifier + " file=" + jarFile); projectHelper.attachArtifact( project, Const.ArtifactType.NATIVE_HEADER_ARCHIVE, classifier, jarFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }
private void createHeaderArchive( List<HeaderFilesDirective> finalHeaderFilesDirectives, String ndkArchitecture) throws MojoExecutionException { try { MavenArchiver mavenArchiver = new MavenArchiver(); mavenArchiver.setArchiver(jarArchiver); final File jarFile = new File( new File(project.getBuild().getDirectory()), project.getBuild().getFinalName() + ".har"); mavenArchiver.setOutputFile(jarFile); for (HeaderFilesDirective headerFilesDirective : finalHeaderFilesDirectives) { mavenArchiver .getArchiver() .addDirectory( new File(headerFilesDirective.getDirectory()), headerFilesDirective.getIncludes(), headerFilesDirective.getExcludes()); } final MavenArchiveConfiguration mavenArchiveConfiguration = new MavenArchiveConfiguration(); mavenArchiveConfiguration.setAddMavenDescriptor(false); mavenArchiver.createArchive(project, mavenArchiveConfiguration); if (AndroidExtension.APKLIB.equals(project.getPackaging())) { projectHelper.attachArtifact(project, "har", ndkClassifier, jarFile); } else { projectHelper.attachArtifact(project, "har", ndkArchitecture, jarFile); } } catch (Exception e) { throw new MojoExecutionException(e.getMessage()); } }