
org.nuiton.license.plugin.AbstractLicenseMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-license-plugin Show documentation
Show all versions of maven-license-plugin Show documentation
Plugin pour switcher de license dans un module maven 2
The newest version!
/*
* #%L
* Maven License Plugin
*
* $Id: AbstractLicenseMojo.java 1857 2010-10-17 01:09:17Z tchemit $
* $HeadURL: http://svn.nuiton.org/svn/maven-license-plugin/tags/maven-license-plugin-3.0/src/main/java/org/nuiton/license/plugin/AbstractLicenseMojo.java $
* %%
* Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
package org.nuiton.license.plugin;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.nuiton.license.plugin.model.LicenseStore;
import org.nuiton.plugin.AbstractPlugin;
import java.io.IOException;
/**
* Abstract license mojo.
*
* @author tchemit
* @since 2.1
*/
public abstract class AbstractLicenseMojo extends AbstractPlugin {
/**
* Current maven session. (used to launch certain mojo once by build).
*
* @parameter expression="${session}"
* @required
* @readonly
* @since 2.3
*/
private MavenSession session;
/**
* The reacted project.
*
* @parameter default-value="${project}"
* @required
* @since 2.1
*/
private MavenProject project;
/**
* Flag to activate verbose mode.
*
* Note: Verbose mode is always on if you starts a debug maven instance
* (says via {@code -X}).
*
* @parameter expression="${license.verbose}" default-value="${maven.verbose}"
* @since 2.1
*/
private boolean verbose;
@Override
public final MavenProject getProject() {
return project;
}
@Override
public final void setProject(MavenProject project) {
this.project = project;
}
@Override
public final boolean isVerbose() {
return verbose;
}
@Override
public final void setVerbose(boolean verbose) {
this.verbose = verbose;
}
public final MavenSession getSession() {
return session;
}
public final void setSession(MavenSession session) {
this.session = session;
}
public final long getBuildTimestamp() {
return session.getStartTime().getTime();
}
protected LicenseStore createLicenseStore(String... extraResolver)
throws MojoExecutionException {
LicenseStore store;
try {
store = new LicenseStore();
store.addJarRepository();
if (extraResolver != null) {
for (String s : extraResolver) {
if (s != null && !s.trim().isEmpty()) {
getLog().info("adding extra resolver " + s);
store.addRepository(s);
}
}
}
store.init();
} catch (IllegalArgumentException ex) {
throw new MojoExecutionException(
"could not obtain the license repository", ex);
} catch (IOException ex) {
throw new MojoExecutionException(
"could not obtain the license repository", ex);
}
return store;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy