コード例 #1
0
  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());
    }
  }
コード例 #2
0
  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());
    }
  }
コード例 #3
0
  private void processMakefileCapture(File localCIncludesFile, String ndkArchitecture)
      throws MojoExecutionException {

    try {
      if (attachHeaderFiles) {

        final List<HeaderFilesDirective> finalHeaderFilesDirectives =
            new ArrayList<HeaderFilesDirective>();

        if (useLocalSrcIncludePaths) {
          Properties props = new Properties();
          props.load(new FileInputStream(localCIncludesFile));
          String localCIncludes = props.getProperty("LOCAL_C_INCLUDES");
          if (localCIncludes != null && !localCIncludes.trim().isEmpty()) {
            String[] includes = localCIncludes.split(" ");
            for (String include : includes) {
              final HeaderFilesDirective headerFilesDirective = new HeaderFilesDirective();
              File includeDir = new File(project.getBasedir(), include);
              headerFilesDirective.setDirectory(includeDir.getAbsolutePath());
              headerFilesDirective.setIncludes(new String[] {"**/*.h"});
              finalHeaderFilesDirectives.add(headerFilesDirective);
            }
          }
        } else {
          if (headerFilesDirectives != null) {
            finalHeaderFilesDirectives.addAll(headerFilesDirectives);
          }
        }
        if (finalHeaderFilesDirectives.isEmpty()) {
          getLog().debug("No header files included, will add default set");
          final HeaderFilesDirective e = new HeaderFilesDirective();
          e.setDirectory(new File(project.getBasedir() + "/jni").getAbsolutePath());
          e.setIncludes(new String[] {"**/*.h"});
          finalHeaderFilesDirectives.add(e);
        }
        createHeaderArchive(finalHeaderFilesDirectives, ndkArchitecture);
      }
    } catch (Exception e) {
      throw new MojoExecutionException(
          "Error while processing headers to include: " + e.getMessage(), e);
    }
  }