Search in sources :

Example 11 with Build

use of org.apache.maven.model.Build in project grails-maven by grails.

the class MvnWarMojo method execute.

/**
 * Executes the MvnWarMojo on the current project.
 *
 * @throws MojoExecutionException if an error occured while building the webapp
 */
public void execute() throws MojoExecutionException, MojoFailureException {
    Build build = project.getBuild();
    String warFileName = build.getFinalName() != null ? build.getFinalName() : project.getArtifactId() + "-" + project.getVersion();
    if (!warFileName.endsWith(".war")) {
        warFileName += ".war";
    }
    warFile = new File(build.getDirectory(), warFileName);
    if (getEnvironment() == null) {
        env = "prod";
    }
    runGrails("War", warFile.toString());
}
Also used : Build(org.apache.maven.model.Build) File(java.io.File)

Example 12 with Build

use of org.apache.maven.model.Build in project che by eclipse.

the class MavenModelUtil method convertModel.

public static MavenModel convertModel(Model model) {
    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, sources, testSources, Collections.emptyList(), Collections.emptyList(), null);
}
Also used : MavenBuild(org.eclipse.che.maven.data.MavenBuild) Build(org.apache.maven.model.Build) ArrayList(java.util.ArrayList)

Example 13 with Build

use of org.apache.maven.model.Build in project che by eclipse.

the class MavenModelUtil method convertToMavenProfile.

private static Profile convertToMavenProfile(MavenProfile mavenProfile) {
    Profile result = new Profile();
    result.setId(mavenProfile.getId());
    result.setSource(mavenProfile.getSource());
    result.setModules(mavenProfile.getModules());
    result.setProperties(mavenProfile.getProperties());
    result.setBuild(new Build());
    result.setActivation(convertToMavenActivation(mavenProfile.getActivation()));
    convertToMavenBuildBase(mavenProfile.getBuild(), result.getBuild());
    return result;
}
Also used : MavenBuild(org.eclipse.che.maven.data.MavenBuild) Build(org.apache.maven.model.Build) Profile(org.apache.maven.model.Profile) MavenProfile(org.eclipse.che.maven.data.MavenProfile)

Example 14 with Build

use of org.apache.maven.model.Build in project che by eclipse.

the class MavenModelUtil method convertPlugins.

private static List<MavenPlugin> convertPlugins(Model model) {
    List<MavenPlugin> result = new ArrayList<>();
    Build build = model.getBuild();
    if (build != null) {
        List<Plugin> plugins = build.getPlugins();
        if (plugins != null) {
            result.addAll(plugins.stream().map(MavenModelUtil::convertPlugin).collect(Collectors.toList()));
        }
    }
    return result;
}
Also used : MavenBuild(org.eclipse.che.maven.data.MavenBuild) Build(org.apache.maven.model.Build) MavenPlugin(org.eclipse.che.maven.data.MavenPlugin) ArrayList(java.util.ArrayList) MavenPlugin(org.eclipse.che.maven.data.MavenPlugin) Plugin(org.apache.maven.model.Plugin)

Example 15 with Build

use of org.apache.maven.model.Build in project buck by facebook.

the class Pom method merge.

