Last active
August 29, 2015 10:05
-
-
Save nobeans/9ebc732d72ffcd82b185 to your computer and use it in GitHub Desktop.
JavaScript to create a command line of CLI at Spring Initializr site (https://start.spring.io/ )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var groupId = document.getElementById('groupId').value; | |
var artifactId = document.getElementById('artifactId').value; | |
var name = document.getElementById('name').value; | |
var description = document.getElementById('description').value; | |
var packageName = document.getElementById('packageName').value; | |
var type = document.getElementById('type').value; | |
var packaging = document.getElementById('packaging').value; | |
var javaVersion = document.getElementById('javaVersion').value; | |
var language = document.getElementById('language').value; | |
var bootVersion = document.getElementById('bootVersion').value; | |
var dependencyNames = [] | |
var dependencies = document.querySelectorAll("#dependencies input:checked"); | |
for (var i = 0; i < dependencies.length; i++) { | |
dependencyNames.push(dependencies[i].value); | |
} | |
var commands = ['spring', 'init']; | |
commands.push('--groupId=' + groupId); | |
commands.push('--artifactId=' + artifactId); | |
commands.push('--name=' + name); | |
//commands.push('--description="' + description + '"'); // to avoid the issue: https://github.com/spring-projects/spring-boot/issues/3841 | |
//commands.push('--packageName=' + packageName); // not supported by cli yet: 3.0.0.M4 | |
commands.push('--type=' + type); | |
commands.push('--packaging=' + packaging); | |
commands.push('--java-version=' + javaVersion); | |
commands.push('--language=' + language); | |
commands.push('--boot-version=' + bootVersion); | |
commands.push('--dependencies=' + dependencyNames.join(',')); | |
prompt("Copy to clipboard", commands.join(' ')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make a bookmark with a name like
To Spring Boot CLI
at your browser.(This is minified by http://syncer.jp/minifier.)
Visit the site of https://start.spring.io/
Input and check the form for your requirement.
Use the bookmarklet.
Copy the command line text of the dialog.
Paste to your console in a directory as the root of your new project. (Requires spring-boot-cli. Please install it by GVM, etc.
cf. http://docs.spring.io/autorepo/docs/spring-boot/1.2.0.M2/reference/htmlsingle/#getting-started-installing-the-cli