Skip to content

Commit

Permalink
Merge pull request #205 from jonesbusy/feature/more-flags
Browse files Browse the repository at this point in the history
Restore license ans developer tags
  • Loading branch information
jonesbusy authored Aug 20, 2024
2 parents 1cdedfa + 449e29c commit aa30530
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,47 @@ public enum MetadataFlag {
.allMatch(url -> url.startsWith("https"));
}
return false;
}),

/**
* If the license block is set
*/
LICENSE_SET(tag -> {
if ("licenses".equals(tag.getName())) {
return tag.getChildren().stream()
.filter(c -> "license".equals(c.getName()))
.map(Xml.Tag.class::cast)
.map(r -> r.getChildValue("name").orElseThrow())
.findAny()
.isPresent();
}
return false;
}),

/**
* If the develop block is set
*/
DEVELOPER_SET(tag -> {
if ("developers".equals(tag.getName())) {
return tag.getChildren().stream()
.filter(c -> "developer".equals(c.getName()))
.map(Xml.Tag.class::cast)
.map(r -> r.getChildValue("id").orElseThrow())
.findAny()
.isPresent();
}
return false;
});

/**
* Function to check if the flag is applicable for the given XML tag
*/
private Predicate<Xml.Tag> isApplicable;
private final Predicate<Xml.Tag> isApplicable;

/**
* Constructor
* @param isApplicable Predicate to check if the flag is applicable for the given XML tag
*/
MetadataFlag(Predicate<Xml.Tag> isApplicable) {
this.isApplicable = isApplicable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ void testPlugin() throws Exception {
<packaging>hpi</packaging>
<name>GitLab Plugin</name>
<url>https://github.com/jenkinsci/${project.artifactId}</url>
<developers>
<developer>
<id>john.doe</id>
<name>John Doe</name>
<email>john.doe@example.com</email>
</developer>
</developers>
<licenses>
<license>
<name>GPL v2.0 License</name>
Expand Down Expand Up @@ -145,6 +151,8 @@ void testPlugin() throws Exception {
assertNotNull(pluginMetadata.getProperties().get("java.level"));
assertTrue(pluginMetadata.hasFlag(MetadataFlag.SCM_HTTPS));
assertTrue(pluginMetadata.hasFlag(MetadataFlag.MAVEN_REPOSITORIES_HTTPS));
assertTrue(pluginMetadata.hasFlag(MetadataFlag.LICENSE_SET));
assertTrue(pluginMetadata.hasFlag(MetadataFlag.DEVELOPER_SET));
Map<String, String> properties = pluginMetadata.getProperties();
assertNotNull(properties);
assertEquals(10, properties.size());
Expand Down

0 comments on commit aa30530

Please sign in to comment.