Java 类org.apache.maven.model.Build 实例源码

项目:incubator-netbeans    文件:CosChecker.java   
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);
}
项目:wavemaker-app-build-tools    文件:AppBuildMojo.java   
@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);
    }
}
项目:apache-maven-shade-plugin    文件:MavenJDOMWriter.java   
/**
 * 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" );
    }
}
项目:eclipse-asciidoctools    文件:MavenEnablerJob.java   
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;
    }
项目:unleash-maven-plugin    文件:CheckPluginDependencyVersions.java   
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;
}
项目:unleash-maven-plugin    文件:CheckPluginDependencyVersions.java   
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;
}
项目:app-maven-plugin    文件:RunMojo.java   
/**
 * <p>If &lt;appYamls&gt; is explicitly set by the user, we'll display a warning.</p>
 * <p>If &lt;appYamls&gt; is explicitly set by the user and &lt;services&gt; 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
 * &lt;appYamls&gt; to &lt;services&gt; to be used in the run configuration.</p>
 * <p>If both &lt;appYamls&gt; and &lt;services&gt; are explicitly set in the configuration, we'll
 * throw an error.</p>
 *
 * @throws MojoExecutionException if both &lt;appYamls&gt; and &lt;services&gt; 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.");
    }
  }
}
项目:app-maven-plugin    文件:RunMojoTest.java   
@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();
}
项目:cloudkeeper    文件:AbstractProjectStub.java   
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);
        }
    }
}
项目:FitNesseLauncher    文件:CalcWikiFormatClasspathTest.java   
@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 );
}
项目:FitNesseLauncher    文件:CalcWikiFormatClasspathTest.java   
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;
}
项目:xmvn    文件:XMvnModelValidator.java   
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 ) );
}
项目:diffusion-maven-plugin    文件:DiffusionProjectStub.java   
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());
}
项目:ono-extra-enforcer-rules    文件:AbstractRule.java   
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;
}
项目:extra-enforcer-rules    文件:RequirePropertyDiverges.java   
/**
 * 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;
}
项目:extra-enforcer-rules    文件:RequirePropertyDiverges.java   
/**
 * Returns the rule configurations from the <tt>pluginManagement</tt> as well
 * as the <tt>plugins</tt> section.
 *
 * @param build the build to inspect.
 * @return configuration of the rules, may be an empty list.
 */
final List<Xpp3Dom> getRuleConfigurations( final Build build )
{
    @SuppressWarnings( "unchecked" )
    final Map<String, Plugin> plugins = build.getPluginsAsMap();
    final List<Xpp3Dom> ruleConfigurationsForPlugins = getRuleConfigurations( plugins );
    final PluginManagement pluginManagement = build.getPluginManagement();
    if ( pluginManagement != null )
    {
        @SuppressWarnings( "unchecked" )
        final Map<String, Plugin> pluginsFromManagementAsMap = pluginManagement.getPluginsAsMap();
        List<Xpp3Dom> ruleConfigurationsFromManagement = getRuleConfigurations( pluginsFromManagementAsMap );
        ruleConfigurationsForPlugins.addAll( ruleConfigurationsFromManagement );
    }
    return ruleConfigurationsForPlugins;
}
项目:extra-enforcer-rules    文件:RequirePropertyDivergesTest.java   
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInParentWithConfigurationInPluginManagement() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "company-parent-pom" );
    final Build build = new Build();
    // create pluginManagement
    final Plugin pluginInManagement = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0");
    final Xpp3Dom configuration = createPluginConfiguration();
    pluginInManagement.setConfiguration( configuration );
    final PluginManagement pluginManagement = new PluginManagement();
    pluginManagement.addPlugin( pluginInManagement );
    build.setPluginManagement( pluginManagement );
    // create plugins
    final Plugin pluginInPlugins = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0");
    build.addPlugin( pluginInPlugins );
    // add build
    project.getOriginalModel().setBuild( build );
    //project.getOriginalModel().setBuild( build );
    setUpHelper( project, "parentValue" );
    mockInstance.execute( helper );
}
项目:extra-enforcer-rules    文件:RequirePropertyDivergesTest.java   
/**
 * Test of execute method, of class RequirePropertyDiverges.
 */
