Java 类org.apache.maven.project.MavenProject 实例源码

项目:Reer    文件:ProjectDependencyArtifactIdExtractorHack.java   
public String extract() {
    Collection<Upload> tasks = project.getTasks().withType(Upload.class);
    Collection<ArtifactRepository> repositories = getRepositories(tasks);
    if (!onlyContainsMavenResolvers(repositories)) {
        return project.getName();
    }

    Collection<MavenDeployer> deployers = getMavenDeployers(repositories);
    Set<String> artifactIds = getArtifactIds(deployers);
    if (artifactIds.size() == 1) {
        String artifactId = artifactIds.iterator().next();
        if (artifactId != null && !artifactId.equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) {
            return artifactId;
        }
    }
    String baseName = getArchivesBaseName();
    return baseName != null ? baseName : project.getName();
}
项目:incubator-netbeans    文件:DependencyTreeFactory.java   
private static DependencyNode createDependencyTree(MavenProject project,
        DependencyTreeBuilder dependencyTreeBuilder, ArtifactRepository localRepository,
        ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource,
        ArtifactCollector artifactCollector,
        String scope) {
    ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope);

    try {
        // TODO: note that filter does not get applied due to MNG-3236
        return dependencyTreeBuilder.buildDependencyTree(project,
                localRepository, artifactFactory,
                artifactMetadataSource, artifactFilter, artifactCollector);
    } catch (DependencyTreeBuilderException exception) {
    }
    return null;
}
项目:incubator-netbeans    文件:CosChecker.java   
static void touchProject(Project project) {
    NbMavenProject prj = project.getLookup().lookup(NbMavenProject.class);
    if (prj != null) {
        MavenProject mvn = prj.getMavenProject();
        if (RunUtils.isCompileOnSaveEnabled(project)) {
            touchCoSTimeStamp(mvn, false);
            touchCoSTimeStamp(mvn, true);
        } else {
            File f = getCoSFile(mvn, false);
            boolean doClean = f != null && f.exists();
            if (doClean) {
                try {
                    cleanGeneratedClassfiles(project);
                } catch (IOException ex) {
                    LOG.log(Level.FINE, "Error cleaning up", ex);
                }
            }
            deleteCoSTimeStamp(mvn, false);
            deleteCoSTimeStamp(mvn, true);
        }
    }
}
项目:athena    文件:YangPluginUtils.java   
/**
 * Copies YANG files to the current project's output directory.
 *
 * @param yangFileInfo list of YANG files
 * @param outputDir    project's output directory
 * @param project      maven project
 * @throws IOException when fails to copy files to destination resource directory
 */
public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
        throws IOException {

    List<File> files = getListOfFile(yangFileInfo);

    String path = outputDir + TARGET_RESOURCE_PATH;
    File targetDir = new File(path);
    targetDir.mkdirs();

    for (File file : files) {
        Files.copy(file.toPath(),
                new File(path + file.getName()).toPath(),
                StandardCopyOption.REPLACE_EXISTING);
    }
    addToProjectResource(outputDir + SLASH + TEMP + SLASH, project);
}
项目:EM    文件:EccentricModularityMavenLifecycleParticipant.java   
@Override
    public void afterProjectsRead(MavenSession session) throws MavenExecutionException {

        Set<String> goals = new HashSet<>(session.getGoals());

        if (goals.size() == 1 && goals.contains("clean")) {
            logger.info("Eccentric modularity not started (clean only session)! ");
            return;
        }

//      executionListener.setDelegate(session.getRequest().getExecutionListener());
//      session.getRequest().setExecutionListener(executionListener);
        logger.info("Eccentric modularity extension started!");


        List<MavenProject> allProjects = session.getProjects();
        for (MavenProject mavenProject : allProjects) {
            logger.info("Preparing " + mavenProject);
            executionListener.projectStarted(session.getProjectBuildingRequest(), mavenProject);
        }

    }
