@Override
  protected void executeWithGems()
      throws MojoExecutionException, ScriptException, IOException, GemException {

    if (includeRubyResources != null) {
      // add it to the classpath so java classes can find the ruby files
      Resource resource = new Resource();
      resource.setDirectory(project.getBasedir().getAbsolutePath());
      for (String include : includeRubyResources) {
        resource.addInclude(include);
      }
      if (excludeRubyResources != null) {
        for (String exclude : excludeRubyResources) {
          resource.addExclude(exclude);
        }
      }
      addResource(project.getBuild().getResources(), resource);
    }

    if (includeBinStubs) {
      Resource resource = new Resource();
      resource.setDirectory(gemsConfig.getBinDirectory().getAbsolutePath());
      resource.addInclude("*");
      resource.setTargetPath("META-INF/jruby.home/bin");
      addResource(project.getBuild().getResources(), resource);
    }
  }
  private List<Resource> getResources() {
    Resource appFolderResource = new Resource();
    appFolderResource.setDirectory(this.appDirectory.getAbsolutePath());
    appFolderResource.setFiltering(true);

    return Arrays.asList(appFolderResource);
  }
Ejemplo n.º 3
0
  public void execute() throws MojoExecutionException {

    AetherUtil.setRepositorySystemSession(repoSession);
    AetherUtil.setRepositorySystem(repoSystem);

    mergerComponent = new KevoreeMergerComponent();

    ContainerRoot model = KevoreeFactory.createContainerRoot();

    if (sourceMarShellDirectory != null) {
      ContainerRoot model2 = executeOnDirectory(sourceMarShellDirectory);
      mergerComponent.merge(model, model2);
    }

    if (sourceMarShellDirectory2 != null) {
      ContainerRoot model2 = executeOnDirectory(sourceMarShellDirectory2);
      mergerComponent.merge(model, model2);
    }

    if (!sourceOutputDirectory.exists() && !sourceOutputDirectory.mkdirs()) {
      throw new MojoExecutionException(
          "Unable to build target packages " + sourceOutputDirectory.getAbsolutePath());
    }

    KevoreeXmiHelper.save(
        sourceOutputDirectory.getAbsolutePath() + File.separator + "lib.kev", model);

    Resource resource = new Resource();
    resource.setTargetPath("KEV-INF");
    resource.setDirectory(sourceOutputDirectory.getAbsolutePath());

    project.addResource(resource);
  }
  /**
   * make room for a Manifest file. use a generated resource for JARS and for WARS use the manifest
   * in the webapp/meta-inf directory.
   *
   * @throws MojoExecutionException
   */
  private void addManifestResource(EclipseWriterConfig config) throws MojoExecutionException {
    if (isJavaProject()) {
      // special case must be done first because it can add stuff to the classpath that will be
      // written by the superclass
      new RadManifestWriter().init(getLog(), config).write();
    }

    if (isJavaProject()
        && !Constants.PROJECT_PACKAGING_EAR.equals(packaging)
        && !Constants.PROJECT_PACKAGING_WAR.equals(packaging)
        && !Constants.PROJECT_PACKAGING_EJB.equals(packaging)
        && !NO_GENERATED_RESOURCE_DIRNAME.equals(this.generatedResourceDirName)) {

      String generatedResourceDir =
          this.project.getBasedir().getAbsolutePath()
              + File.separatorChar
              + this.generatedResourceDirName;

      String metainfDir = generatedResourceDir + File.separatorChar + "META-INF";

      new File(metainfDir).mkdirs();

      final Resource resource = new Resource();

      getLog().debug("Adding " + this.generatedResourceDirName + " to resources");

      resource.setDirectory(generatedResourceDir);

      this.executedProject.addResource(resource);
    }

    if (Constants.PROJECT_PACKAGING_WAR.equals(packaging)) {
      new File(getWebContentBaseDirectory(config) + File.separatorChar + "META-INF").mkdirs();
    }
  }
  private void addOutputToSourcesIfNeeded() {
    final Boolean add = addOutputDirectoryToCompilationSources;
    if (add == null || add.booleanValue()) {
      getLog().info("Source directory: " + outputDirectory + " added");
      addCompileSourceRoot(project, outputDirectory.getAbsolutePath());
      getLog().info("Resource directory: " + outputDirectory + " added");

      Resource resourceDirectory = new Resource();
      resourceDirectory.setDirectory(outputDirectory.getAbsolutePath());
      project.addResource(resourceDirectory);
    }
  }
  protected void includeDescriptorResource() {

    final Resource resource = new Resource();

    final String sourcePath = outputDirectorySCR().getPath();
    final String targetPath = targetDirectorySCR;

    resource.setDirectory(sourcePath);
    resource.setTargetPath(targetPath);

    getLog().info("");
    getLog().info("including descriptor resource = " + resource);

    project.addResource(resource);
  }
