Skip to content

Commit

Permalink
Add site, repository and snapshot repository
Browse files Browse the repository at this point in the history
  • Loading branch information
mnhock committed Aug 17, 2023
1 parent 7174612 commit 8551e86
Showing 1 changed file with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.model.CiManagement;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Scm;
import org.apache.maven.project.MavenProject;

public final class IntegrationsProvider extends PomProvider<Integrations> {

@Override
public Integrations provide(MavenProject project, Bom existingBom) {
List<Integration> integrations = new ArrayList<>(2);
List<Integration> integrations = new ArrayList<>(5);

scm(project, integrations);
ciManagement(project, integrations);
site(project, integrations);
repository(project, integrations);
snapshotRepository(project, integrations);

return new Integrations(integrations);
}
Expand All @@ -29,7 +33,7 @@ private static void scm(MavenProject project, List<Integration> integrations) {
integrations.add(new Integration(
"SCM",
scm.getUrl(),
null,
"The SCM (Source Control Management) of the project",
Tags.empty()));
}
}
Expand All @@ -41,11 +45,47 @@ private static void ciManagement(MavenProject project, List<Integration> integra
integrations.add(new Integration(
ciManagement.getSystem(),
ciManagement.getUrl(),
"The CI system of the project.",
Tags.empty()));
}
}

private static void site(MavenProject project, List<Integration> integrations) {
DistributionManagement distributionManagement = project.getDistributionManagement();

if (distributionManagement != null && distributionManagement.getSite() != null) {
integrations.add(new Integration(
distributionManagement.getSite().getName(),
distributionManagement.getSite().getUrl(),
null,
Tags.empty()));
}
}

private static void repository(MavenProject project, List<Integration> integrations) {
DistributionManagement distributionManagement = project.getDistributionManagement();

if (distributionManagement != null && distributionManagement.getRepository() != null) {
integrations.add(new Integration(
distributionManagement.getRepository().getName(),
distributionManagement.getRepository().getUrl(),
"Deployment remote repository for this project.",
Tags.empty()));
}
}

private static void snapshotRepository(MavenProject project, List<Integration> integrations) {
DistributionManagement distributionManagement = project.getDistributionManagement();

if (distributionManagement != null && distributionManagement.getSnapshotRepository() != null) {
integrations.add(new Integration(
distributionManagement.getSnapshotRepository().getName(),
distributionManagement.getSnapshotRepository().getUrl(),
"Deployment remote snapshot repository for this project.",
Tags.empty()));
}
}

@Override
public boolean support(Class<?> clazz) {
return Integrations.class.isAssignableFrom(clazz);
Expand Down

0 comments on commit 8551e86

Please sign in to comment.