Add optional links to a dependency

See gh-163
This commit is contained in:
Dave Syer 2016-08-24 11:58:39 +01:00 committed by Stephane Nicoll
parent 9c7bdcc5bf
commit d8a1927a36
5 changed files with 44 additions and 1 deletions

View File

@ -84,13 +84,15 @@ class Dependency extends MetadataElement {
@JsonIgnore @JsonIgnore
String versionRequirement String versionRequirement
private VersionRange range private VersionRange range
String bom String bom
String repository String repository
List<Link> links = []
@JsonInclude(JsonInclude.Include.NON_DEFAULT) @JsonInclude(JsonInclude.Include.NON_DEFAULT)
int weight int weight

View File

@ -0,0 +1,31 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.spring.initializr.metadata
/**
* @author Dave Syer
*
*/
class Link {
String id
URL url
String description
}

View File

@ -57,6 +57,9 @@ class DependencyMetadataV21JsonMapper implements DependencyMetadataJsonMapper {
if (dep.repository) { if (dep.repository) {
result.repository = dep.repository result.repository = dep.repository
} }
if (dep.links) {
result.links = dep.links
}
result result
} }

View File

@ -52,6 +52,9 @@ class InitializrMetadataV21JsonMapper extends InitializrMetadataV2JsonMapper {
if (dependency.versionRange) { if (dependency.versionRange) {
content['versionRange'] = dependency.versionRange content['versionRange'] = dependency.versionRange
} }
if (dependency.links) {
content.links = dependency.links
}
content content
} }

View File

@ -82,6 +82,10 @@ class UiController {
if (d.description) { if (d.description) {
result.description = d.description result.description = d.description
} }
if (d.links) {
result.url = d.links[0].url
result.links = d.links
}
if (d.weight) { if (d.weight) {
result.weight = d.weight result.weight = d.weight
} }