项目:Pogamut3    文件:TestUnpackMojo.java   
public void testMissingVersionFromDependencies()
    throws MojoExecutionException
{
    ArtifactItem item = new ArtifactItem();

    item.setArtifactId( "artifactId" );
    item.setClassifier( "" );
    item.setGroupId( "groupId" );
    item.setType( "jar" );

    ArrayList list = new ArrayList();
    list.add( item );
    mojo.setArtifactItems( list );

    MavenProject project = mojo.getProject();
    project.setDependencies( getDependencyList( item ) );

    mojo.execute();
    assertMarkerFile( true, item );
    assertEquals( "2.0-SNAPSHOT", item.getVersion() );
}
项目:EM    文件:BndPlugin.java   
private void configureJarPlugin(MavenProject project) throws MavenExecutionException {
    Plugin jarPlugin = getPlugin(project, "org.apache.maven.plugins:maven-jar-plugin");

    if (jarPlugin != null) {
        StringBuilder jarConfig = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") //
                .append("<configuration>") //
                .append("   <archive>\n") //
                .append("       <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>\n") //
                .append("   </archive>") //
                .append("   <annotationProcessorPaths>") //
                .append("       <annotationProcessorPath>") //
                .append("           <groupId>com.commsen.em</groupId>") //
                .append("           <artifactId>em.annotation.processors</artifactId>") //
                .append("           <version>").append(Constants.VAL_EXTENSION_VERSION).append("</version>") //
                .append("       </annotationProcessorPath>") //
                .append("   </annotationProcessorPaths>") //
                .append("</configuration>");

        configurePlugin(jarPlugin, "default-jar", jarConfig.toString());
    }
}
项目:EM    文件:BndIndexerPlugin.java   
public void addToPomForIndexingTmpBundles(MavenProject project) throws MavenExecutionException {

        Path genertedModules;
        try {
            genertedModules = Constants.getGeneratedModulesFolder(project);
        } catch (IOException e) {
            throw new MavenExecutionException(e.getMessage(), e);
        } 

        String configuration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" //
                + "<configuration>" //
                + "     <inputDir>" //
                +           genertedModules //
                + "     </inputDir>" //
                + "     <outputFile>${project.build.directory}/index/index.xml</outputFile>" //
                + "</configuration>"; //

        Plugin plugin = createPlugin("biz.aQute.bnd", "bnd-indexer-maven-plugin", VAL_BND_VERSION, configuration,
                "index", "local-index", null);

        project.getBuild().getPlugins().add(0, plugin);

        logger.info("Added `bnd-indexer-maven-plugin` to genrate an index of detected modules!");

    }
