本文整理了Java中org.apache.maven.model.Build
类的一些代码示例,展示了Build
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Build
类的具体详情如下:
包路径:org.apache.maven.model.Build
类名称:Build
[英]The <build>
element contains informations required to build the project. Default values are defined in Super POM.
[中]<build>
元素包含构建项目所需的信息。默认值在超级POM中定义。
代码示例来源:origin: vipshop/Saturn
@SuppressWarnings({ "unchecked" })
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!CommonUtils.initSaturnHome())
throw new MojoExecutionException("The ${user.home}/.saturn/caches is not exists");
Log log = getLog();
MavenProject project = (MavenProject) getPluginContext().get("project");
String version = getSaturnVersion(project);
log.info("Packing the saturn job into a zip file: version:" + version);
List<File> runtimeLibFiles = new ArrayList<File>();
List<Artifact> runtimeArtifacts = project.getRuntimeArtifacts();
for (Artifact artifact : runtimeArtifacts) {
runtimeLibFiles.add(artifact.getFile());
}
runtimeLibFiles.add(new File(project.getBuild().getDirectory(),
project.getBuild().getFinalName() + "." + project.getPackaging()));
File zipFile = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + "-" + "app.zip");
try {
CommonUtils.zip(runtimeLibFiles, null, zipFile);
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("zip " + zipFile + " failed", e);
}
projectHelper.attachArtifact(project, "zip", "executor", zipFile);
}
代码示例来源:origin: org.apache.maven/maven-project
Build build = model.getBuild();
build.setDirectory( unalignFromBaseDirectory( build.getDirectory(), basedir ) );
build.setSourceDirectory( unalignFromBaseDirectory( build.getSourceDirectory(), basedir ) );
build.setTestSourceDirectory( unalignFromBaseDirectory( build.getTestSourceDirectory(), basedir ) );
build.setScriptSourceDirectory( unalignFromBaseDirectory( build.getScriptSourceDirectory(), basedir ) );
for ( Iterator i = build.getResources().iterator(); i.hasNext(); )
for ( Iterator i = build.getTestResources().iterator(); i.hasNext(); )
if ( build.getFilters() != null )
for ( Iterator i = build.getFilters().iterator(); i.hasNext(); )
build.setFilters( filters );
build.setOutputDirectory( unalignFromBaseDirectory( build.getOutputDirectory(), basedir ) );
build.setTestOutputDirectory( unalignFromBaseDirectory( build.getTestOutputDirectory(), basedir ) );
Reporting reporting = model.getReporting();
代码示例来源:origin: apache/maven
Build build = model.getBuild();
if ( build != null )
for ( Plugin plugin : build.getPlugins() )
if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) )
PluginManagement mgmt = build.getPluginManagement();
if ( mgmt != null )
if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) )
代码示例来源:origin: apache/maven
protected void mergeBuild_TestSourceDirectory( Build target, Build source, boolean sourceDominant,
Map<Object, Object> context )
{
String src = source.getTestSourceDirectory();
if ( src != null )
{
if ( sourceDominant || target.getTestSourceDirectory() == null )
{
target.setTestSourceDirectory( src );
target.setLocation( "testSourceDirectory", source.getLocation( "testSourceDirectory" ) );
}
}
}
代码示例来源:origin: apache/maven
protected void mergeBuild_TestOutputDirectory( Build target, Build source, boolean sourceDominant,
Map<Object, Object> context )
{
String src = source.getTestOutputDirectory();
if ( src != null )
{
if ( sourceDominant || target.getTestOutputDirectory() == null )
{
target.setTestOutputDirectory( src );
target.setLocation( "testOutputDirectory", source.getLocation( "testOutputDirectory" ) );
}
}
}
代码示例来源:origin: apache/maven
protected void mergeBuild_SourceDirectory( Build target, Build source, boolean sourceDominant,
Map<Object, Object> context )
{
String src = source.getSourceDirectory();
if ( src != null )
{
if ( sourceDominant || target.getSourceDirectory() == null )
{
target.setSourceDirectory( src );
target.setLocation( "sourceDirectory", source.getLocation( "sourceDirectory" ) );
}
}
}
代码示例来源:origin: bytedeco/javacpp
@Override public void execute() throws MojoExecutionException {
final Log log = getLog();
try {
if (log.isDebugEnabled()) {
log.debug("classPath: " + classPath);
log.debug("classPaths: " + Arrays.deepToString(classPaths));
log.debug("buildPath: " + buildPath);
log.debug("buildPaths: " + Arrays.deepToString(buildPaths));
project.addCompileSourceRoot(targetDirectory);
v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s);
properties.setProperty("platform.artifacts", project.getBuild().getOutputDirectory());
for (Artifact a : plugin.getArtifacts()) {
String s = a.getFile().getCanonicalPath();
String v = properties.getProperty("platform.artifacts", "");
properties.setProperty("platform.artifacts",
v.length() == 0 || v.endsWith(separator) ? v + s : v + separator + s);
Properties projectProperties = project.getProperties();
for (String key : properties.stringPropertyNames()) {
projectProperties.setProperty("javacpp." + key, properties.getProperty(key));
log.error("Failed to execute JavaCPP Builder: " + e.getMessage());
throw new MojoExecutionException("Failed to execute JavaCPP Builder", e);
代码示例来源:origin: jeremylong/DependencyCheck
outputDir = new File(this.getProject().getBuild().getDirectory());
engine.writeReports(p.getName(), p.getGroupId(), p.getArtifactId(), p.getVersion(), outputDir, getFormat());
} catch (ReportException ex) {
if (exCol == null) {
throw new MojoExecutionException("One or more exceptions occurred during dependency-check analysis", exCol);
} else {
getLog().debug("Error writing the report", ex);
checkForFailure(engine.getDependencies());
if (exCol != null && this.isFailOnError()) {
throw new MojoExecutionException("One or more exceptions occurred during dependency-check analysis", exCol);
if (getLog().isDebugEnabled()) {
getLog().debug("Database connection error", ex);
throw new MojoExecutionException(msg, ex);
getLog().error(msg, ex);
代码示例来源:origin: streamsets/datacollector
ClassLoader projectCL = getProjectClassLoader();
if (usesDataCollectorAPI(projectCL)) {
File file = new File(project.getBuild().getOutputDirectory(), BUNDLES_TO_GEN_FILE);
if (file.exists() && file.isFile()) {
Map<String, File> bundles = new HashMap<>();
bundles.put(bundleName, bundleFile);
File jarFile = new File(project.getBuild().getDirectory(),
project.getArtifactId() + "-" + project.getVersion() + "-bundles.jar");
getLog().info("Building bundles jar: " + jarFile.getAbsolutePath());
createBundlesJar(jarFile, bundles);
} else {
getLog().debug(BUNDLES_TO_GEN_FILE + "' file does not have any class, no bundles jar will be generated");
getLog().debug("Project does not have '" + BUNDLES_TO_GEN_FILE + "' file, no bundles jar will be generated");
throw new MojoExecutionException(ex.toString(), ex);
代码示例来源:origin: jooby-project/jooby
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (mainClass == null) {
throw new MojoExecutionException("main class not configured");
}
try (URLClassLoader loader = new Classpath(mavenProject).toClassLoader()) {
Path srcdir = new File(mavenProject.getBuild().getSourceDirectory()).toPath();
Path bindir = new File(mavenProject.getBuild().getOutputDirectory()).toPath();
getLog().debug("Using classloader " + loader);
getLog().debug(" source: " + srcdir);
getLog().debug(" bin: " + bindir);
Path output = new ApiParser(srcdir)
.with(loader)
.export(bindir, mainClass);
getLog().info("API file: " + output);
} catch (Exception x) {
throw new MojoFailureException("ApiTool resulted in exception: ", x);
}
}
}
代码示例来源:origin: rapidoid/rapidoid
if (!deleted) getLog().warn("Couldn't delete the temporary assembly descriptor file!");
List<String> appJars = IO.find("*-uber-jar.jar").in(project.getBuild().getDirectory()).getNames();
uberJar = appJar.toFile().getAbsolutePath();
} catch (IOException e) {
throw new MojoExecutionException("Couldn't rename the file! " + ABORT, e);
getLog().info("");
getLog().info("The main class is: " + mainClass);
throw new MojoExecutionException("Couldn't add the JAR manifest! " + ABORT, e);
代码示例来源:origin: apache/maven
project.setModel( model );
project.setOriginalModel( result.getRawModel() );
project.setFile( model.getPomFile() );
Build build = project.getBuild();
project.addScriptSourceRoot( build.getScriptSourceDirectory() );
project.addCompileSourceRoot( build.getSourceDirectory() );
project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
for ( ReportPlugin report : project.getReportPlugins() )
Plugin pp = new Plugin();
pp.setGroupId( report.getGroupId() );
pp.setArtifactId( report.getArtifactId() );
pp.setVersion( report.getVersion() );
代码示例来源:origin: sap-production/xcode-maven-plugin
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
try {
XCodeProjectLayoutValidator.verifyXcodeFolder(new File(project.getBuild().getSourceDirectory()),
project.getArtifactId());
getLog().info("Project '" + project + "' successfully validated.");
}
catch (XCodeException e) {
throw new MojoExecutionException("Project " + project.getArtifactId() + " (" + project.getBasedir()
+ ") is not a valid xcode project: " + e.getMessage() + ".", e);
}
}
}
代码示例来源:origin: offbynull/coroutines
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Log log = getLog();
File mainOutputFolder = new File(getProject().getBuild().getOutputDirectory());
if (!mainOutputFolder.isDirectory()) {
log.warn("Main folder doesn't exist -- nothing to instrument");
return;
}
List<String> classpath;
try {
classpath = getProject().getCompileClasspathElements();
} catch (DependencyResolutionRequiredException ex) {
throw new MojoExecutionException("Dependency resolution problem", ex);
}
log.debug("Processing main output folder ... ");
instrumentPath(log, classpath, mainOutputFolder);
}
}
代码示例来源:origin: org.apache.maven/maven-project
superProjectProfileManager.addProfiles( superModel.getProfiles() );
MavenProject superProject = new MavenProject( superModel );
superProject.setActiveProfiles( activeProfiles );
String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
Model previous = superProject.getModel();
Build build = project.getBuild();
project.addCompileSourceRoot( build.getSourceDirectory() );
project.addScriptSourceRoot( build.getScriptSourceDirectory() );
project.addTestCompileSourceRoot( build.getTestSourceDirectory() );
代码示例来源:origin: vipshop/Saturn
throw new MojoExecutionException("The ${user.home}/.saturn/caches is not exists");
log.info("Running saturn job");
project.getBuild().getDirectory() + System.getProperty("file.separator") + "saturn-run");
if (!saturnAppLibDir.exists()) {
saturnAppLibDir.mkdirs();
List<String> runtimeArtifacts = project.getRuntimeClasspathElements();
for (String path : runtimeArtifacts) {
File tmp = new File(path);
throw new MojoExecutionException("getRuntimeClasspathElements error", e);
} catch (Exception e) {
e.printStackTrace();
throw new MojoExecutionException("unzip saturn-executor.zip failed", e);
代码示例来源:origin: geotools/geotools
generator.setResourceLocation(((Resource)project.getBuild().getResources().get( 0 )).getDirectory());
generator.setFollowComplexTypes(followComplexTypes);
generator.setIncludes( includes );
for ( Iterator d = project.getDependencies().iterator(); d.hasNext(); ) {
Dependency dep = (Dependency) d.next();
try {
artifactResolver.resolve( artifact, remoteRepositories, localRepository );
urls.add( artifact.getFile().toURI().toURL() );
getLog().error( "Unable to resolve " + artifact.getId() );
urls.add( new File(project.getBuild().getOutputDirectory()).toURI().toURL() );
getLog().error("Bad url: " + project.getBuild().getOutputDirectory() );
return;
getLog().error("Could note load class: " + schemaClassName);
return;
代码示例来源:origin: offbynull/coroutines
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Log log = getLog();
File testOutputFolder = new File(getProject().getBuild().getTestOutputDirectory());
if (!testOutputFolder.isDirectory()) {
log.warn("Test folder doesn't exist -- nothing to instrument");
return;
}
List<String> classpath;
try {
classpath = getProject().getTestClasspathElements();
} catch (DependencyResolutionRequiredException ex) {
throw new MojoExecutionException("Dependency resolution problem", ex);
}
log.debug("Processing test output folder ... ");
instrumentPath(log, classpath, testOutputFolder);
}
}
代码示例来源:origin: simpligility/android-maven-plugin
getLog().debug( "Adding dex input (obfuscatedJar) : " + obfuscatedJar );
inputs.add( obfuscatedJar );
getLog().debug( "Using non-obfuscated input" );
getLog().debug( "Adding dex input : " + project.getBuild().getOutputDirectory() );
for ( Artifact artifact : filterArtifacts( getTransitiveDependencyArtifacts(), skipDependencies,
artifactTypeSet.getIncludes(), artifactTypeSet.getExcludes(), artifactSet.getIncludes(),
artifactSet.getExcludes() ) )
if ( artifact.getType().equals( Const.ArtifactType.NATIVE_SYMBOL_OBJECT )
|| artifact.getType().equals( Const.ArtifactType.NATIVE_IMPLEMENTATION_ARCHIVE ) )
else if ( artifact.getType().equals( APKLIB ) )
代码示例来源:origin: org.apache.maven/maven-project
public List getSystemClasspathElements()
throws DependencyResolutionRequiredException
{
List list = new ArrayList( getArtifacts().size() );
list.add( getBuild().getOutputDirectory() );
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
if ( a.getArtifactHandler().isAddedToClasspath() )
{
// TODO: let the scope handler deal with this
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
{
addArtifactPath( a, list );
}
}
}
return list;
}
内容来源于网络,如有侵权,请联系作者删除!