org.apache.maven.model.DistributionManagement Java Examples

The following examples show how to use org.apache.maven.model.DistributionManagement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MavenUtilTest.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
private MavenProject getMavenProject() {
    MavenProject mavenProject = new MavenProject();
    mavenProject.setName("testProject");
    mavenProject.setGroupId("org.eclipse.jkube");
    mavenProject.setArtifactId("test-project");
    mavenProject.setVersion("0.1.0");
    mavenProject.setDescription("test description");
    Build build = new Build();
    build.setOutputDirectory("./target");
    build.setDirectory(".");
    mavenProject.setBuild(build);
    DistributionManagement distributionManagement = new DistributionManagement();
    Site site = new Site();
    site.setUrl("https://www.eclipse.org/jkube/");
    distributionManagement.setSite(site);
    mavenProject.setDistributionManagement(distributionManagement);
    return mavenProject;
}
 
Example #2
Source File: MavenUtil.java    From jkube with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Retrieves the URL used for documentation from the provided {@link MavenProject}.
 *
 * @param project MavenProject from which to retrieve the documentation URL
 * @return the documentation URL
 */
public static String getDocumentationUrl(MavenProject project) {
    while (project != null) {
        DistributionManagement distributionManagement = project.getDistributionManagement();
        if (distributionManagement != null) {
            Site site = distributionManagement.getSite();
            if (site != null) {
                return site.getUrl();
            }
        }
        project = project.getParent();
    }
    return null;
}
 
Example #3
Source File: DependencyNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Relocation getRelocation(org.netbeans.modules.maven.model.pom.Dependency d) {
    ProjectBuildingRequest dpbr = EmbedderFactory.getProjectEmbedder().createMavenExecutionRequest().getProjectBuildingRequest();
    dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
    dpbr.setProcessPlugins(false);
    dpbr.setResolveDependencies(false);
    ArrayList<ArtifactRepository> remoteRepos = new ArrayList<>();
    dpbr.setRemoteRepositories(remoteRepos);
    String groupId = d.getGroupId();
    String artifactId = d.getArtifactId();
    String version = d.getVersion();
    if(groupId != null && !"".equals(groupId.trim()) &&
       artifactId != null && !"".equals(artifactId.trim()) &&
       version != null && !"".equals(version.trim())) 
    {           
        MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder();
        Artifact a = embedder.createProjectArtifact(groupId, artifactId, version);
        try {
            ProjectBuildingResult r = embedder.buildProject(a, dpbr);
            DistributionManagement dm = r.getProject().getDistributionManagement();
            return dm != null ? dm.getRelocation() : null;
        } catch (ProjectBuildingException ex) {
            // just log and hope for the best ...
            Logger.getLogger(DependencyNode.class.getName()).log(Level.INFO, version, ex);                
        }
    }
    return null;
}
 
Example #4
Source File: LocationAwareMavenXpp3Writer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void writeDistributionManagement(DistributionManagement distributionManagement, String tagName, XmlSerializer serializer)
        throws java.io.IOException {
    serializer.startTag(NAMESPACE, tagName);
    flush(serializer);
    StringBuffer b = b(serializer);
    int start = b.length();

    if (distributionManagement.getRepository() != null) {
        writeDeploymentRepository((DeploymentRepository) distributionManagement.getRepository(), "repository", serializer);
    }
    if (distributionManagement.getSnapshotRepository() != null) {
        writeDeploymentRepository((DeploymentRepository) distributionManagement.getSnapshotRepository(), "snapshotRepository", serializer);
    }
    if (distributionManagement.getSite() != null) {
        writeSite((Site) distributionManagement.getSite(), "site", serializer);
    }
    if (distributionManagement.getDownloadUrl() != null) {
        writeValue(serializer, "downloadUrl", distributionManagement.getDownloadUrl(), distributionManagement);
    }
    if (distributionManagement.getRelocation() != null) {
        writeRelocation((Relocation) distributionManagement.getRelocation(), "relocation", serializer);
    }
    if (distributionManagement.getStatus() != null) {
        writeValue(serializer, "status", distributionManagement.getStatus(), distributionManagement);
    }
    serializer.endTag(NAMESPACE, tagName).flush();
    logLocation(distributionManagement, "", start, b.length());
}
 
Example #5
Source File: PomProperty.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public DistributionManagement get( Model model )
{
    return model.getDistributionManagement();
}
 
Example #6
Source File: PomProperty.java    From flatten-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void set( Model model, DistributionManagement value )
{
    model.setDistributionManagement( value );
}
 
Example #7
Source File: RetargetDeployMojo.java    From gitflow-helper-maven-plugin with Apache License 2.0 4 votes vote down vote up
@Override
protected void execute(final GitBranchInfo gitBranchInfo) throws MojoExecutionException, MojoFailureException {
    // Ensure we have a 'null' distribution management for other plugins which expect it.
    if (project.getDistributionManagement() == null) {
        project.setDistributionManagement(new DistributionManagement());
    }

    switch (gitBranchInfo.getType()) {
        case SUPPORT:
        case MASTER: {
            setTargetRelease();
            break;
        }
        case RELEASE:
        case HOTFIX: {
            setTargetStage();
            break;
        }
        case DEVELOPMENT: {
            setTargetSnapshots();
            break;
        }
        case OTHER: {
            String otherBranchesToDeploy = resolveExpression(otherDeployBranchPattern);
         if (!"".equals(otherBranchesToDeploy) && gitBranchInfo.getName().matches(otherBranchesToDeploy)) {
                setTargetSnapshots();

                project.setVersion(getAsBranchSnapshotVersion(project.getVersion(), gitBranchInfo.getName()));

                // Update any attached artifacts.
                updateArtifactVersion(project.getArtifact(), gitBranchInfo.getName());
                for (Artifact a : project.getAttachedArtifacts()) {
                    updateArtifactVersion(a, gitBranchInfo.getName());
                }

                getLog().info("Artifact versions updated with build metadata: " + getAsBranchSnapshotVersion("", gitBranchInfo.getName()));
                break;
            }
        }
        default: {
            unsetRepos();
            break;
        }
    }
}