项目:incubator-netbeans    文件:CompileClassPathImpl.java   
static boolean getCompileArtifacts(MavenProject mavenProject, List<URI> lst) {
    // according the current 2.1 sources this is almost the same as getCompileClasspath()
    //except for the fact that multiproject references are not redirected to their respective
    // output folders.. we lways retrieve stuff from local repo..
    List<Artifact> arts = mavenProject.getCompileArtifacts();
    boolean broken = false;
    for (Artifact art : arts) {
        if (art.getFile() != null) {
            lst.add(Utilities.toURI(art.getFile()));
            broken |= !art.getFile().exists();
        } else {
            //NOPMD   //null means dependencies were not resolved..
            broken = true;
        } 
    }
    return broken;
}
项目:incubator-netbeans    文件:ArtifactDependencyIndexCreator.java   
private MavenProject load(ArtifactInfo ai) {
    try {
        Artifact projectArtifact = embedder.createArtifact(ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPackaging() != null ? ai.getPackaging() : "jar");
        ProjectBuildingRequest dpbr = embedder.createMavenExecutionRequest().getProjectBuildingRequest();
        //mkleint: remote repositories don't matter we use project embedder.
        dpbr.setRemoteRepositories(remoteRepos);
        dpbr.setProcessPlugins(false);
        dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);

        ProjectBuildingResult res = embedder.buildProject(projectArtifact, dpbr);
        if (res.getProject() != null) {
            return res.getProject();
        } else {
            LOG.log(Level.FINER, "No project model from repository for {0}: {1}", new Object[] {ai, res.getProblems()});
        }
    } catch (ProjectBuildingException ex) {
        LOG.log(Level.FINER, "Failed to load project model from repository for {0}: {1}", new Object[] {ai, ex});
    } catch (Exception exception) {
        LOG.log(Level.FINER, "Failed to load project model from repository for " + ai, exception);
    }
    return null;
}
项目:cdversion-maven-extension    文件:PluginMerger.java   
public void merge(
        MavenProject project, 
        Plugin mergePlugin) {
    if (mergePlugin.getArtifactId() == null || mergePlugin.getArtifactId().isEmpty()) {
        return;
    }

    List<Plugin> plugins = project.getBuild().getPlugins();
    Plugin foundPlugin = null;
    for (Plugin plugin : plugins) {
        if (mergePlugin.getGroupId().equals(plugin.getGroupId())
                && mergePlugin.getArtifactId().equals(plugin.getArtifactId())) {
            foundPlugin = plugin;
            break;
        }
    }
    if (foundPlugin == null) {
        plugins.add(mergePlugin);
    } else {
        mergeExecutions(foundPlugin.getExecutions(), mergePlugin.getExecutions());
    }
}
项目:incubator-netbeans    文件:MavenSourcesImpl.java   
@Messages({
    "SG_Sources=Source Packages",
    "SG_Test_Sources=Test Packages"
})
private void checkChanges(boolean fireChanges, boolean checkAlsoNonJavaStuff) {        
    boolean changed = false;
    synchronized (lock) {
        NbMavenProjectImpl project = project();
        MavenProject mp = project.getOriginalMavenProject();
        NbMavenProject watcher = project.getProjectWatcher();
        File folder = FileUtilities.convertStringToFile(mp.getBuild().getSourceDirectory());
        changed = changed | checkSourceGroupCache(folder, NAME_SOURCE, SG_Sources(), javaGroup, watcher);
        folder = FileUtilities.convertStringToFile(mp.getBuild().getTestSourceDirectory());
        changed = changed | checkSourceGroupCache(folder, NAME_TESTSOURCE, SG_Test_Sources(), javaGroup, watcher);
        changed = changed | checkGeneratedGroupsCache();
        if (checkAlsoNonJavaStuff) {
            changed = changed | checkOtherGroupsCache(project.getOtherRoots(false), false);
            changed = changed | checkOtherGroupsCache(project.getOtherRoots(true), true);
        }
    }
    if (changed) {
        if (fireChanges) {
            cs.fireChange();
        }
    }
}
项目:incubator-netbeans    文件:NetBeansRunParamsIDEChecker.java   
public @Override boolean checkRunConfig(RunConfig config) {
    String val = config.getProperties().get(OLD_PROPERTY);
    MavenProject prj = config.getMavenProject();
    boolean usingNew = usingNbmPlugin311(prj);
    if (usingNew) {
        if (val == null) {
            return true;
        }
        //modified nbactions.xml file? just adjust to new property
        config.setProperty(PROPERTY, val);
        config.setProperty(OLD_PROPERTY, null);
        return true;
    }
    if (val == null) { //!usingNew
        val = config.getProperties().get(PROPERTY);
        if (val == null) {
            //using old version of nbm plugin but also not using the old or new property, so it should be save to continue.
            return true;
        }
        config.setProperty(OLD_PROPERTY, val);
    }
    //offer upgrade to new version.
    return removeInterpolation(prj.getFile());

}
项目:azure-maven-plugins    文件:PackageMojoTest.java   
@Test
public void doExecute() throws Exception {
    final PackageMojo mojo = getMojoFromPom();
    final PackageMojo mojoSpy = spy(mojo);
    ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0");
    doReturn(mock(AnnotationHandler.class)).when(mojoSpy).getAnnotationHandler();
    doReturn(ClasspathHelper.forPackage("com.microsoft.azure.maven.function.handlers").toArray()[0])
            .when(mojoSpy)
            .getTargetClassUrl();
    doReturn("target/azure-functions").when(mojoSpy).getDeploymentStageDirectory();
    doReturn("target").when(mojoSpy).getBuildDirectoryAbsolutePath();
    doReturn(mock(MavenProject.class)).when(mojoSpy).getProject();
    doReturn(mock(MavenSession.class)).when(mojoSpy).getSession();
    doReturn(mock(MavenResourcesFiltering.class)).when(mojoSpy).getMavenResourcesFiltering();

    mojoSpy.doExecute();
}
项目:incubator-netbeans    文件:Utils.java   
private static Set<String> collectSourceRoots(Project prj) {
    Set<String> toRet = new HashSet<String>();
    NbMavenProject watcher = prj.getLookup().lookup(NbMavenProject.class);
    MavenProject mproject = watcher.getMavenProject();
    //TODO this ought to be really configurable based on what class gets debugged.
    toRet.addAll(mproject.getTestCompileSourceRoots());
    //for poms also include all module projects recursively..
    boolean isPom = NbMavenProject.TYPE_POM.equals(watcher.getPackagingType());
    if (isPom) {
        //only for pom is correct use of subprojectprovider
        ProjectContainerProvider subs = prj.getLookup().lookup(ProjectContainerProvider.class);
        ProjectContainerProvider.Result res = subs.getContainedProjects();
        for (Project pr : res.getProjects()) {
            toRet.addAll(collectSourceRoots(pr));
        }
    }
    return toRet;
}
项目:smart-testing    文件:SurefireReportStorageTest.java   
@Test
public void should_purge_reports_directory() throws IOException {
    // given
    copySurefireReports(project);
    MavenSession mavenSession = mock(MavenSession.class);
    MavenProject mavenProject = mock(MavenProject.class);
    when(mavenProject.getModel()).thenReturn(project);
    when(mavenSession.getAllProjects()).thenReturn(singletonList(mavenProject));
    File reportsDir = TemporaryInternalFiles.createTestReportDirAction(projectDir).getFile();

    // when
    new LocalStorage(projectDir).duringExecution().purge(null);

    // then
    softly.assertThat(reportsDir).doesNotExist();
}
项目:incubator-netbeans    文件:NbMavenProjectImpl.java   
@Override
public void run() {
    problemReporter.clearReports(); //#167741 -this will trigger node refresh?
    MavenProject prj = loadOriginalMavenProject(true);
    synchronized (NbMavenProjectImpl.this) {
        MavenProject old = project == null ? null : project.get();
        if (old != null && MavenProjectCache.isFallbackproject(prj)) {
            prj.setPackaging(old.getPackaging()); //#229366 preserve packaging for broken projects to avoid changing lookup.
        }
        project = new SoftReference<MavenProject>(prj);
        if (hardReferencingMavenProject) {
            hardRefProject = prj;
        }
    }
    ACCESSOR.doFireReload(watcher);
}
项目:cdversion-maven-extension    文件:Plugins.java   
public Plugin getEnforcerPlugin(MavenProject project)
        throws MavenExecutionException {
    StringBuilder configString = new StringBuilder()
            .append("<configuration><rules>")
            .append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
            .append("</rules></configuration>");
    Xpp3Dom config = null;
    try {
        config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
    } catch (XmlPullParserException | IOException ex) {
        throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
    }

    PluginExecution execution = new PluginExecution();
    execution.setId("no-snapshot-deps");
    execution.addGoal("enforce");
    execution.setConfiguration(config);

    Plugin result = new Plugin();
    result.setArtifactId("maven-enforcer-plugin");
    result.setVersion("1.4.1");
    result.addExecution(execution);

    return result;
}
项目:incubator-netbeans    文件:NbMavenProjectImpl.java   
protected List<File> getParents() {
    LinkedList<File> ret = new LinkedList<>();
    MavenProject project = getOriginalMavenProject();
    while(true) {
        try {
            MavenProject parent = loadParentOf(getEmbedder(), project);
            File parentFile = parent != null ? parent.getFile() : null;
            if(parentFile != null) {
                ret.add(parentFile);
                project = parent;
            } else {
                break;
            }
        } catch (ProjectBuildingException ex) {
            break;
        }
    } 
    return ret;
}
项目:incubator-netbeans    文件:MavenCoverageProvider.java   
private boolean hasPlugin(String groupId, String artifactId) {
    NbMavenProject prj = p.getLookup().lookup(NbMavenProject.class);
    if (prj == null) {
        return false;
    }
    MavenProject mp = prj.getMavenProject();
    if (PluginPropertyUtils.getReportPluginVersion(mp, groupId, artifactId) != null) {
        return true;
    }
    if (PluginPropertyUtils.getPluginVersion(mp, groupId, artifactId) != null) {
        // For whatever reason, was configured as a direct build plugin... fine.
        return true;
    }
    // In fact you _could_ just run the plugin directly here... but perhaps the user did not want to do so.
    return false;
}
项目:Pogamut3    文件:TestUnpackMojo.java   
public void testMissingVersionFromDependenciesWithClassifier()
    throws MojoExecutionException
{
    ArtifactItem item = new ArtifactItem();

    item.setArtifactId( "artifactId" );
    item.setClassifier( "classifier" );
    item.setGroupId( "groupId" );
    item.setType( "war" );

    ArrayList list = new ArrayList();
    list.add( item );
    mojo.setArtifactItems( list );

    MavenProject project = mojo.getProject();
    project.setDependencies( getDependencyList( item ) );

    mojo.execute();
    assertMarkerFile( true, item );
    assertEquals( "2.1", item.getVersion() );
}
项目:neoscada    文件:GenerateQualifierMojo.java   
@Override
protected synchronized String getQualifier ( final MavenProject project ) throws MojoExecutionException
{
    String providerType = this.nameProviderMap.get ( project.getPackaging () );
    if ( providerType == null )
    {
        providerType = this.defaultNameProvider;
    }

    getLog ().debug ( String.format ( "Using provider '%s' for project: %s", providerType, project.getId () ) );

    final QualifierNameProvider nameProvider = this.nameProviders.get ( providerType );
    if ( nameProvider == null )
    {
        throw new MojoExecutionException ( String.format ( "Unable to find name provider with hint '%s'", providerType ) );
    }

    return nameProvider.createName ( new Configuration ( this.session, this.execution, project, this.nameProviderProperties ) );
}
项目:neoscada    文件:AbstractSetQualifierMojo.java   
private void handleFeature ( final MavenProject project, final String version ) throws Exception
{
    recordVersion ( "feature", project.getArtifactId (), version );

    this.changeManager.addChange ( new Callable<Void> () {

        @Override
        public Void call () throws Exception
        {
            final File file = new File ( project.getBasedir (), "feature.xml" );
            final Document doc = XmlHelper.parse ( file );
            XmlHelper.updateValue ( doc, "/feature/@version", version );
            XmlHelper.write ( doc, file );
            return null;
        }
    } );
}
项目: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);
}
项目:maven-cdn-alioss-plugin    文件:MyAbstractMojo.java   
@SuppressWarnings({ "unchecked" })
private String[] buildExcludes() {
    List<String> ex = new ArrayList<String>();
    ex.addAll(asList(this.excludes));
    MavenProject project = getProject();
    if (project != null && project.getModules() != null) {
        for (String module : (List<String>) project.getModules()) {
            ex.add(module + "/**");
        }
    }
    return ex.toArray(new String[ex.size()]);
}
项目:Reer    文件:DefaultArtifactPom.java   
private void assignArtifactValuesToPom(Artifact artifact, MavenPom pom, boolean setType) {
    if (pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID)) {
        pom.setGroupId(artifact.getModuleRevisionId().getOrganisation());
    }
    if (pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID)) {
        pom.setArtifactId(artifact.getName());
    }
    if (pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION)) {
        pom.setVersion(artifact.getModuleRevisionId().getRevision());
    }
    if (setType) {
        pom.setPackaging(artifact.getType());
    }
}
项目:neoscada    文件:DefaultPomHelper.java   
protected List<String> getModules ( final MavenProject project )
{
    final List<String> result = new LinkedList<String> ();

    result.addAll ( project.getModules () );
    for ( final Profile profile : project.getModel ().getProfiles () )
    {
        result.addAll ( profile.getModules () );
    }

    return result;
}
项目:EM    文件:ExportMojo.java   
private Set<File> prepareDependencies(ProjectBuildingRequest projectBuildingRequest, MavenProject project) {

        if (logger.isDebugEnabled()) {
            logger.debug("Analysing project's BOMs!");
        } else if (Flag.verbose()) {
            logger.info("Analysing project's BOMs!");
        }

        Set<File> bundleSet = new HashSet<File>();

        boolean generateIndex = project.getProperties().containsKey(PROP_CONFIG_INDEX);

        processModules(projectBuildingRequest, project);

        Set<Artifact> artifacts = new HashSet<>();
        try {
            artifacts.addAll(dependencies.asArtifacts(projectBuildingRequest, project));
            artifacts.addAll(dependencies.managedAsArtifacts(projectBuildingRequest, project));
        } catch (MavenExecutionException e) {
            throw new RuntimeException("Failed to analyze dependencies", e);
        }

        /*
         * For each artifact : - convert to bundle if it's not - add it to the bundle
         * set
         */
        artifacts.stream().forEach(a -> addToBundleSet(a, emProjectGeneratedModules.toFile(), bundleSet, generateIndex));

        return bundleSet;

    }
