Search in sources :

Example 16 with Build

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

the class ReactorMavenProjectStub method getModel.

public Model getModel() {
    if (model == null) {
        model = new Model();
        model.setGroupId(getGroupId());
        model.setArtifactId(getArtifactId());
        model.setVersion(getVersion());
        model.setPackaging(getPackaging());
        model.setProperties(new Properties());
        Build build = new Build();
        build.setFinalName(getArtifactId() + "-" + getVersion() + "." + getPackaging());
        if (parent != null) {
            build.setDirectory(parent.getBasedir().getAbsolutePath() + "/" + getArtifactId() + "/target");
            FileUtils.mkdir(build.getDirectory());
            build.setOutputDirectory(parent.getBasedir().getAbsolutePath() + "/" + getArtifactId() + "/target/classes");
            FileUtils.mkdir(build.getOutputDirectory());
            build.setTestOutputDirectory(parent.getBasedir().getAbsolutePath() + "/" + getArtifactId() + "/target/test-classes");
            FileUtils.mkdir(build.getTestOutputDirectory());
            Reporting reporting = new Reporting();
            reporting.setOutputDirectory(parent.getBasedir().getAbsolutePath() + "/" + getArtifactId() + "/target/site");
            FileUtils.mkdir(reporting.getOutputDirectory());
            model.setReporting(reporting);
        }
        model.setBuild(build);
    }
    return model;
}
Also used : Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) Properties(java.util.Properties) Reporting(org.apache.maven.model.Reporting)

Example 17 with Build

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

the class AssemblyExpressionEvaluatorTest method testShouldInterpolateMultiDotProjectExpression.

public void testShouldInterpolateMultiDotProjectExpression() throws ExpressionEvaluationException {
    final Build build = new Build();
    build.setFinalName("final-name");
    final Model model = new Model();
    model.setBuild(build);
    configSourceStub.setMavenProject(new MavenProject(model));
    setupInterpolation();
    final Object result = new AssemblyExpressionEvaluator(configSourceStub).evaluate("assembly.${project.build.finalName}");
    assertEquals("assembly.final-name", result);
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model)

Example 18 with Build

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

the class AssemblyFormatUtilsTest method verifyOutputDirUsingMainProject.

private void verifyOutputDirUsingMainProject(final String outDir, final String finalName, final String groupId, final String artifactId, final String version, final String projectFinalName, final Properties properties, final String checkValue) throws AssemblyFormattingException {
    final MavenProject project = createProject(groupId, artifactId, version, properties);
    if (projectFinalName != null) {
        final Build build = new Build();
        build.setFinalName(projectFinalName);
        project.getModel().setBuild(build);
    }
    final MavenProject moduleProject = createProject("unknown", "unknown", "unknown", null);
    final MavenProject artifactProject = createProject("unknown", "unknown", "unknown", null);
    verifyOutputDir(outDir, finalName, project, moduleProject, artifactProject, checkValue);
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Build(org.apache.maven.model.Build)

Example 19 with Build

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

the class SiteStageDeployMojo method getStagingSiteURL.

/**
     * Extract the value of the stagingSiteURL configuration parameter of
     * maven-site-plugin for the given project.
     *
     * @param project The MavenProject, not null
     * @return The stagingSiteURL for the project, or null if it doesn't have one
     */
private String getStagingSiteURL(MavenProject project) {
    final String sitePluginKey = "org.apache.maven.plugins:maven-site-plugin";
    if (project == null) {
        return null;
    }
    final Build build = project.getBuild();
    if (build == null) {
        return null;
    }
    Map<String, Plugin> plugins = build.getPluginsAsMap();
    Plugin sitePlugin = plugins.get(sitePluginKey);
    if (sitePlugin == null) {
        final PluginManagement buildPluginManagement = build.getPluginManagement();
        if (buildPluginManagement == null) {
            return null;
        }
        plugins = buildPluginManagement.getPluginsAsMap();
        sitePlugin = plugins.get(sitePluginKey);
    }
    if (sitePlugin == null) {
        return null;
    }
    final Xpp3Dom sitePluginConfiguration = (Xpp3Dom) sitePlugin.getConfiguration();
    if (sitePluginConfiguration == null) {
        return null;
    }
    final Xpp3Dom child = sitePluginConfiguration.getChild("stagingSiteURL");
    if (child == null) {
        return null;
    } else {
        return child.getValue();
    }
}
Also used : PluginManagement(org.apache.maven.model.PluginManagement) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Build(org.apache.maven.model.Build) Plugin(org.apache.maven.model.Plugin)

Example 20 with Build

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

the class ModuleMavenProjectStub method getBuild.

/** {@inheritDoc} */
public Build getBuild() {
    Build build = new Build();
    build.setDirectory(PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi");
    build.setSourceDirectory(PlexusTestCase.getBasedir() + "/src/test/test-sources");
    build.setTestSourceDirectory(PlexusTestCase.getBasedir() + "/src/test/java");
    return build;
}
Also used : Build(org.apache.maven.model.Build)

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