private ReleaseResult runLogic()

in maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RunPerformGoalsPhase.java [62:128]


    private ReleaseResult runLogic(
            ReleaseDescriptor releaseDescriptor, ReleaseEnvironment releaseEnvironment, boolean simulate)
            throws ReleaseExecutionException {
        String additionalArguments = getAdditionalArguments(releaseDescriptor);

        if (releaseDescriptor.isUseReleaseProfile()) {
            if (!(additionalArguments == null || additionalArguments.isEmpty())) {
                additionalArguments = additionalArguments + " -DperformRelease=true";
            } else {
                additionalArguments = "-DperformRelease=true";
            }
        }

        String pomFileName = releaseDescriptor.getPomFileName();
        if (pomFileName == null) {
            pomFileName = "pom.xml";
        }

        // ensure we don't use the release pom for the perform goals
        // ^^ paranoia? A MavenExecutor has already access to this. Probably worth refactoring.
        if (!(additionalArguments == null || additionalArguments.isEmpty())) {
            additionalArguments = additionalArguments + " -f " + pomFileName;
        } else {
            additionalArguments = "-f " + pomFileName;
        }

        if (simulate) {
            ReleaseResult result = new ReleaseResult();

            logInfo(
                    result,
                    "Simulating perform goals '" + buffer().strong(getGoals(releaseDescriptor))
                            + "' - since this is simulation mode these goals are skipped.");
            logInfo(result, "    with additional arguments: " + additionalArguments);

            return result;
        }

        String workDir = releaseDescriptor.getWorkingDirectory();
        if (workDir == null) {
            workDir = System.getProperty("user.dir");
        }

        File pomFile = new File(workDir, pomFileName);
        PomFinder pomFinder = new PomFinder(getLogger());
        boolean foundPom = false;

        if (StringUtils.isEmpty(releaseDescriptor.getScmRelativePathProjectDirectory())) {
            foundPom = pomFinder.parsePom(pomFile);
        }

        File workDirectory = new File(releaseDescriptor.getCheckoutDirectory());

        if (foundPom) {
            File matchingPom = pomFinder.findMatchingPom(workDirectory);
            if (matchingPom != null) {
                getLogger().info("Invoking perform goals in directory " + matchingPom.getParent());
                // The directory of the POM in a flat project layout is not
                // the same directory as the SCM checkout directory!
                // The same is true for a sparse checkout in e.g. GIT
                // the project to build could be in target/checkout/some/dir/
                workDirectory = matchingPom.getParentFile();
            }
        }

        return execute(releaseDescriptor, releaseEnvironment, workDirectory, additionalArguments, false);
    }