Examples of IMaven


Examples of org.eclipse.m2e.core.embedder.IMaven

        assertTrue("Archetype was not found at " + artifactPathLocation, artifactPathLocation.exists());
    }

    private File getInstalledArchetypeLocation() throws CoreException {

        IMaven maven = MavenPlugin.getMaven();

        String artifactPath = maven.getArtifactPath(maven.getLocalRepository(), archetypeGroupId, archetypeArtifactId,
                archetypeVersion, "jar", null);

        String localRepositoryPath = maven.getLocalRepositoryPath();

        return new File(localRepositoryPath + File.separatorChar + artifactPath);
    }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

    origins.put(fileExtension, new FileInputStream(origin));
  }
 
    public void installArchetype() throws CoreException {
        try {
            IMaven maven = MavenPlugin.getMaven();
            // first get the plexus container
            PlexusContainer container = ((MavenImpl) MavenPlugin.getMaven()).getPlexusContainer();

            // then get the DefaultMaven
            DefaultMaven mvn = (DefaultMaven) container.lookup(Maven.class);

            // now create a RepositorySystemSession
            MavenExecutionRequest request = new DefaultMavenExecutionRequest();
            request.setLocalRepository(maven.getLocalRepository());

            // We need to support Maven 3.0.x as well, so we use reflection to
            // access Aether APIs in a manner which is compatible with all Maven 3.x versions
            // See https://maven.apache.org/docs/3.1.0/release-notes.html
            MavenSession session = reflectiveCreateMavenSession(container, mvn, request);
            LegacySupport legacy = container.lookup(LegacySupport.class);
            legacy.setSession(session);

            // then lookup the DefaultArtifactInstaller
            DefaultArtifactInstaller dai = (DefaultArtifactInstaller) container.lookup(ArtifactInstaller.class);

            final Set<Entry<String, InputStream>> entries = origins.entrySet();
            for (Iterator<Entry<String, InputStream>> it = entries.iterator(); it.hasNext();) {
                final Entry<String, InputStream> entry = it.next();
                final String fileExtension = entry.getKey();
                final InputStream in = entry.getValue();
                File tmpFile = File.createTempFile("slingClipseTmp", fileExtension);
                FileOutputStream fos = new FileOutputStream(tmpFile);

                try {
                    IOUtils.copy(in, fos);
                    Artifact jarArtifact = new DefaultArtifact(groupId, artifactId, version, "", fileExtension, "",
                            new DefaultArtifactHandler());
                    dai.install(tmpFile, jarArtifact, maven.getLocalRepository());
                } finally {
                    IOUtils.closeQuietly(in);
                    IOUtils.closeQuietly(fos);
                    FileUtils.deleteQuietly(tmpFile);
                }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

  @Override
  public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
    // execute mojo
    Set<IProject> result = super.build(kind, monitor);
    if (true) {
      IMaven maven = MavenPlugin.getMaven();
      BuildContext buildContext = getBuildContext();
      IMavenProjectFacade mproj = getMavenProjectFacade();

      IProject proj = mproj.getProject();

      proj.refreshLocal(IResource.DEPTH_INFINITE, monitor);

      for (String dirName : outputDirs) {
        IFile generatedSource = proj.getFile(dirName);
        File generatedSourceFolder = generatedSource.getFullPath().toFile();
        buildContext.refresh(generatedSourceFolder);
        // tell m2e builder to refresh generated files
        File generated = maven.getMojoParameterValue(getSession(), getMojoExecution(), dirName, File.class);
        if (generated != null) {
          buildContext.refresh(generated);
        }
      }
    }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

  }

  @Override
  public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
    IMaven maven = MavenPlugin.getMaven();
    // execute mojo
    Set<IProject> result = super.build(kind, monitor);

    BuildContext buildContext = getBuildContext();
    IMavenProjectFacade mproj = getMavenProjectFacade();

    IProject proj = mproj.getProject();

    proj.refreshLocal(IResource.DEPTH_INFINITE, monitor);

    IFile generatedSource = proj.getFile(sourceRoot);
    File generatedSourceFolder = generatedSource.getFullPath().toFile();
    buildContext.refresh(generatedSourceFolder);
    // tell m2e builder to refresh generated files
    File generated = maven.getMojoParameterValue(getSession(), getMojoExecution(), sourceRoot, File.class);
    if (generated != null) {
      buildContext.refresh(generated);
    }

    return result;
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

  }

  @Override
  public Set<IProject> build(int kind, IProgressMonitor monitor) throws Exception {
    IMaven maven = MavenPlugin.getMaven();
    // execute mojo
    Set<IProject> result = super.build(kind, monitor);

    BuildContext buildContext = getBuildContext();
    IMavenProjectFacade mproj = getMavenProjectFacade();

    IProject proj = mproj.getProject();

    proj.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    IFile generatedSource = proj.getFile(sourceRoot);
    File generatedSourceFolder = generatedSource.getFullPath().toFile();
    buildContext.refresh(generatedSourceFolder);
    // tell m2e builder to refresh generated files
    File generated = maven.getMojoParameterValue(getSession(), getMojoExecution(), sourceRoot, File.class);
    if (generated != null) {
      buildContext.refresh(generated);
    }

    return result;
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

        return false;
    }

    public ClassRealm getPluginClassRealm(MavenSession session,
            MojoExecution mojoExecution) throws CoreException {
        IMaven mvn = MavenPlugin.getMaven();
        // call for side effect of ensuring that the realm is set in the
        // descriptor.
        mvn.getConfiguredMojo(session, mojoExecution, Mojo.class);
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
        return mojoDescriptor.getPluginDescriptor().getClassRealm();
    }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

    }

    private IPath getMetainfPath( IMavenProjectFacade facade, List<MojoExecution> executions, IProgressMonitor monitor )
        throws CoreException
    {
        IMaven maven = MavenPlugin.getMaven();
        for ( MojoExecution execution : executions )
        {
            MavenProject mavenProject = facade.getMavenProject( monitor );
            File location =
                maven.getMojoParameterValue( mavenProject, execution, PARAM_MANIFESTLOCATION, File.class, monitor );
            if ( location != null )
            {
                return facade.getProjectRelativePath( location.getAbsolutePath() );
            }
        }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

   * @param monitor
   * @return
   * @throws CoreException
   */
  public static boolean runBuild(List<String> goals, Properties serverProperties, IModule module, IProgressMonitor monitorthrows CoreException {
    IMaven maven = MavenPlugin.getMaven();
    IMavenExecutionContext executionContext = maven.createExecutionContext();
    MavenExecutionRequest executionRequest = executionContext.getExecutionRequest();
    executionRequest.setPom(getModelFile(module));
    if (serverProperties != null && serverProperties.isEmpty() == false) {
      Server fabric8Server = new Server();
      fabric8Server.setId(serverProperties.getProperty(SERVER_ID));
      fabric8Server.setUsername(serverProperties.getProperty(SERVER_USER));
      fabric8Server.setPassword(serverProperties.getProperty(SERVER_PASSWORD));
      executionRequest.addServer(fabric8Server);
    }
    executionRequest.setGoals(goals);
   
    MavenExecutionResult result = maven.execute(executionRequest, monitor);
    for (Throwable t : result.getExceptions()) {
      Activator.getLogger().error(t);
    }
    return !result.hasExceptions();
  }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

  }


  private File getLocation(MojoExecution mojoExecution, String parameterName)
      throws CoreException {
    IMaven maven = MavenPlugin.getMaven();
    File location = maven.getMojoParameterValue(getSession(), mojoExecution, parameterName, File.class);
    return location;
  }
View Full Code Here

Examples of org.eclipse.m2e.core.embedder.IMaven

  }

  private Collection<File> getContextRoots(IMavenProjectFacade facade, MojoExecution mojoExecution)
      throws CoreException {
 
    IMaven maven = MavenPlugin.getMaven();
    String contextRoots = maven.getMojoParameterValue(getSession(), mojoExecution, CONTEXT_FOLDER, String.class);
  List<File> locations = new ArrayList<File>();
    if (contextRoots != null) {
      String[] crs = contextRoots.split(TOKEN_SEPARATOR);
      IPath root = facade.getProject().getLocation();
      for (String cr : crs) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.