项目:incubator-netbeans    文件:NBPluginParameterExpressionEvaluator.java   
@Deprecated
public NBPluginParameterExpressionEvaluator( 
                                           MavenProject project, 
                                           Settings settings,
                                           Map<? extends String,? extends String> systemProperties)
{
    this(project, settings, systemProperties, Collections.<String, String>emptyMap());
}
项目:athena    文件:YangPluginUtils.java   
/**
 * Resolves inter jar dependencies.
 *
 * @param project         current maven project
 * @param localRepository local maven repository
 * @param remoteRepos     list of remote repository
 * @param directory       directory for serialized files
 * @return list of resolved datamodel nodes
 * @throws IOException when fails to do IO operations
 */
public static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository,
                                                         List<ArtifactRepository> remoteRepos, String directory)
        throws IOException {

    List<String> dependeciesJarPaths = resolveDependecyJarPath(project, localRepository, remoteRepos);
    List<YangNode> resolvedDataModelNodes = new ArrayList<>();
    for (String dependecy : dependeciesJarPaths) {
        resolvedDataModelNodes.addAll(deSerializeDataModel(parseJarFile(dependecy, directory)));
    }
    return resolvedDataModelNodes;
}
项目:EM    文件:BndExportPlugin.java   
private String getBndrunPath(MavenProject project) throws MavenExecutionException {
    String bndrunName = project.getProperties().getProperty(Constants.PROP_CONFIG_BNDRUN, "");
    if (bndrunName.trim().isEmpty()) {
        bndrunName = project.getName() + ".bndrun";
    }

    File existingBndrunFile = new File(project.getBasedir(), bndrunName);
    File targetBndrunFile = emProjectHome.resolve(bndrunName).toFile();

    if (existingBndrunFile.exists()) {
        if (existingBndrunFile.isFile()) {
            logger.info("Found `" + existingBndrunFile.getName() + "` in project's folder and will use it as is! POM config is ignored!");
            try {
                Files.copy(existingBndrunFile.toPath(), targetBndrunFile.toPath());
            } catch (IOException e) {
                throw new MavenExecutionException("Failed to copy file!", e);
            }
        } else {
            throw new MavenExecutionException("'" + existingBndrunFile + "' is not a file!", project.getFile());
        }
    } else {
        String distro = project.getProperties().getProperty(INTERNAL_DISTRO_FILE, "");
        generateBndrun(project, distro, targetBndrunFile);
    }

    return targetBndrunFile.getAbsolutePath();
}
项目:incubator-netbeans    文件:AbstractSchemaBasedGrammar.java   
protected final MavenProject getMavenProject() {
    Project proj = FileOwnerQuery.getOwner(environment.getFileObject());
    if (proj != null) {
        NbMavenProject watch = proj.getLookup().lookup(NbMavenProject.class);
        assert watch != null;
        return watch.getMavenProject();
    }
    ErrorManager.getDefault().log(ErrorManager.WARNING, "File " + environment.getFileObject() + " has maven2 code completion but doesn't belong to a maven2 project."); //NOI18N
    return null;
}
项目:azure-maven-plugins    文件:FTPArtifactHandlerImplTest.java   
@Test
public void copyResourcesToStageDirectory() throws Exception {
    doReturn(mock(MavenProject.class)).when(mojo).getProject();
    doReturn(mock(MavenSession.class)).when(mojo).getSession();
    doReturn(mock(MavenResourcesFiltering.class)).when(mojo).getMavenResourcesFiltering();
    doReturn("stageDirectory").when(mojo).getDeploymentStageDirectory();

    handler.copyResourcesToStageDirectory(new ArrayList<Resource>());
    verify(mojo, times(1)).getProject();
    verify(mojo, times(1)).getSession();
    verify(mojo, times(1)).getMavenResourcesFiltering();
    verify(mojo, times(1)).getDeploymentStageDirectory();
    verifyNoMoreInteractions(mojo);
}
项目:neoscada    文件:UpdateMojo.java   
protected String getVersion ( final MavenProject project )
{
    getLog ().debug ( "Properties: " + project.getProperties () );

    if ( !project.getVersion ().endsWith ( "-SNAPSHOT" ) )
    {
        // project version is already qualified
        return project.getVersion ();
    }

    final String version = project.getProperties ().getProperty ( "qualifiedVersion" );
    if ( version != null )
    {
        // we do have a direct qualified version
        return version;
    }

    final String q = project.getProperties ().getProperty ( "buildQualifier" );
    final String v = project.getProperties ().getProperty ( "unqualifiedVersion" );

    if ( q == null || v == null )
    {
        throw new IllegalStateException ( String.format ( "Unable to find qualified version for: %s", project.getArtifactId () ) );
    }

    // just stick it together
    return v + "." + q;
}
项目:incubator-netbeans    文件:AuxPropsImpl.java   
static boolean definesCheckStyle(MavenProject prj) {
    for (ReportPlugin plug : prj.getReportPlugins()) {
        if (Constants.GROUP_APACHE_PLUGINS.equals(plug.getGroupId()) &&
                Constants.PLUGIN_CHECKSTYLE.equals(plug.getArtifactId())) { //NOI18N
            return true;
        }
    }
    return false;
}
项目:incubator-netbeans    文件:OldJavaRunnerCOS.java   
private static  ClassPath createRuntimeClassPath(MavenProject prj, boolean test) {
    List<URI> roots;
    if (test) {
        roots = TestRuntimeClassPathImpl.createPath(prj);
    } else {
        roots = RuntimeClassPathImpl.createPath(prj);
    }
    return ClassPathSupport.createClassPath(AbstractProjectClassPathImpl.getPath(roots.toArray(new URI[0]), null));
}
项目:neoscada    文件:DefaultPomHelper.java   
private MavenProject loadProject ( File file, final MavenSession session ) throws Exception
{
    file = file.getCanonicalFile ();
    for ( final MavenProject project : session.getProjects () )
    {
        final File projectFile = project.getFile ().getCanonicalFile ();
        if ( projectFile.equals ( file ) )
        {
            return project;
        }
    }

    throw new MojoExecutionException ( file, "Unreferenced project found", String.format ( "Project at '%s' is not in the list of active projects. This plugin can only"
            + "work on projects there were loaded by maven. You need to include the project in your build.", file ) );
}
项目:incubator-netbeans    文件:AddDependencyPanel.java   
private static List<Dependency> getDependenciesFromDM(MavenProject project, Project nbprj) {
    NbMavenProjectImpl p = nbprj.getLookup().lookup(NbMavenProjectImpl.class);
    MavenProject localProj = project;
    DependencyManagement curDM;
    List<Dependency> result = new ArrayList<Dependency>();
    //mkleint: without the managementKey checks I got some entries multiple times.
    // do we actually need to traverse the parent poms, are they completely resolved anyway?
    //XXX
    Set<String> knownKeys = new HashSet<String>();

    while (localProj != null) {
        curDM = localProj.getDependencyManagement();
        if (curDM != null) {
            @SuppressWarnings("unchecked")
            List<Dependency> ds = curDM.getDependencies();
            for (Dependency d : ds) {
                if (knownKeys.contains(d.getManagementKey())) {
                    continue;
                }
                result.add(d);
                knownKeys.add(d.getManagementKey());
            }
        }
        try {
            localProj = p.loadParentOf(EmbedderFactory.getProjectEmbedder(), localProj);
        } catch (ProjectBuildingException x) {
            break;
        }
    }
    Collections.sort(result, new Comparator<Dependency>() {

        @Override
        public int compare(Dependency o1, Dependency o2) {
            return o1.getManagementKey().compareTo(o2.getManagementKey());
        }
    });
    return result;
}
项目:incubator-netbeans    文件:GraphConstructor.java   
public GraphConstructor(DependencyGraphScene scene, MavenProject proj) {
        this.scene = scene;
        this.proj = proj;
        path = new Stack<>();
//        graphPath = new Stack<ArtifactGraphNode>();
        cache = new HashMap<>();
        edges = new ArrayList<>();
    }
项目:incubator-netbeans    文件:RepositoryMavenCPProvider.java   
private ClassPathImplementation createExecuteCPI(MavenProject project, File binary) {
    List<PathResourceImplementation> items = new ArrayList<PathResourceImplementation>(); 
    items.add(ClassPathSupport.createResource(FileUtil.urlForArchiveOrDir(binary)));
    if (project != null) {
        for (Artifact s : project.getRuntimeArtifacts()) {
            if (s.getFile() == null) continue;
            items.add(ClassPathSupport.createResource(FileUtil.urlForArchiveOrDir(s.getFile())));
        }
    }
    return ClassPathSupport.createClassPathImplementation(items);
}