mirror of
https://gitee.com/dcren/initializr.git
synced 2025-04-05 17:38:06 +08:00
Harmonize metadata term
This commit is contained in:
parent
ad4ed895d9
commit
0a4f631b3a
20
README.adoc
20
README.adoc
@ -10,7 +10,7 @@ link:https://start.spring.io[]. It provides a simple web UI to configure the pro
|
|||||||
to generate and endpoints that you can use via plain HTTP.
|
to generate and endpoints that you can use via plain HTTP.
|
||||||
|
|
||||||
Spring Initializr also exposes an endpoint that serves its
|
Spring Initializr also exposes an endpoint that serves its
|
||||||
{wiki}/Metadata-format[meta-data] in a well-known format to allow third-party
|
{wiki}/Metadata-format[metadata] in a well-known format to allow third-party
|
||||||
clients to provide the necessary assistance.
|
clients to provide the necessary assistance.
|
||||||
|
|
||||||
Finally, Initializr offers a configuration structure to define all the aspects related
|
Finally, Initializr offers a configuration structure to define all the aspects related
|
||||||
@ -74,10 +74,10 @@ an invalid character for a java identifier, `Application` is used as fallback.
|
|||||||
** The `artifactId` attribute not only defines the identifier of the project in the build but
|
** The `artifactId` attribute not only defines the identifier of the project in the build but
|
||||||
also the name of the generated archive.
|
also the name of the generated archive.
|
||||||
* `dependencies` (or `style`): the identifiers of the dependencies to add to the project. Such
|
* `dependencies` (or `style`): the identifiers of the dependencies to add to the project. Such
|
||||||
identifiers are defined through configuration and are exposed in the <<meta-data,meta-data>>.
|
identifiers are defined through configuration and are exposed in the <<metadata,metadata>>.
|
||||||
* `type`: the _kind_ of project to generate (e.g. `maven-project`). Again, each service
|
* `type`: the _kind_ of project to generate (e.g. `maven-project`). Again, each service
|
||||||
exposes an arbitrary number of supported types and these are available in the
|
exposes an arbitrary number of supported types and these are available in the
|
||||||
<<meta-data,meta-data>>.
|
<<metadata,metadata>>.
|
||||||
* `javaVersion`: the language level (e.g. `1.8`).
|
* `javaVersion`: the language level (e.g. `1.8`).
|
||||||
* `bootVersion`: the Spring Boot version to use (e.g. `1.2.0.RELEASE`).
|
* `bootVersion`: the Spring Boot version to use (e.g. `1.2.0.RELEASE`).
|
||||||
* `language`: the programming language to use (e.g. `java`).
|
* `language`: the programming language to use (e.g. `java`).
|
||||||
@ -118,11 +118,11 @@ The following hashbang parameters are supported: `type`, `groupId`, `artifactId`
|
|||||||
`description`, `packageName`, `packaging`, `javaVersion` and `language`. Review the section
|
`description`, `packageName`, `packaging`, `javaVersion` and `language`. Review the section
|
||||||
above for a description of each of them.
|
above for a description of each of them.
|
||||||
|
|
||||||
[[meta-data]]
|
[[metadata]]
|
||||||
== Service meta-data
|
== Service metadata
|
||||||
|
|
||||||
The service meta-data is used by the web UI and is exposed to ease the creation of
|
The service metadata is used by the web UI and is exposed to ease the creation of
|
||||||
third-party clients. You can grab the meta-data by _curling_ the root
|
third-party clients. You can grab the metadata by _curling_ the root
|
||||||
|
|
||||||
[source,bash]
|
[source,bash]
|
||||||
----
|
----
|
||||||
@ -132,15 +132,15 @@ $ curl -H 'Accept: application/json' https://start.spring.io
|
|||||||
NOTE: As stated above, if you use `curl` without an accept header, you'll retrieve a human
|
NOTE: As stated above, if you use `curl` without an accept header, you'll retrieve a human
|
||||||
readable text version of the metadata. `HTTPie` is also supported.
|
readable text version of the metadata. `HTTPie` is also supported.
|
||||||
|
|
||||||
The meta-data basically lists the _capabilities_ of the service, that is the available
|
The metadata basically lists the _capabilities_ of the service, that is the available
|
||||||
options for all request parameters (`dependencies`, `type`, `bootVersion`, etc.) The web
|
options for all request parameters (`dependencies`, `type`, `bootVersion`, etc.) The web
|
||||||
UI uses that information to initialize the select options and the tree of available
|
UI uses that information to initialize the select options and the tree of available
|
||||||
dependencies.
|
dependencies.
|
||||||
|
|
||||||
The meta-data also lists the default values for simple _text_ parameter (i.e. the default
|
The metadata also lists the default values for simple _text_ parameter (i.e. the default
|
||||||
`name` for the project).
|
`name` for the project).
|
||||||
|
|
||||||
NOTE: More details about the structure of the meta-data are {wiki}/Metadata-format[available
|
NOTE: More details about the structure of the metadata are {wiki}/Metadata-format[available
|
||||||
on the wiki].
|
on the wiki].
|
||||||
|
|
||||||
== Running your own instance
|
== Running your own instance
|
||||||
|
@ -19,7 +19,7 @@ package io.spring.initializr.metadata
|
|||||||
import io.spring.initializr.util.Version
|
import io.spring.initializr.util.Version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dependency meta-data for a given spring boot {@link Version}.
|
* Dependency metadata for a given spring boot {@link Version}.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
|
@ -117,7 +117,7 @@ class InitializrConfiguration {
|
|||||||
String artifactRepository = 'https://repo.spring.io/release/'
|
String artifactRepository = 'https://repo.spring.io/release/'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The meta-data url of the Spring Boot project.
|
* The metadata url of the Spring Boot project.
|
||||||
*/
|
*/
|
||||||
String springBootMetadataUrl = 'https://spring.io/project_metadata/spring-boot'
|
String springBootMetadataUrl = 'https://spring.io/project_metadata/spring-boot'
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class InitializrMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the meta-data.
|
* Validate the metadata.
|
||||||
*/
|
*/
|
||||||
void validate() {
|
void validate() {
|
||||||
this.configuration.validate()
|
this.configuration.validate()
|
||||||
|
@ -25,7 +25,7 @@ import org.springframework.core.io.Resource
|
|||||||
import org.springframework.util.StreamUtils
|
import org.springframework.util.StreamUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder for {@link InitializrMetadata}. Allows to read meta-data from any arbitrary resource,
|
* Builder for {@link InitializrMetadata}. Allows to read metadata from any arbitrary resource,
|
||||||
* including remote URLs.
|
* including remote URLs.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
@ -81,7 +81,7 @@ class InitializrMetadataBuilder {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a {@link InitializrMetadata} to be merged with other content.
|
* Add a {@link InitializrMetadata} to be merged with other content.
|
||||||
* @param resource a resource to a json document describing the meta-data to include
|
* @param resource a resource to a json document describing the metadata to include
|
||||||
*/
|
*/
|
||||||
InitializrMetadataBuilder withInitializrMetadata(Resource resource) {
|
InitializrMetadataBuilder withInitializrMetadata(Resource resource) {
|
||||||
withCustomizer(new ResourceInitializrMetadataCustomizer(resource))
|
withCustomizer(new ResourceInitializrMetadataCustomizer(resource))
|
||||||
@ -174,7 +174,7 @@ class InitializrMetadataBuilder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void customize(InitializrMetadata metadata) {
|
void customize(InitializrMetadata metadata) {
|
||||||
log.info("Loading initializr meta-data from $resource")
|
log.info("Loading initializr metadata from $resource")
|
||||||
def content = StreamUtils.copyToString(resource.getInputStream(), UTF_8)
|
def content = StreamUtils.copyToString(resource.getInputStream(), UTF_8)
|
||||||
ObjectMapper objectMapper = new ObjectMapper()
|
ObjectMapper objectMapper = new ObjectMapper()
|
||||||
def anotherMetadata = objectMapper.readValue(content, InitializrMetadata)
|
def anotherMetadata = objectMapper.readValue(content, InitializrMetadata)
|
||||||
|
@ -66,37 +66,37 @@ class InitializrProperties extends InitializrConfiguration {
|
|||||||
final List<DefaultMetadataElement> bootVersions = []
|
final List<DefaultMetadataElement> bootVersions = []
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GroupId meta-data.
|
* GroupId metadata.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
final SimpleElement groupId = new SimpleElement(value: 'com.example')
|
final SimpleElement groupId = new SimpleElement(value: 'com.example')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArtifactId meta-data.
|
* ArtifactId metadata.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
final SimpleElement artifactId = new SimpleElement()
|
final SimpleElement artifactId = new SimpleElement()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version meta-data.
|
* Version metadata.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
final SimpleElement version = new SimpleElement(value: '0.0.1-SNAPSHOT')
|
final SimpleElement version = new SimpleElement(value: '0.0.1-SNAPSHOT')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name meta-data.
|
* Name metadata.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
final SimpleElement name = new SimpleElement(value: 'demo')
|
final SimpleElement name = new SimpleElement(value: 'demo')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description meta-data.
|
* Description metadata.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
final SimpleElement description = new SimpleElement(value: 'Demo project for Spring Boot')
|
final SimpleElement description = new SimpleElement(value: 'Demo project for Spring Boot')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package name meta-data.
|
* Package name metadata.
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
final SimpleElement packageName = new SimpleElement()
|
final SimpleElement packageName = new SimpleElement()
|
||||||
|
@ -20,7 +20,7 @@ import groovy.transform.AutoClone
|
|||||||
import groovy.transform.AutoCloneStyle
|
import groovy.transform.AutoCloneStyle
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic meta-data element
|
* A basic metadata element
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
|
@ -227,7 +227,7 @@
|
|||||||
{
|
{
|
||||||
"name": "initializr.env.spring-boot-metadata-url",
|
"name": "initializr.env.spring-boot-metadata-url",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"description": "The meta-data url of the Spring Boot project.",
|
"description": "The metadata url of the Spring Boot project.",
|
||||||
"sourceType": "io.spring.initializr.metadata.InitializrConfiguration$Env",
|
"sourceType": "io.spring.initializr.metadata.InitializrConfiguration$Env",
|
||||||
"defaultValue": "https://spring.io/project_metadata/spring-boot"
|
"defaultValue": "https://spring.io/project_metadata/spring-boot"
|
||||||
},
|
},
|
||||||
|
@ -77,10 +77,10 @@ class InitializrMetadataBuilderTests {
|
|||||||
assertEquals 2, metadata.packagings.content.size()
|
assertEquals 2, metadata.packagings.content.size()
|
||||||
assertEquals 1, metadata.javaVersions.content.size()
|
assertEquals 1, metadata.javaVersions.content.size()
|
||||||
assertEquals 3, metadata.languages.content.size()
|
assertEquals 3, metadata.languages.content.size()
|
||||||
assertEquals 'meta-data-merge', metadata.name.content
|
assertEquals 'metadata-merge', metadata.name.content
|
||||||
assertEquals 'Demo project for meta-data merge', metadata.description.content
|
assertEquals 'Demo project for metadata merge', metadata.description.content
|
||||||
assertEquals 'org.acme', metadata.groupId.content
|
assertEquals 'org.acme', metadata.groupId.content
|
||||||
assertEquals 'meta-data', metadata.artifactId.content
|
assertEquals 'metadata', metadata.artifactId.content
|
||||||
assertEquals '1.0.0-SNAPSHOT', metadata.version.content
|
assertEquals '1.0.0-SNAPSHOT', metadata.version.content
|
||||||
assertEquals 'org.acme.demo', metadata.packageName.content
|
assertEquals 'org.acme.demo', metadata.packageName.content
|
||||||
}
|
}
|
||||||
|
@ -113,13 +113,13 @@
|
|||||||
"id": "name",
|
"id": "name",
|
||||||
"type": "TEXT",
|
"type": "TEXT",
|
||||||
"description": null,
|
"description": null,
|
||||||
"content": "meta-data-merge"
|
"content": "metadata-merge"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"id": "description",
|
"id": "description",
|
||||||
"type": "TEXT",
|
"type": "TEXT",
|
||||||
"description": null,
|
"description": null,
|
||||||
"content": "Demo project for meta-data merge"
|
"content": "Demo project for metadata merge"
|
||||||
},
|
},
|
||||||
"groupId": {
|
"groupId": {
|
||||||
"id": "groupId",
|
"id": "groupId",
|
||||||
@ -131,7 +131,7 @@
|
|||||||
"id": "artifactId",
|
"id": "artifactId",
|
||||||
"type": "TEXT",
|
"type": "TEXT",
|
||||||
"description": null,
|
"description": null,
|
||||||
"content": "meta-data"
|
"content": "metadata"
|
||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"id": "version",
|
"id": "version",
|
||||||
|
@ -27,7 +27,7 @@ import io.spring.initializr.metadata.DependencyMetadata
|
|||||||
interface DependencyMetadataJsonMapper {
|
interface DependencyMetadataJsonMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a json representation of the specified meta-data.
|
* Write a json representation of the specified metadata.
|
||||||
*/
|
*/
|
||||||
String write(DependencyMetadata metadata);
|
String write(DependencyMetadata metadata);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import io.spring.initializr.metadata.DependencyMetadata
|
|||||||
import io.spring.initializr.metadata.Repository
|
import io.spring.initializr.metadata.Repository
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link DependencyMetadataJsonMapper} handling the meta-data format for v2.1.
|
* A {@link DependencyMetadataJsonMapper} handling the metadata format for v2.1.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
|
@ -27,7 +27,7 @@ import io.spring.initializr.metadata.InitializrMetadata
|
|||||||
interface InitializrMetadataJsonMapper {
|
interface InitializrMetadataJsonMapper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a json representation of the specified meta-data.
|
* Write a json representation of the specified metadata.
|
||||||
*/
|
*/
|
||||||
String write(InitializrMetadata metadata, String appUrl);
|
String write(InitializrMetadata metadata, String appUrl);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import org.springframework.hateoas.TemplateVariables
|
|||||||
import org.springframework.hateoas.UriTemplate
|
import org.springframework.hateoas.UriTemplate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link InitializrMetadataJsonMapper} handling the meta-data format for v2.1
|
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.1
|
||||||
* <p>
|
* <p>
|
||||||
* Version 2.1 brings the 'versionRange' attribute for a dependency to restrict
|
* Version 2.1 brings the 'versionRange' attribute for a dependency to restrict
|
||||||
* the Spring Boot versions that can be used against it. That version also adds
|
* the Spring Boot versions that can be used against it. That version also adds
|
||||||
|
@ -25,7 +25,7 @@ import org.springframework.hateoas.TemplateVariables
|
|||||||
import org.springframework.hateoas.UriTemplate
|
import org.springframework.hateoas.UriTemplate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link InitializrMetadataJsonMapper} handling the meta-data format for v2.
|
* A {@link InitializrMetadataJsonMapper} handling the metadata format for v2.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
|
@ -19,7 +19,7 @@ package io.spring.initializr.web.mapper
|
|||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the supported meta-data version.
|
* Define the supported metadata version.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
@ -34,7 +34,7 @@ enum InitializrMetadataVersion {
|
|||||||
/**
|
/**
|
||||||
* Add 'versionRange' attribute to any dependency to specify which
|
* Add 'versionRange' attribute to any dependency to specify which
|
||||||
* Spring Boot versions are compatible with it. Also provide a
|
* Spring Boot versions are compatible with it. Also provide a
|
||||||
* separate 'dependencies' endpoint to query dependencies meta-data.
|
* separate 'dependencies' endpoint to query dependencies metadata.
|
||||||
*/
|
*/
|
||||||
V2_1('application/vnd.initializr.v2.1+json')
|
V2_1('application/vnd.initializr.v2.1+json')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user