本文整理汇总了Java中org.apache.maven.model.Build类的典型用法代码示例。如果您正苦于以下问题:Java Build类的具体用法?Java Build怎么用?Java Build使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Build类属于org.apache.maven.model包,在下文中一共展示了Build类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCoSFile
import org.apache.maven.model.Build; //导入依赖的package包/类
private static File getCoSFile(MavenProject mp, boolean test) {
if (mp == null) {
return null;
}
Build build = mp.getBuild();
if (build == null) {
return null;
}
String path = test ? build.getTestOutputDirectory() : build.getOutputDirectory();
if (path == null) {
return null;
}
File fl = new File(path);
fl = FileUtil.normalizeFile(fl);
return new File(fl, NB_COS);
}
示例2: execute
import org.apache.maven.model.Build; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
initializeHandlers();
for (AppBuildHandler appBuildHandler : appBuildHandlers) {
appBuildHandler.handle();
}
final Build build = project.getBuild();
final List<String> nonFilteredFileExtensions = getNonFilteredFileExtensions(build.getPlugins());
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution(build.getResources(), new File(outputDirectory), project,
ENCODING, build.getFilters(), nonFilteredFileExtensions, session);
try {
mavenResourcesFiltering.filterResources(mavenResourcesExecution);
} catch (MavenFilteringException e) {
throw new WMRuntimeException("Failed to execute resource filtering ", e);
}
}
示例3: updateBuild
import org.apache.maven.model.Build; //导入依赖的package包/类
/**
* Method updateBuild
*
* @param value
* @param element
* @param counter
* @param xmlTag
*/
//CHECKSTYLE_OFF: LineLength
protected void updateBuild( Build value, String xmlTag, Counter counter, Element element )
{
boolean shouldExist = value != null;
Element root = updateElement( counter, element, xmlTag, shouldExist );
if ( shouldExist )
{
Counter innerCount = new Counter( counter.getDepth() + 1 );
findAndReplaceSimpleElement( innerCount, root, "sourceDirectory", value.getSourceDirectory(), null );
findAndReplaceSimpleElement( innerCount, root, "scriptSourceDirectory", value.getScriptSourceDirectory(),
null );
findAndReplaceSimpleElement( innerCount, root, "testSourceDirectory", value.getTestSourceDirectory(), null );
findAndReplaceSimpleElement( innerCount, root, "outputDirectory", value.getOutputDirectory(), null );
findAndReplaceSimpleElement( innerCount, root, "testOutputDirectory", value.getTestOutputDirectory(), null );
iterateExtension( innerCount, root, value.getExtensions(), "extensions", "extension" );
findAndReplaceSimpleElement( innerCount, root, "defaultGoal", value.getDefaultGoal(), null );
iterateResource( innerCount, root, value.getResources(), "resources", "resource" );
iterateResource( innerCount, root, value.getTestResources(), "testResources", "testResource" );
findAndReplaceSimpleElement( innerCount, root, "directory", value.getDirectory(), null );
findAndReplaceSimpleElement( innerCount, root, "finalName", value.getFinalName(), null );
findAndReplaceSimpleLists( innerCount, root, value.getFilters(), "filters", "filter" );
updatePluginManagement( value.getPluginManagement(), "pluginManagement", innerCount, root );
iteratePlugin( innerCount, root, value.getPlugins(), "plugins", "plugin" );
}
}
示例4: getOrCreateResourcesPlugin
import org.apache.maven.model.Build; //导入依赖的package包/类
private static Plugin getOrCreateResourcesPlugin(Model mavenModel) {
Build build = getOrCreateBuild(mavenModel);
// Locate the plugin and returns if exists
for (Iterator<Plugin> iterator = build.getPlugins().iterator(); iterator.hasNext();) {
Plugin next = iterator.next();
if ("maven-resources-plugin".equals(next.getArtifactId())) {
return next;
}
}
// Creates if couldn't be found.
Plugin resourcesPlugin = new Plugin();
resourcesPlugin.setGroupId("org.apache.maven.plugins");
resourcesPlugin.setArtifactId("maven-resources-plugin");
resourcesPlugin.setVersion("${maven.resources.plugin.version}");
build.getPlugins().add(resourcesPlugin);
return resourcesPlugin;
}
示例5: getSnapshotsFromManagement
import org.apache.maven.model.Build; //导入依赖的package包/类
private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshotsFromManagement(MavenProject project,
PomPropertyResolver propertyResolver) {
this.log.debug("\t\tChecking managed plugins");
Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
Build build = project.getBuild();
if (build != null) {
PluginManagement pluginManagement = build.getPluginManagement();
if (pluginManagement != null) {
for (Plugin plugin : pluginManagement.getPlugins()) {
Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(),
new IsSnapshotDependency(propertyResolver));
if (!snapshots.isEmpty()) {
result.putAll(PluginToCoordinates.INSTANCE.apply(plugin),
Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
}
}
}
}
return result;
}
示例6: getSnapshots
import org.apache.maven.model.Build; //导入依赖的package包/类
private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshots(MavenProject project,
PomPropertyResolver propertyResolver) {
this.log.debug("\t\tChecking direct plugin references");
Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
Build build = project.getBuild();
if (build != null) {
for (Plugin plugin : build.getPlugins()) {
Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(),
new IsSnapshotDependency(propertyResolver));
if (!snapshots.isEmpty()) {
result.putAll(PluginToCoordinates.INSTANCE.apply(plugin),
Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
}
}
}
return result;
}
示例7: handleAppYamlsDeprecation
import org.apache.maven.model.Build; //导入依赖的package包/类
/**
* <p>If <appYamls> is explicitly set by the user, we'll display a warning.</p>
* <p>If <appYamls> is explicitly set by the user and <services> is not (i.e. not
* present in the configuration; <i>note: the </i>{@code services}<i> field will contain the
* default value, so we cannot simply check if it's empty</i>), then we'll assign the value of
* <appYamls> to <services> to be used in the run configuration.</p>
* <p>If both <appYamls> and <services> are explicitly set in the configuration, we'll
* throw an error.</p>
*
* @throws MojoExecutionException if both <appYamls> and <services> are explicitly set
* in the configuration
*/
protected void handleAppYamlsDeprecation() throws MojoExecutionException {
if (CollectionUtil.isNullOrEmpty(appYamls)) {
if (CollectionUtil.isNullOrEmpty(services)) {
Build build = mavenProject.getBuild();
services =
Collections.singletonList(new File(build.getDirectory()).toPath()
.resolve(build.getFinalName()).toFile());
}
} else {
// no default value, so it was set by the user explicitly
getLog().warn("<appYamls> is deprecated, use <services> instead.");
if (CollectionUtil.isNullOrEmpty(services)) {
services = appYamls;
} else {
throw new MojoExecutionException("Both <appYamls> and <services> are defined."
+ " <appYamls> is deprecated, use <services> only.");
}
}
}
示例8: testRunFlexible
import org.apache.maven.model.Build; //导入依赖的package包/类
@Test
@Parameters({"1,V1", "2-alpha,V2ALPHA" })
public void testRunFlexible(String version, SupportedDevServerVersion mockVersion)
throws MojoFailureException, MojoExecutionException, IOException {
// wire up
runMojo.devserverVersion = version;
when(factoryMock.devServerRunSync(mockVersion)).thenReturn(devServerMock);
when(mavenProjectMock.getBuild()).thenReturn(mock(Build.class));
when(mavenProjectMock.getBuild().getDirectory()).thenReturn("/fake/project/build/directory");
when(mavenProjectMock.getBuild().getFinalName()).thenReturn("artifact");
// invoke
expectedException.expect(MojoExecutionException.class);
expectedException.expectMessage(
"Dev App Server does not support App Engine Flexible Environment applications.");
runMojo.execute();
}
示例9: AbstractProjectStub
import org.apache.maven.model.Build; //导入依赖的package包/类
AbstractProjectStub(String pomResourceName) throws IOException, XmlPullParserException {
super(new MavenXpp3Reader().read(ITCompileBundleMojo.class.getResourceAsStream(pomResourceName)));
Model model = getModel();
setGroupId(model.getGroupId());
setArtifactId(model.getArtifactId());
setVersion(model.getVersion());
setName(model.getName());
setUrl(model.getUrl());
setPackaging(model.getPackaging());
SimpleArtifactStub artifact = new SimpleArtifactStub(
model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging());
artifact.setArtifactHandler(new SimpleArtifactHandlerStub(model.getPackaging()));
setArtifact(artifact);
Build build = new Build();
build.setFinalName(model.getArtifactId() + '-' + model.getVersion());
setBuild(build);
for (Dependency dependency: model.getDependencies()) {
if (dependency.getScope() == null) {
dependency.setScope(JavaScopes.COMPILE);
}
}
}
示例10: testWhitespaceHandling2
import org.apache.maven.model.Build; //导入依赖的package包/类
@Test
public void testWhitespaceHandling2() throws IOException {
File whitespace = new File( new File( "." ).getCanonicalFile(), WHITESPACE_DIR );
// Save the real user.dir
String dir = System.getProperty( "user.dir" );
whitespace.mkdir();
System.setProperty( "user.dir", whitespace.getCanonicalPath() );
Build build = assertWhitespaceHandling( whitespace );
String warning1 = "[WARNING] THERE IS WHITESPACE IN CLASSPATH ELEMENT [%s]%n";
String warning2 = "Attempting relative path workaround%n";
assertEquals( format( warning1 + warning2 + warning1 + warning2, build.getTestOutputDirectory(), build.getOutputDirectory() ), helper.logStream.toString() );
// Restore the real user.dir (to prevent side-effects on other tests)
System.setProperty( "user.dir", dir );
}
示例11: assertWhitespaceHandling
import org.apache.maven.model.Build; //导入依赖的package包/类
private Build assertWhitespaceHandling( File whitespace ) throws IOException {
// Save the real os.name
String os = System.getProperty( "os.name" );
System.setProperty( "os.name", "linux" );
Build build = helper.mojo.project.getBuild();
build.setOutputDirectory( mkdir( whitespace, build.getOutputDirectory() ) );
build.setTestOutputDirectory( mkdir( whitespace, build.getTestOutputDirectory() ) );
helper.mojo.project.setFile( new File( whitespace, "pom.xml" ) );
assertEquals( "\n", helper.mojo.calcWikiFormatClasspath() );
helper.classRealmAssertions();
FileUtils.deleteQuietly( whitespace );
// Restore the real os.name (to prevent side-effects on other tests)
System.setProperty( "os.name", os );
return build;
}
示例12: customizeModel
import org.apache.maven.model.Build; //导入依赖的package包/类
void customizeModel( Model model )
{
BuildSettings settings = configurator.getConfiguration().getBuildSettings();
Build build = model.getBuild() != null ? model.getBuild() : new Build();
List<Dependency> dependencies = model.getDependencies();
List<Extension> extensions = build.getExtensions();
List<Plugin> plugins = build.getPlugins();
if ( settings.isSkipTests() )
dependencies.removeIf( d -> StringUtils.equals( d.getScope(), "test" ) );
dependencies.forEach( d -> d.setVersion( replaceVersion( d.getGroupId(), d.getArtifactId(),
d.getVersion() ) ) );
extensions.forEach( e -> e.setVersion( replaceVersion( e.getGroupId(), e.getArtifactId(), e.getVersion() ) ) );
plugins.forEach( p -> p.setVersion( replaceVersion( p.getGroupId(), p.getArtifactId(), p.getVersion() ) ) );
plugins.stream().filter( p -> p.getGroupId().equals( "org.apache.maven.plugins" )
&& p.getArtifactId().equals( "maven-compiler-plugin" ) ).forEach( p -> configureCompiler( p ) );
}
示例13: DiffusionProjectStub
import org.apache.maven.model.Build; //导入依赖的package包/类
public DiffusionProjectStub(final File buildDirectory, final File pom)
throws Exception {
super(new DiffusionModelStub());
setExecutionProject(this);
setFile(pom);
final Build build = new Build();
build.setDirectory(buildDirectory.getAbsolutePath());
setBuild(build);
setDependencyArtifacts((Set)emptySet());
setArtifacts((Set)emptySet());
setPluginArtifacts((Set)emptySet());
setReportArtifacts((Set)emptySet());
setExtensionArtifacts((Set)emptySet());
setRemoteArtifactRepositories((List)emptyList());
setPluginArtifactRepositories((List)emptyList());
setCollectedProjects((List)emptyList());
setActiveProfiles((List)emptyList());
}
示例14: getDefinedActiveBuilds
import org.apache.maven.model.Build; //导入依赖的package包/类
private Set<BuildBase> getDefinedActiveBuilds(MavenProject project) {
HashSet<BuildBase> activeBuilds = new HashSet<>();
final Model originalModel = project.getOriginalModel();
final Build build = originalModel.getBuild();
activeBuilds.add(build);
final List<Profile> originalProfiles = originalModel.getProfiles();
if (originalProfiles != null) {
for (Profile profile : project.getActiveProfiles()) {
// check active profile is defined in project
for (Profile originalProfile : originalProfiles) {
if (originalProfile.equals(profile)) {
activeBuilds.add(originalProfile.getBuild());
}
}
}
}
// remove possible null entries
activeBuilds.remove(null);
return activeBuilds;
}
示例15: findDefiningParent
import org.apache.maven.model.Build; //导入依赖的package包/类
/**
* Finds the ancestor project which defines the rule.
*
* @param project to inspect
* @return the defining ancestor project.
*/
final MavenProject findDefiningParent( final MavenProject project )
{
final Xpp3Dom invokingRule = createInvokingRuleDom();
MavenProject parent = project;
while ( parent != null )
{
final Model model = parent.getOriginalModel();
final Build build = model.getBuild();
if ( build != null )
{
final List<Xpp3Dom> rules = getRuleConfigurations( build );
if ( isDefiningProject( rules, invokingRule ) )
{
break;
}
}
parent = parent.getParent();
}
return parent;
}