Ejemplo n.º 7
0
 private MavenProject createMavenProject(String projectRootPath) throws IOException {
   File projectFile = new File(projectRootPath + "/pom.xml").getAbsoluteFile();
   MavenProject project = new MavenProject();
   project.setFile(projectFile);
   project
       .getBuild()
       .setOutputDirectory(
           projectFile
               .getParentFile()
               .toPath()
               .resolve("target/classes")
               .toFile()
               .getCanonicalPath());
   Resource resource = new Resource();
   resource.setDirectory(new File(projectRootPath + "/src/main/resources").getAbsolutePath());
   project.getResources().add(resource);
   return project;
 }
  public MojoProjectStub(File projectDir) {
    this.basedir = projectDir;
    props.setProperty("basedir", this.basedir.getAbsolutePath());

    File pom = new File(getBasedir(), "plugin-config.xml");
    MavenXpp3Reader pomReader = new MavenXpp3Reader();
    Model model = null;
    FileReader fileReader = null;

    try {
      fileReader = new FileReader(pom);
      model = pomReader.read(fileReader);
      setModel(model);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      IOUtils.closeQuietly(fileReader);
    }

    setGroupId(model.getGroupId());
    setArtifactId(model.getArtifactId());
    setVersion(model.getVersion());
    setName(model.getName());
    setUrl(model.getUrl());
    setPackaging(model.getPackaging());
    setFile(pom);

    build = model.getBuild();
    if (build == null) {
      build = new Build();
    }

    File srcDir = getStandardDir(getBuild().getSourceDirectory(), "src/main/java");
    getBuild().setSourceDirectory(srcDir.getAbsolutePath());

    File targetDir = getStandardDir(getBuild().getDirectory(), "target");
    getBuild().setDirectory(targetDir.getAbsolutePath());

    File outputDir = getStandardDir(getBuild().getOutputDirectory(), "target/classes");
    getBuild().setOutputDirectory(outputDir.getAbsolutePath());

    List<Resource> resources = new ArrayList<Resource>();
    resources.addAll(getBuild().getResources());

    if (resources.isEmpty()) {
      resources = new ArrayList<Resource>();
      Resource resource = new Resource();
      File resourceDir = normalize("src/main/resources");
      resource.setDirectory(resourceDir.getAbsolutePath());
      makeDirs(resourceDir);
      resources.add(resource);
    } else {
      // Make this project work on windows ;-)
      for (Resource resource : resources) {
        File dir = normalize(resource.getDirectory());
        resource.setDirectory(dir.getAbsolutePath());
      }
    }

    getBuild().setResources(resources);
  }
Ejemplo n.º 9
0
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    try {
      URL url = new URL(war);
      String targetFile = url.getFile().substring(url.getFile().lastIndexOf('/') + 1);
      File tempWarFile = new File(tempWar.getAbsolutePath() + File.separator + targetFile);
      if (!tempWarFile.exists()) {
        getLog().info("Dowloading = " + war + " -> " + tempWarFile.getAbsolutePath());
        UrlHelper.getFile(war, tempWarFile);
      }
      File previous = new File(tempWar.getAbsolutePath() + File.separator + "extracted");
      if (previous.exists()) {
        previous.delete();
      }
      previous = new File(tempWar.getAbsolutePath() + File.separator + "extracted");

      Resource res = new Resource();
      res.setDirectory(filteredWar.getAbsolutePath());

      project.getResources().add(res);
      String[] names = new String[0];
      if (filtered != null) {
        names = filtered.split(",");
        for (String name : Arrays.asList(names)) {
          System.out.println("Filter=" + name);
        }
      }

      ZipHelper.unzipToTempDir(tempWarFile, previous, Arrays.asList(names));
      if (!filteredWar.exists()) {
        filteredWar.mkdirs();
      }

      ZipHelper.zipFolder(
          previous.getAbsolutePath(), filteredWar.getAbsolutePath() + File.separator + targetFile);

      /*
                  ZipHelper.unzipToTempDir(tempWarFile, outputClasses)
                  BundlerHelper.copyWebInf(outputClasses);

                  String sjars = singletonJars;
                  if(sjars == null){
                      sjars = "";
                  }
                  String[] lsjars = sjars.split(",");

                  BundlerHelper.generateManifest(project, outputClasses,lsjars);

                  Resource resource = new Resource();
                  resource.setDirectory(outputClasses.getPath());
                  project.getResources().add(resource);

                  Resource resource2 = new Resource();
                  resource2.setDirectory(sourceOutputDirectory.getPath()+File.separator+"KEV-INF");
                  resource2.setTargetPath("KEV-INF");
                  project.getResources().add(resource2);

      */
      // GENERATE KEVOREE COMPONENT WRAPPER
      /*
                  Dependency dep = new Dependency();
                  dep.setArtifactId("org.kevoree.library.javase.webserver.servlet");
                  dep.setGroupId("org.kevoree.library.javase");
                  dep.setVersion(KevoreeFactory.getVersion());
                  dep.setType("bundle");
                  dep.setScope("compile");
                  project.getCompileDependencies().add(dep);

                  Dependency dep2 = new Dependency();
                  dep2.setArtifactId("org.kevoree.library.javase.webserver");
                  dep2.setGroupId("org.kevoree.library.javase");
                  dep2.setVersion(KevoreeFactory.getVersion());
                  dep2.setType("bundle");
                  dep2.setScope("compile");
                  project.getCompileDependencies().add(dep2);
      */
      /*
      Dependency dep3 = new Dependency();
      dep3.setArtifactId("org.kevoree.extra.jetty");
      dep3.setGroupId("org.kevoree.extra");
      dep3.setVersion("8.1.0.RC2");
      dep3.setType("bundle");
      dep3.setScope("compile");
      project.getCompileDependencies().add(dep3);*/

      // WrapperGenerator.generate(sourceOutputDirectory,project,BundlerHelper.getWebInfParams(outputClasses),lsjars);

      // project.getBuild().setSourceDirectory(sourceOutputDirectory.getAbsolutePath());

    } catch (Exception e) {
      e.printStackTrace();
      getLog().error(e);
    }
  }
 protected Resource createResource(String resourceDirectory) {
   Resource resource = new Resource();
   resource.setDirectory(resourceDirectory);
   return resource;
 }