<commit_before>package com.heroku.sdk.maven.mojo;

import com.heroku.sdk.deploy.lib.OutputAdapter;
import com.heroku.sdk.deploy.lib.deploymemt.Deployer;
import com.heroku.sdk.deploy.lib.deploymemt.DeploymentDescriptor;
import com.heroku.sdk.deploy.lib.resolver.ApiKeyResolver;
import com.heroku.sdk.deploy.lib.resolver.AppNameResolver;
import com.heroku.sdk.deploy.lib.resolver.WebappRunnerResolver;
import com.heroku.sdk.deploy.lib.sourceblob.JvmProjectSourceBlobCreator;
import com.heroku.sdk.deploy.lib.sourceblob.SourceBlobDescriptor;
import com.heroku.sdk.deploy.lib.sourceblob.SourceBlobPackager;
import com.heroku.sdk.deploy.util.FileDownloader;
import com.heroku.sdk.deploy.util.PathUtils;
import com.heroku.sdk.deploy.util.Procfile;
import com.heroku.sdk.maven.MavenLogOutputAdapter;
import com.heroku.sdk.maven.MojoExecutor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public abstract class AbstractHerokuDeployMojo extends AbstractHerokuMojo {

    protected final void deploy(Mode mode) throws MojoExecutionException, MojoFailureException {
        try {
            OutputAdapter outputAdapter = new MavenLogOutputAdapter(getLog(), logProgress);

            Path projectDirectory = super.mavenProject.getBasedir().toPath();

            Path dependencyList = MojoExecutor.createDependencyListFile(super.mavenProject, super.mavenSession, super.pluginManager);

            ArrayList<Path> includedPaths = new ArrayList<>();

            for (String includePattern : super.includes) {
                includedPaths.addAll(resolveIncludePattern(includePattern));
            }

            includedPaths.add(Paths.get("pom.xml"));

            if (super.includeTarget) {
                includedPaths.add(Paths.get("target"));
            }

            Optional<Path> warFilePath = resolveWarFilePath(mode, projectDirectory);

            Supplier<Procfile> customProcfileResolver = () -> new Procfile(super.processTypes);
            if (mode == Mode.WAR) {
                if (!super.processTypes.isEmpty()) {
                    outputAdapter.logWarn("The processTypes property will be ignored when deploying a WAR file. Use `heroku:deploy` goal for custom processes.");
                }

                customProcfileResolver = () ->
                        Procfile.singleton("web", "java $JAVA_OPTS -jar webapp-runner.jar $WEBAPP_RUNNER_OPTS --port $PORT " + warFilePath.get().toString());
            }

            SourceBlobDescriptor sourceBlobDescriptor = JvmProjectSourceBlobCreator.create(
                    projectDirectory,
                    "heroku-maven-plugin",
                    includedPaths,
                    customProcfileResolver,
                    Procfile.empty(),
                    () -> Optional.ofNullable(super.jdkVersion),
                    outputAdapter
            );

            sourceBlobDescriptor.addLocalPath("mvn-dependency-list.log", dependencyList, true);

            if (mode == Mode.WAR) {
                Path webappRunnerPath = FileDownloader.download(WebappRunnerResolver.getUrlForVersion(super.webappRunnerVersion));
                sourceBlobDescriptor.addLocalPath("webapp-runner.jar", webappRunnerPath, false);
            }

            Path sourceBlob = SourceBlobPackager.pack(sourceBlobDescriptor, outputAdapter);

            String appName = AppNameResolver.resolve(projectDirectory, () -> Optional.ofNullable(super.appName))<commit_msg>Move mvn-dependency-list.log into target directory<commit_after>package com.heroku.sdk.maven.mojo;

import com.heroku.sdk.deploy.lib.OutputAdapter;
import com.heroku.sdk.deploy.lib.deploymemt.Deployer;
import com.heroku.sdk.deploy.lib.deploymemt.DeploymentDescriptor;
import com.heroku.sdk.deploy.lib.resolver.ApiKeyResolver;
import com.heroku.sdk.deploy.lib.resolver.AppNameResolver;
import com.heroku.sdk.deploy.lib.resolver.WebappRunnerResolver;
import com.heroku.sdk.deploy.lib.sourceblob.JvmProjectSourceBlobCreator;
import com.heroku.sdk.deploy.lib.sourceblob.SourceBlobDescriptor;
import com.heroku.sdk.deploy.lib.sourceblob.SourceBlobPackager;
import com.heroku.sdk.deploy.util.FileDownloader;
import com.heroku.sdk.deploy.util.PathUtils;
import com.heroku.sdk.deploy.util.Procfile;
import com.heroku.sdk.maven.MavenLogOutputAdapter;
import com.heroku.sdk.maven.MojoExecutor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public abstract class AbstractHerokuDeployMojo extends AbstractHerokuMojo {

    protected final void deploy(Mode mode) throws MojoExecutionException, MojoFailureException {
        try {
            OutputAdapter outputAdapter = new MavenLogOutputAdapter(getLog(), logProgress);

            Path projectDirectory = super.mavenProject.getBasedir().toPath();

            Path dependencyList = MojoExecutor.createDependencyListFile(super.mavenProject, super.mavenSession, super.pluginManager);

            ArrayList<Path> includedPaths = new ArrayList<>();

            for (String includePattern : super.includes) {
                includedPaths.addAll(resolveIncludePattern(includePattern));
            }

            includedPaths.add(Paths.get("pom.xml"));

            if (super.includeTarget) {
                includedPaths.add(Paths.get("target"));
            }

            Optional<Path> warFilePath = resolveWarFilePath(mode, projectDirectory);

            Supplier<Procfile> customProcfileResolver = () -> new Procfile(super.processTypes);
            if (mode == Mode.WAR) {
                if (!super.processTypes.isEmpty()) {
                    outputAdapter.logWarn("The processTypes property will be ignored when deploying a WAR file. Use `heroku:deploy` goal for custom processes.");
                }

                customProcfileResolver = () ->
                        Procfile.singleton("web", "java $JAVA_OPTS -jar webapp-runner.jar $WEBAPP_RUNNER_OPTS --port $PORT " + warFilePath.get().toString());
            }

            SourceBlobDescriptor sourceBlobDescriptor = JvmProjectSourceBlobCreator.create(
                    projectDirectory,
                    "heroku-maven-plugin",
                    includedPaths,
                    customProcfileResolver,
                    Procfile.empty(),
                    () -> Optional.ofNullable(super.jdkVersion),
                    outputAdapter
            );

            sourceBlobDescriptor.addLocalPath("target/mvn-dependency-list.log", dependencyList, true);

            if (mode == Mode.WAR) {
                Path webappRunnerPath = FileDownloader.download(WebappRunnerResolver.getUrlForVersion(super.webappRunnerVersion));
                sourceBlobDescriptor.addLocalPath("webapp-runner.jar", webappRunnerPath, false);
            }

            Path sourceBlob = SourceBlobPackager.pack(sourceBlobDescriptor, outputAdapter);

            String appName = AppNameResolver.resolve(projectDirectory, () -> Optional.ofNullable(super.appName))
{'fraction_non_alphanumeric': 0.09966862095335202, 'fraction_numerical': 0.0, 'mean_word_length': 3.097650130548303, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6039031', 'n_tokens_mistral': 2186, 'n_tokens_neox': 2067, 'n_words': 345}