Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2014 Takari, Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
 package io.takari.maven.plugins;

Jason van Zyl
@Mojo(name = "wrapper", requiresProject = true, aggregator = true)
public class WrapperMojo extends AbstractMojo {
  @Parameter(defaultValue = "${session}", readonly = true)
  private MavenSession session;
  @Parameter(defaultValue = "0.1.2", property = "version")
  private String version;
  public void execute() throws MojoExecutionExceptionMojoFailureException {
    // Fetch the latest wrapper archive
    // Unpack it in the current working project
    // Possibly interpolate the latest version of Maven in the wrapper properties
    File localRepository = new File(System.getProperty("user.home"), ".m2/repository");
    String artifactPath = String.format("io/takari/maven-wrapper/%s/maven-wrapper-%s.tar.gz");
    String wrapperUrl = String.format(""artifactPath);    
    File destination = new File(localRepositoryartifactPath);
    Downloader downloader = new DefaultDownloader("mvnw");
    try { URI(wrapperUrl), destination);     
      UnArchiver unarchiver = UnArchiver.builder().useRoot(false).build();
      unarchiver.unarchive(destinationnew File(.getExecutionRootDirectory()));
    } catch (Exception e) {
      throw new MojoExecutionException("Error fetching maven-wrapper archive."e);
New to GrepCode? Check out our FAQ X