@Test
public void testExecuteInParentWithConfigurationInExecution() throws EnforcerRuleException
{
    RequirePropertyDiverges mockInstance = createMockRule();
    final MavenProject project = createMavenProject( "company", "company-parent-pom" );
    final Build build = new Build();
    build.setPluginManagement( new PluginManagement() );
    final Plugin plugin = newPlugin( "org.apache.maven.plugins", "maven-enforcer-plugin", "1.0" );
    final Xpp3Dom configuration = createPluginConfiguration();
    PluginExecution pluginExecution = new PluginExecution();
    pluginExecution.setConfiguration( configuration );
    plugin.addExecution( pluginExecution );
    build.addPlugin( plugin );
    project.getOriginalModel().setBuild( build );
    setUpHelper(project, "parentValue");
    mockInstance.execute( helper );
}
项目:che    文件:MavenModelUtil.java   
public static MavenModel convertModel(Model model, File projectDir) {
  Build build = model.getBuild();
  List<String> sources = new ArrayList<>();
  List<String> testSources = new ArrayList<>();
  if (build != null) {
    String sourceDirectory = build.getSourceDirectory();
    if (sourceDirectory != null) {
      sources.add(sourceDirectory);
    }
    String testSourceDirectory = build.getTestSourceDirectory();
    if (testSourceDirectory != null) {
      testSources.add(testSourceDirectory);
    }
  }

  return convertModel(
      model,
      projectDir,
      sources,
      testSources,
      Collections.emptyList(),
      Collections.emptyList(),
      null);
}
项目:che    文件:MavenModelUtil.java   
private static void convertBuild(
    MavenBuild mavenBuild,
    Build build,
    File projectDir,
    List<String> compileSourceRoots,
    List<String> testCompileSourceRoots) {
  convertBaseBuild(build, mavenBuild, projectDir);
  mavenBuild.setOutputDirectory(relativize(projectDir, build.getOutputDirectory()));
  mavenBuild.setTestOutputDirectory(relativize(projectDir, build.getTestOutputDirectory()));
  mavenBuild.setSources(
      compileSourceRoots.stream().map(path -> relativize(projectDir, path)).collect(toList()));
  mavenBuild.setTestSources(
      testCompileSourceRoots
          .stream()
          .map(path -> relativize(projectDir, path))
          .collect(toList()));
}
项目:versions-maven-plugin    文件:DisplayDependencyUpdatesMojo.java   
private static Set<Dependency> extractPluginDependenciesFromPluginsInPluginManagement( Build build )
{
    Set<Dependency> result = new TreeSet<>( new DependencyComparator() );
    if ( build.getPluginManagement() != null )
    {
        for ( Plugin plugin : build.getPluginManagement().getPlugins() )
        {
            if ( plugin.getDependencies() != null && !plugin.getDependencies().isEmpty() )
            {
                for ( Dependency pluginDependency : plugin.getDependencies() )
                {
                    result.add( pluginDependency );
                }
            }
        }
    }
    return result;
}
项目:wildfly-swarm-addon    文件:DetectFractionsCommand.java   
private DirectoryResource getTargetDirectory(Project project)
{
   MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
   Build build = mavenFacet.getModel().getBuild();
   String targetFolderName;
   if (build != null && build.getOutputDirectory() != null)
   {
      targetFolderName = mavenFacet.resolveProperties(build.getOutputDirectory());
   }
   else
   {
      targetFolderName = "target" + File.separator + "classes";
   }
   DirectoryResource projectRoot = project.getRoot().reify(DirectoryResource.class);
   return projectRoot.getChildDirectory(targetFolderName);
}
项目:FitNesseLauncher    文件:CalcWikiFormatClasspathTest.java   
@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 );
}
项目:FitNesseLauncher    文件:CalcWikiFormatClasspathTest.java   
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;
}
项目:appformer    文件:BuildContentHandlerTest.java   
@Test
public void testBuildPluginDeletePlugin() throws Exception {
    org.guvnor.common.services.project.model.Build from = new org.guvnor.common.services.project.model.Build();
    from.getPlugins().add(makeGuvnorPlugin("myGroup",
                                           "myArtifact",
                                           "1.0"));

    Build to = new Build();
    to.getPlugins().add(makeMavenPlugin("myGroup",
                                        "myArtifact",
                                        "1.0"));
    to.getPlugins().add(makeMavenPlugin("junit",
                                        "junit",
                                        "1.44"));

    to = new BuildContentHandler().update(from,
                                          to);

    assertEquals(1,
                 to.getPlugins().size());
    assertEquals("1.0",
                 to.getPlugins().get(0).getVersion());
}
项目:coroutines    文件:MainInstrumentMojoTest.java   
@Test
public void mustNotThrowExceptionWhenDirectoryDoesntExist() throws Exception {
    File mainDir = null;
    try {
        // create a folder and delete it right away
        mainDir = Files.createTempDirectory(getClass().getSimpleName()).toFile();
        File fakeFolder = new File(mainDir, "DOESNOTEXIST");

        // mock
        Mockito.when(mavenProject.getCompileClasspathElements()).thenReturn(Collections.emptyList());
        Build build = Mockito.mock(Build.class);
        Mockito.when(mavenProject.getBuild()).thenReturn(build);
        Mockito.when(build.getOutputDirectory()).thenReturn(fakeFolder.getAbsolutePath());

        // execute plugin
        fixture.execute();
    } finally {
        if (mainDir != null) {
            FileUtils.deleteDirectory(mainDir);
        }
    }
}
项目:coroutines    文件:TestInstrumentMojoTest.java   
@Test
public void mustNotThrowExceptionWhenDirectoryDoesntExist() throws Exception {
    File testDir = null;
    try {
        // create a folder and delete it right away
        testDir = Files.createTempDirectory(getClass().getSimpleName()).toFile();
        File fakeFolder = new File(testDir, "DOESNOTEXIST");

        // mock
        Mockito.when(mavenProject.getTestClasspathElements()).thenReturn(Collections.emptyList());
        Build build = Mockito.mock(Build.class);
        Mockito.when(mavenProject.getBuild()).thenReturn(build);
        Mockito.when(build.getTestOutputDirectory()).thenReturn(fakeFolder.getAbsolutePath());

        // execute plugin
        fixture.execute();
    } finally {
        if (testDir != null) {
            FileUtils.deleteDirectory(testDir);
        }
    }
}
项目:yangtools    文件:YangToSourcesProcessorTest.java   
@Test
public void test() throws Exception {
    final File file = new File(getClass().getResource("/yang").getFile());
    final File excludedYang = new File(getClass().getResource("/yang/excluded-file.yang").getFile());
    final String path = file.getPath();
    final CodeGeneratorArg codeGeneratorArg = new CodeGeneratorArg(GeneratorMock.class.getName(),
            "target/YangToSourcesProcessorTest-outputBaseDir");
    final List<CodeGeneratorArg> codeGenerators = ImmutableList.of(codeGeneratorArg);
    final MavenProject mvnProject = Mockito.mock(MavenProject.class);
    final Build build = new Build();
    Mockito.when(mvnProject.getBuild()).thenReturn(build);
    final boolean dependencies = true;
    final YangToSourcesProcessor proc = new YangToSourcesProcessor(file, ImmutableList.of(excludedYang),
        codeGenerators, mvnProject, dependencies, YangProvider.getInstance());
    Assert.assertNotNull(proc);
    proc.execute();
}
项目:pitest    文件:BasePitMojoTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  MockitoAnnotations.initMocks(this);
  this.classPath = new ArrayList<>(FCollection.map(
      ClassPath.getClassPathElementsAsFiles(), fileToString()));
  when(this.project.getTestClasspathElements()).thenReturn(this.classPath);
  when(this.project.getPackaging()).thenReturn("jar");

  final Build build = new Build();
  build.setOutputDirectory("");

  when(this.project.getBuild()).thenReturn(build);

  when(this.plugins.findToolClasspathPlugins()).thenReturn(
      Collections.emptyList());
  when(this.plugins.findClientClasspathPlugins()).thenReturn(
      Collections.emptyList());
}
项目:sonar-pull-request-integration    文件:ComponentConverterTest.java   
@Test
public void toComponentKeyTreeProject() throws Exception {

    List<MavenProject> projects = Lists.newArrayList();
    MavenProject root = new MavenProject();
    root.setGroupId( "com.mysema.querydsl" );
    root.setArtifactId( "querydsl-root" );
    root.setFile( new File( "src/test/resources/tree-project/pom.xml" ).getCanonicalFile() );
    projects.add( root );
    MavenProject hazelcast = new MavenProject();
    hazelcast.setGroupId( "com.mysema.querydsl" );
    hazelcast.setArtifactId( "querydsl-hazelcast" );
    hazelcast.setFile( new File( "src/test/resources/tree-project/querydsl-hazelcast/pom.xml" ).getCanonicalFile() );
    hazelcast.setBuild( new Build() );
    hazelcast.getBuild().setSourceDirectory(
            new File( "src/test/resources/tree-project/querydsl-hazelcast/src/main/java" ).getCanonicalPath() );
    projects.add( hazelcast );

    runTest( projects );
}
项目:pom-manipulation-ext    文件:DistributionEnforcingManipulatorTest.java   
@Test
public void projectUnchangedWhenModeIsNone()
    throws Exception
{
    final Plugin plugin = new Plugin();
    plugin.setGroupId( MAVEN_PLUGIN_GROUPID );
    plugin.setArtifactId( MAVEN_DEPLOY_ARTIFACTID );
    plugin.setConfiguration( simpleSkipConfig( true ) );

    final Build build = new Build();
    build.addPlugin( plugin );

    final Model model = new Model();
    model.setModelVersion( "4.0.0" );
    model.setGroupId( "org.foo" );
    model.setArtifactId( "bar" );
    model.setVersion( "1" );

    model.setBuild( build );

    applyTest( none, model, null );
}
项目:pom-manipulation-ext    文件:DistributionEnforcingManipulatorTest.java   
@Test
public void projectDeploySkipTurnedOffWhenModeIsOff()
    throws Exception
{
    final Plugin plugin = new Plugin();
    plugin.setGroupId( MAVEN_PLUGIN_GROUPID );
    plugin.setArtifactId( MAVEN_DEPLOY_ARTIFACTID );
    plugin.setConfiguration( simpleSkipConfig( true ) );

    final Build build = new Build();
    build.addPlugin( plugin );

    final Model model = new Model();
    model.setModelVersion( "4.0.0" );
    model.setGroupId( "org.foo" );
    model.setArtifactId( "bar" );
    model.setVersion( "1" );

    model.setBuild( build );

    applyTest( off, model, model );
    assertSkip( model, null, true, Boolean.FALSE );
}
项目:oceano    文件:DefaultPluginPrefixResolver.java   
private PluginPrefixResult resolveFromProject( PluginPrefixRequest request )
{
    PluginPrefixResult result = null;

    if ( request.getPom() != null && request.getPom().getBuild() != null )
    {
        Build build = request.getPom().getBuild();

        result = resolveFromProject( request, build.getPlugins() );

        if ( result == null && build.getPluginManagement() != null )
        {
            result = resolveFromProject( request, build.getPluginManagement().getPlugins() );
        }
    }

    return result;
}
项目:oceano    文件:DefaultPluginVersionResolver.java   
private PluginVersionResult resolveFromProject( PluginVersionRequest request )
{
    PluginVersionResult result = null;

    if ( request.getPom() != null && request.getPom().getBuild() != null )
    {
        Build build = request.getPom().getBuild();

        result = resolveFromProject( request, build.getPlugins() );

        if ( result == null && build.getPluginManagement() != null )
        {
            result = resolveFromProject( request, build.getPluginManagement().getPlugins() );
        }
    }

    return result;
}
项目:oceano    文件:DefaultLifecycleBindingsInjector.java   
public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    String packaging = model.getPackaging();

    Collection<Plugin> defaultPlugins = lifecycle.getPluginsBoundByDefaultToAllLifecycles( packaging );

    if ( defaultPlugins == null )
    {
        problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE)
                .setMessage( "Unknown packaging: " + packaging )
                .setLocation( model.getLocation( "packaging" )));
    }
    else if ( !defaultPlugins.isEmpty() )
    {
        Model lifecycleModel = new Model();
        lifecycleModel.setBuild( new Build() );
        lifecycleModel.getBuild().getPlugins().addAll( defaultPlugins );

        merger.merge( model, lifecycleModel );
    }
}
项目:oceano    文件:PluginParameterExpressionEvaluatorTest.java   
public void testValueExtractionWithAPomValueContainingAPath()
    throws Exception
{
    String expected = getTestFile( "target/test-classes/target/classes" ).getCanonicalPath();

    Build build = new Build();
    build.setDirectory( expected.substring( 0, expected.length() - "/classes".length() ) );

    Model model = new Model();
    model.setBuild( build );

    MavenProject project = new MavenProject( model );
    project.setFile( new File( "pom.xml" ).getCanonicalFile() );

    ExpressionEvaluator expressionEvaluator = createExpressionEvaluator( project, null, new Properties() );

    Object value = expressionEvaluator.evaluate( "${project.build.directory}/classes" );
    String actual = new File( value.toString() ).getCanonicalPath();

    assertEquals( expected, actual );
}
项目:oceano    文件:PluginParameterExpressionEvaluatorTest.java   
public void testTwoExpressions()
    throws Exception
{
    Build build = new Build();
    build.setDirectory( "expected-directory" );
    build.setFinalName( "expected-finalName" );

    Model model = new Model();
    model.setBuild( build );

    ExpressionEvaluator expressionEvaluator =
        createExpressionEvaluator( new MavenProject( model ), null, new Properties() );

    Object value = expressionEvaluator.evaluate( "${project.build.directory}" + FS + "${project.build.finalName}" );

    assertEquals( "expected-directory" + File.separatorChar + "expected-finalName", value );
}
项目:oceano    文件:DefaultPluginConfigurationExpander.java   
public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
    Build build = model.getBuild();

    if ( build != null )
    {
        expand( build.getPlugins() );

        PluginManagement pluginManagement = build.getPluginManagement();

        if ( pluginManagement != null )
        {
            expand( pluginManagement.getPlugins() );
        }
    }
}
项目:oceano    文件:DefaultProfileInjector.java   
public void injectProfile( Model model, Profile profile, ModelBuildingRequest request,
                           ModelProblemCollector problems )
{
    if ( profile != null )
    {
        merger.mergeModelBase( model, profile );

        if ( profile.getBuild() != null )
        {
            if ( model.getBuild() == null )
            {
                model.setBuild( new Build() );
            }
            merger.mergeBuildBase( model.getBuild(), profile.getBuild() );
        }
    }
}
项目:deadcode4j    文件:A_ModuleGenerator.java   
private MavenProject givenMavenProject(String projectId) {
    MavenProject mavenProject = new MavenProject();
    mavenProject.setGroupId("de.is24.junit");
    mavenProject.setArtifactId(projectId);
    mavenProject.setVersion("42");
    mavenProject.getProperties().setProperty("project.build.sourceEncoding", "UTF-8");
    ArtifactStub projectArtifact = new ArtifactStub();
    projectArtifact.setGroupId("de.is24.junit");
    projectArtifact.setArtifactId(projectId);
    projectArtifact.setVersion("42");
    mavenProject.setArtifact(projectArtifact);
    Build build = new Build();
    build.setOutputDirectory(tempFileRule.getTempFile().getParent());
    mavenProject.setBuild(build);
    return mavenProject;
}