private Model merge(Model first, @Nullable Model second) {
    if (second == null) {
        return first;
    }
    Model model = first.clone();
    //---- Values from ModelBase
    List<String> modules = second.getModules();
    if (modules != null) {
        for (String module : modules) {
            model.addModule(module);
        }
    }
    DistributionManagement distributionManagement = second.getDistributionManagement();
    if (distributionManagement != null) {
        model.setDistributionManagement(distributionManagement);
    }
    Properties properties = second.getProperties();
    if (properties != null) {
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            model.addProperty((String) entry.getKey(), (String) entry.getValue());
        }
    }
    DependencyManagement dependencyManagement = second.getDependencyManagement();
    if (dependencyManagement != null) {
        model.setDependencyManagement(dependencyManagement);
    }
    List<Dependency> dependencies = second.getDependencies();
    if (dependencies != null) {
        for (Dependency dependency : dependencies) {
            model.addDependency(dependency);
        }
    }
    List<Repository> repositories = second.getRepositories();
    if (repositories != null) {
        for (Repository repository : repositories) {
            model.addRepository(repository);
        }
    }
    List<Repository> pluginRepositories = second.getPluginRepositories();
    if (pluginRepositories != null) {
        for (Repository pluginRepository : pluginRepositories) {
            model.addPluginRepository(pluginRepository);
        }
    }
    // Ignore reports, reporting, and locations
    //----- From Model
    Parent parent = second.getParent();
    if (parent != null) {
        model.setParent(parent);
    }
    Organization organization = second.getOrganization();
    if (organization != null) {
        model.setOrganization(organization);
    }
    List<License> licenses = second.getLicenses();
    Set<String> currentLicenseUrls = new HashSet<>();
    if (model.getLicenses() != null) {
        for (License license : model.getLicenses()) {
            currentLicenseUrls.add(license.getUrl());
        }
    }
    if (licenses != null) {
        for (License license : licenses) {
            if (!currentLicenseUrls.contains(license.getUrl())) {
                model.addLicense(license);
                currentLicenseUrls.add(license.getUrl());
            }
        }
    }
    List<Developer> developers = second.getDevelopers();
    Set<String> currentDevelopers = new HashSet<>();
    if (model.getDevelopers() != null) {
        for (Developer developer : model.getDevelopers()) {
            currentDevelopers.add(developer.getName());
        }
    }
    if (developers != null) {
        for (Developer developer : developers) {
            if (!currentDevelopers.contains(developer.getName())) {
                model.addDeveloper(developer);
                currentDevelopers.add(developer.getName());
            }
        }
    }
    List<Contributor> contributors = second.getContributors();
    Set<String> currentContributors = new HashSet<>();
    if (model.getContributors() != null) {
        for (Contributor contributor : model.getContributors()) {
            currentDevelopers.add(contributor.getName());
        }
    }
    if (contributors != null) {
        for (Contributor contributor : contributors) {
            if (!currentContributors.contains(contributor.getName())) {
                model.addContributor(contributor);
                currentContributors.add(contributor.getName());
            }
        }
    }
    List<MailingList> mailingLists = second.getMailingLists();
    if (mailingLists != null) {
        for (MailingList mailingList : mailingLists) {
            model.addMailingList(mailingList);
        }
    }
    Prerequisites prerequisites = second.getPrerequisites();
    if (prerequisites != null) {
        model.setPrerequisites(prerequisites);
    }
    Scm scm = second.getScm();
    if (scm != null) {
        model.setScm(scm);
    }
    String url = second.getUrl();
    if (url != null) {
        model.setUrl(url);
    }
    String description = second.getDescription();
    if (description != null) {
        model.setDescription(description);
    }
    IssueManagement issueManagement = second.getIssueManagement();
    if (issueManagement != null) {
        model.setIssueManagement(issueManagement);
    }
    CiManagement ciManagement = second.getCiManagement();
    if (ciManagement != null) {
        model.setCiManagement(ciManagement);
    }
    Build build = second.getBuild();
    if (build != null) {
        model.setBuild(build);
    }
    List<Profile> profiles = second.getProfiles();
    Set<String> currentProfileIds = new HashSet<>();
    if (model.getProfiles() != null) {
        for (Profile profile : model.getProfiles()) {
            currentProfileIds.add(profile.getId());
        }
    }
    if (profiles != null) {
        for (Profile profile : profiles) {
            if (!currentProfileIds.contains(profile.getId())) {
                model.addProfile(profile);
                currentProfileIds.add(profile.getId());
            }
        }
    }
    return model;
}
Also used : Organization(org.apache.maven.model.Organization) Parent(org.apache.maven.model.Parent) License(org.apache.maven.model.License) MailingList(org.apache.maven.model.MailingList) Developer(org.apache.maven.model.Developer) Contributor(org.apache.maven.model.Contributor) Properties(java.util.Properties) Profile(org.apache.maven.model.Profile) Prerequisites(org.apache.maven.model.Prerequisites) Build(org.apache.maven.model.Build) DependencyManagement(org.apache.maven.model.DependencyManagement) IssueManagement(org.apache.maven.model.IssueManagement) HashSet(java.util.HashSet) Dependency(org.apache.maven.model.Dependency) Repository(org.apache.maven.model.Repository) Model(org.apache.maven.model.Model) CiManagement(org.apache.maven.model.CiManagement) DistributionManagement(org.apache.maven.model.DistributionManagement) Scm(org.apache.maven.model.Scm) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

Build (org.apache.maven.model.Build)23 Model (org.apache.maven.model.Model)7 MavenProject (org.apache.maven.project.MavenProject)7 File (java.io.File)4 MavenBuild (org.eclipse.che.maven.data.MavenBuild)4 Properties (java.util.Properties)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Parent (org.apache.maven.model.Parent)2 Plugin (org.apache.maven.model.Plugin)2 PluginManagement (org.apache.maven.model.PluginManagement)2 Profile (org.apache.maven.model.Profile)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Path (java.nio.file.Path)1 List (java.util.List)1 Map (java.util.Map)1 JarFile (java.util.jar.JarFile)1 DefaultArtifact (org.apache.maven.artifact.DefaultArtifact)1 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)1 ArtifactHandler (org.apache.maven.artifact.handler.ArtifactHandler)1