├── .gitignore ├── src ├── it │ ├── default │ │ ├── tscfg │ │ │ ├── test.conf │ │ │ └── example.spec.conf │ │ ├── verify.groovy │ │ └── pom.xml │ └── settings.xml ├── main │ └── java │ │ └── tscfg │ │ └── TscfgJavaGeneratorMojo.java └── test │ └── java │ └── tscfg │ └── TscfgJavaGeneratorMojoTest.java ├── .travis.yml ├── RELEASE.md ├── README.md ├── pom.xml └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | target/ -------------------------------------------------------------------------------- /src/it/default/tscfg/test.conf: -------------------------------------------------------------------------------- 1 | test { 2 | property1: "a" 3 | property4: 10 minutes 4 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | script: mvn verify -P !build-extras -B 4 | 5 | cache: 6 | directories: 7 | - ~/.m2/repository 8 | -------------------------------------------------------------------------------- /src/it/default/tscfg/example.spec.conf: -------------------------------------------------------------------------------- 1 | test { 2 | property1: "string" 3 | property2: "string?" 4 | property3: "int | 3" 5 | property4: "duration" 6 | } -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Release this plugin 2 | 3 | * prepare release on branch release/v$VERSION 4 | * update version in pom file 5 | * update version in README.md 6 | * usage 7 | * build yourself 8 | * Merge all code to master -------------------------------------------------------------------------------- /src/it/default/verify.groovy: -------------------------------------------------------------------------------- 1 | import static org.assertj.core.api.Assertions.assertThat 2 | import static org.assertj.core.api.Assertions.contentOf 3 | 4 | def generatedClass = new File((File) basedir, "target/generated-sources/tscfg/com/github/timvlaer/generated/config/TestConfig.java") 5 | assertThat(generatedClass).exists() 6 | 7 | assertThat(contentOf(generatedClass)) 8 | .contains("String getProperty1()") 9 | .contains("Optional getProperty2()") 10 | .contains("int getProperty3()") 11 | .contains("Duration getProperty4()") 12 | 13 | return true -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | it-repo 6 | 7 | true 8 | 9 | 10 | 11 | local.central 12 | @localRepositoryUrl@ 13 | 14 | true 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | local.central 24 | @localRepositoryUrl@ 25 | 26 | true 27 | 28 | 29 | true 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/it/default/pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.github.timvlaer 7 | tscfg-maven-plugin-test 8 | 0.0.0 9 | 10 | 11 | 1.8 12 | 1.8 13 | UTF-8 14 | 15 | 16 | 17 | 18 | com.typesafe 19 | config 20 | 1.3.3 21 | 22 | 23 | 24 | 25 | 26 | 27 | com.github.timvlaer 28 | tscfg-maven-plugin 29 | @project.version@ 30 | 31 | tscfg/example.spec.conf 32 | com.github.timvlaer.generated.config 33 | TestConfig 34 | true 35 | true 36 | true 37 | 38 | 39 | 40 | tscfg-sources 41 | 42 | generate-config-class 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://www.travis-ci.org/timvlaer/tscfg-maven-plugin.svg?branch=master)](https://www.travis-ci.org/timvlaer/tscfg-maven-plugin) 2 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.timvlaer/tscfg-maven-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.timvlaer/tscfg-maven-plugin) 4 | 5 | # tscfg-maven-plugin 6 | 7 | Maven plugin that generates the boiler-plate for a [Typesafe Config](https://github.com/typesafehub/config) properties file 8 | using the excellent [tscfg](https://github.com/carueda/tscfg) library by @carueda. 9 | 10 | This plugin takes a configuration file (templateFile) and generates objects to hold your configuration. 11 | 12 | ## Usage 13 | ```xml 14 | 15 | com.github.timvlaer 16 | tscfg-maven-plugin 17 | 1.0.0 18 | 19 | config-spec/service.spec.conf 20 | com.sentiance.service.config 21 | ServiceConfig 22 | true 23 | false 24 | true 25 | 26 | 27 | 28 | tscfg-sources 29 | 30 | generate-config-class 31 | 32 | 33 | 34 | 35 | ``` 36 | 37 | To compile the generated code, add the [Lightbend Config](https://github.com/lightbend/config) dependency to your project: 38 | ```xml 39 | 40 | com.typesafe 41 | config 42 | 1.3.4 43 | 44 | ``` 45 | 46 | ## Configuration 47 | * templateFile: typesafe configuration template file 48 | * className: the name of the generated config class 49 | * packageName: the package of the generated config class 50 | * outputDirectory: the output directory for the generated class, default is `target/generated-sources/tscfg/` 51 | * generateGetters: (true|false) generate getters for configuration 52 | * useOptionals: (true|false) use java8 Optional object for optional fields 53 | * useDurations: (true|false) if true, properties of type `duration` will be of type `java.time.Duration` in the generated code. If false, it will be a long. 54 | * allRequired: (true|false) if true, optional tags are ignored and every property in the config file is required. Defaults to false. 55 | 56 | ## Current limitations 57 | * This plugin currently only generates Java code. 58 | * This plugin always generates java classes for Java 8 and above. 59 | Open a ticket or PR if you'd like to change the above. 60 | 61 | ## Build the plugin yourself 62 | * `git clone https://github.com/timvlaer/tscfg-maven-plugin.git` 63 | * `cd tscfg-maven-plugin` 64 | * Update the `` in the pom.xml file, e.g. `2.0.0-custom-SNAPSHOT` 65 | * `mvn clean install` 66 | * Configure your project's pom to depend on your version of the plugin (e.g. `2.0.0-custom-SNAPSHOT`.) 67 | -------------------------------------------------------------------------------- /src/main/java/tscfg/TscfgJavaGeneratorMojo.java: -------------------------------------------------------------------------------- 1 | package tscfg; 2 | 3 | import org.apache.maven.plugin.AbstractMojo; 4 | import org.apache.maven.plugin.MojoExecutionException; 5 | import org.apache.maven.plugins.annotations.Execute; 6 | import org.apache.maven.plugins.annotations.LifecyclePhase; 7 | import org.apache.maven.plugins.annotations.Mojo; 8 | import org.apache.maven.plugins.annotations.Parameter; 9 | import org.apache.maven.project.MavenProject; 10 | import tscfg.generators.GenOpts; 11 | import tscfg.generators.GenResult; 12 | import tscfg.generators.Generator; 13 | import tscfg.generators.java.JavaGen; 14 | 15 | import java.io.File; 16 | import java.io.IOException; 17 | import java.nio.charset.Charset; 18 | import java.nio.file.Files; 19 | import java.nio.file.Path; 20 | import java.nio.file.Paths; 21 | 22 | import static java.nio.file.StandardOpenOption.*; 23 | 24 | @Mojo(name = "generate-config-class", defaultPhase = LifecyclePhase.GENERATE_SOURCES) 25 | @Execute(phase = LifecyclePhase.GENERATE_SOURCES, goal = "generate-config-class") 26 | public class TscfgJavaGeneratorMojo extends AbstractMojo { 27 | 28 | static final Charset UTF_8 = Charset.forName("UTF-8"); 29 | private static final String PACKAGE_SEPARATOR = "."; 30 | private static final String JAVA_FILE_EXTENSION = ".java"; 31 | 32 | @Parameter(required = true) 33 | private File templateFile; 34 | 35 | @Parameter(required = true) 36 | private String packageName; 37 | 38 | @Parameter(required = true) 39 | private String className; 40 | 41 | @Parameter(defaultValue = "${project.build.directory}/generated-sources/tscfg/") 42 | private String outputDirectory; 43 | 44 | @Parameter(defaultValue = "${project}", required = true, readonly = true) 45 | private MavenProject project; 46 | 47 | @Parameter(defaultValue = "false") 48 | private boolean generateGetters; 49 | 50 | @Parameter(defaultValue = "false") 51 | private boolean useOptionals; 52 | 53 | @Parameter(defaultValue = "true") 54 | private boolean useDurations; 55 | 56 | @Parameter(defaultValue = "false") 57 | private boolean allRequired; 58 | 59 | public void execute() throws MojoExecutionException { 60 | GenResult generatorResult = generateJavaCodeForTemplate(templateFile); 61 | writeGeneratedCodeToJavaFile(generatorResult.code()); 62 | 63 | getLog().debug("Adding " + outputDirectory + " as source root in the maven project."); 64 | project.addCompileSourceRoot(outputDirectory); 65 | } 66 | 67 | private GenResult generateJavaCodeForTemplate(File templateFile) throws MojoExecutionException { 68 | boolean useBackticks = false; 69 | boolean generateJava7Code = false; 70 | boolean generateScala12Code = true; 71 | GenOpts genOpts = new GenOpts( 72 | packageName, 73 | className, 74 | allRequired, 75 | generateJava7Code, 76 | generateScala12Code, 77 | useBackticks, 78 | generateGetters, 79 | useOptionals, 80 | useDurations 81 | ); 82 | Generator tscfgGenerator = new JavaGen(genOpts); 83 | return tscfgGenerator.generate(ModelBuilder.apply(readTscfgTemplate(templateFile), allRequired).objectType()); 84 | } 85 | 86 | private String readTscfgTemplate(File templateFile) throws MojoExecutionException { 87 | try { 88 | return Files.readString(templateFile.toPath(), UTF_8); 89 | } catch (IOException e) { 90 | throw new MojoExecutionException("Failed to read template file (" + templateFile + "): " + e.getClass() + ": " + e.getMessage()); 91 | } 92 | } 93 | 94 | private void writeGeneratedCodeToJavaFile(String javaClassCode) throws MojoExecutionException { 95 | Path javaClassFile = assembleJavaFilePath(); 96 | try { 97 | createParentDirsIfNecessary(javaClassFile); 98 | Files.write(javaClassFile, javaClassCode.getBytes(UTF_8), CREATE, WRITE, TRUNCATE_EXISTING); 99 | getLog().debug("Wrote generated java config file to " + javaClassFile); 100 | } catch (IOException e) { 101 | throw new MojoExecutionException("Failed to write file (" + javaClassFile + "). " + 102 | e.getClass() + ": " + e.getMessage()); 103 | } 104 | } 105 | 106 | private Path assembleJavaFilePath() { 107 | String packageDirectoryPath = packageName.replace(PACKAGE_SEPARATOR, File.separator); 108 | String javaFileName = className + JAVA_FILE_EXTENSION; 109 | return Paths.get(outputDirectory, packageDirectoryPath, javaFileName); 110 | } 111 | 112 | private void createParentDirsIfNecessary(Path outputFile) throws IOException { 113 | Path parentDir = outputFile.getParent(); 114 | if (!Files.exists(parentDir)) { 115 | Files.createDirectories(parentDir); 116 | } 117 | } 118 | 119 | void setTemplateFile(File templateFile) { 120 | this.templateFile = templateFile; 121 | } 122 | 123 | void setPackageName(String packageName) { 124 | this.packageName = packageName; 125 | } 126 | 127 | void setClassName(String className) { 128 | this.className = className; 129 | } 130 | 131 | void setOutputDirectory(String outputDirectory) { 132 | this.outputDirectory = outputDirectory; 133 | } 134 | 135 | void setProject(MavenProject project) { 136 | this.project = project; 137 | } 138 | 139 | void setGenerateGetters(boolean generateGetters) { 140 | this.generateGetters = generateGetters; 141 | } 142 | 143 | void setUseOptionals(boolean useOptionals) { 144 | this.useOptionals = useOptionals; 145 | } 146 | 147 | void setUseDurations(boolean useDurations) { 148 | this.useDurations = useDurations; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/test/java/tscfg/TscfgJavaGeneratorMojoTest.java: -------------------------------------------------------------------------------- 1 | package tscfg; 2 | 3 | import org.apache.maven.plugin.MojoExecutionException; 4 | import org.apache.maven.project.MavenProject; 5 | import org.junit.Before; 6 | import org.junit.Rule; 7 | import org.junit.Test; 8 | import org.junit.rules.ExpectedException; 9 | import org.junit.rules.TemporaryFolder; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.Mockito; 13 | import org.mockito.junit.MockitoJUnitRunner; 14 | 15 | import java.io.File; 16 | import java.io.IOException; 17 | import java.nio.file.Files; 18 | import java.nio.file.StandardOpenOption; 19 | 20 | import static java.nio.file.StandardOpenOption.*; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.junit.Assert.assertTrue; 23 | import static tscfg.TscfgJavaGeneratorMojo.UTF_8; 24 | 25 | @RunWith(MockitoJUnitRunner.class) 26 | public class TscfgJavaGeneratorMojoTest { 27 | 28 | private TscfgJavaGeneratorMojo mojo = new TscfgJavaGeneratorMojo(); 29 | 30 | @Rule 31 | public TemporaryFolder templateFolder = new TemporaryFolder(); 32 | @Rule 33 | public TemporaryFolder outputFolder = new TemporaryFolder(); 34 | @Rule 35 | public ExpectedException expectedException = ExpectedException.none(); 36 | 37 | @Mock 38 | private MavenProject project; 39 | 40 | @Before 41 | public void setUp() throws Exception { 42 | mojo.setProject(project); 43 | 44 | File templateFile = templateFolder.newFile("test.spec.conf"); 45 | Files.write(templateFile.toPath(), templateContent(), CREATE, WRITE, TRUNCATE_EXISTING); 46 | mojo.setTemplateFile(templateFile); 47 | 48 | mojo.setOutputDirectory(outputFolder.getRoot().getAbsolutePath()); 49 | mojo.setClassName("TestConfig"); 50 | mojo.setPackageName("com.test.config"); 51 | } 52 | 53 | @Test 54 | public void execute() throws Exception { 55 | mojo.execute(); 56 | 57 | Mockito.verify(project).addCompileSourceRoot(outputFolder.getRoot().getAbsolutePath()); 58 | 59 | File resultFile = new File(outputFolder.getRoot(), "com/test/config/TestConfig.java"); 60 | assertThat(resultFile).exists(); 61 | 62 | String result = new String(Files.readAllBytes(resultFile.toPath()), UTF_8); 63 | assertThat(result).contains("package com.test.config;"); 64 | assertThat(result).contains("public class TestConfig {"); 65 | } 66 | 67 | @Test 68 | public void executeFailsIfTemplateFileDoesNotExist() throws MojoExecutionException { 69 | expectedException.expect(MojoExecutionException.class); 70 | expectedException.expectMessage("Failed to read template file"); 71 | 72 | mojo.setTemplateFile(new File(templateFolder.getRoot(), "unexisting.conf")); 73 | mojo.execute(); 74 | } 75 | 76 | @Test 77 | public void generateGetters() throws Exception { 78 | mojo.setGenerateGetters(true); 79 | 80 | String result = executeMojo(); 81 | assertThat(result).contains("int getPort()"); 82 | assertThat(result).contains("String getServer()"); 83 | assertThat(result).contains("long getLength()"); 84 | } 85 | 86 | @Test 87 | public void useOptionals() throws Exception { 88 | mojo.setUseOptionals(true); 89 | 90 | String result = executeMojo(); 91 | assertThat(result).contains("java.util.Optional server"); 92 | } 93 | 94 | @Test 95 | public void useDurations() throws Exception { 96 | mojo.setUseDurations(true); 97 | 98 | String result = executeMojo(); 99 | assertThat(result).contains("public final java.time.Duration length;"); 100 | } 101 | 102 | @Test 103 | public void executeFullyOverwritesGeneratedFile() throws Exception { 104 | mojo.execute(); 105 | 106 | File resultFile = new File(outputFolder.getRoot(), "com/test/config/TestConfig.java"); 107 | Files.write(resultFile.toPath(), "extra".getBytes(UTF_8), StandardOpenOption.APPEND); 108 | 109 | mojo.execute(); 110 | 111 | String result = new String(Files.readAllBytes(resultFile.toPath()), UTF_8); 112 | assertThat(result).doesNotContain("extra"); 113 | } 114 | 115 | @Test 116 | public void executeFailsIfGeneratedCodeCannotBeWritten() throws Exception { 117 | mojo.execute(); 118 | 119 | expectedException.expect(MojoExecutionException.class); 120 | expectedException.expectMessage("Failed to write file"); 121 | 122 | File resultFile = new File(outputFolder.getRoot(), "com/test/config/TestConfig.java"); 123 | assertTrue(resultFile.setWritable(false)); 124 | mojo.execute(); 125 | } 126 | 127 | @Test 128 | public void templateFileDoesNotExists() throws Exception { 129 | expectedException.expect(MojoExecutionException.class); 130 | expectedException.expectMessage("Failed to read template file ("); 131 | expectedException.expectMessage("unexisting.spec.conf):"); 132 | 133 | mojo.setTemplateFile(new File(outputFolder.getRoot(), "unexisting.spec.conf")); 134 | mojo.execute(); 135 | } 136 | 137 | private byte[] templateContent() { 138 | String templateConfig = "test {\n" + 139 | " server: \"string?\"\n" + 140 | " port: \"int\"\n" + 141 | " length: \"duration\"\n" + 142 | "}"; 143 | return templateConfig.getBytes(UTF_8); 144 | } 145 | 146 | private String executeMojo() throws MojoExecutionException, IOException { 147 | mojo.execute(); 148 | 149 | File resultFile = new File(outputFolder.getRoot(), "com/test/config/TestConfig.java"); 150 | assertThat(resultFile).exists(); 151 | 152 | return new String(Files.readAllBytes(resultFile.toPath()), UTF_8); 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | com.github.timvlaer 7 | tscfg-maven-plugin 8 | 1.0.0 9 | maven-plugin 10 | 11 | tscfg Maven Plugin 12 | Maven plugin that generates the boiler-plate Java code for a Typesafe Config properties file using tscfg. 13 | https://github.com/timvlaer/tscfg-maven-plugin 14 | 15 | 16 | 17 | timvlaer 18 | Tim Van Laer 19 | timvanlaer@gmail.com 20 | 21 | 22 | 23 | 24 | 25 | Apache 2.0 26 | http://www.opensource.org/licenses/Apache-2.0 27 | repo 28 | 29 | 30 | 31 | 32 | scm:git@github.com:timvlaer/tscfg-maven-plugin.git 33 | https://github.com/timvlaer/tscfg-maven-plugin 34 | 35 | 36 | 37 | 3.6.3 38 | 39 | 0.9.981 40 | 41 | 42 | 43 | 44 | org.apache.maven 45 | maven-plugin-api 46 | ${maven.version} 47 | provided 48 | 49 | 50 | org.apache.maven.plugin-tools 51 | maven-plugin-annotations 52 | 3.5.2 53 | provided 54 | 55 | 56 | org.apache.maven 57 | maven-project 58 | 2.2.1 59 | provided 60 | 61 | 62 | 63 | com.github.carueda 64 | tscfg_2.13 65 | ${tscfg.version} 66 | 67 | 68 | 69 | junit 70 | junit 71 | 4.13.1 72 | test 73 | 74 | 75 | org.mockito 76 | mockito-core 77 | 2.21.0 78 | test 79 | 80 | 81 | org.assertj 82 | assertj-core 83 | 3.10.0 84 | test 85 | 86 | 87 | 88 | org.apache.maven 89 | maven-core 90 | ${maven.version} 91 | test 92 | 93 | 94 | org.apache.maven.shared 95 | maven-verifier 96 | 1.6 97 | test 98 | 99 | 100 | 101 | 102 | 103 | 104 | org.apache.maven.plugins 105 | maven-compiler-plugin 106 | 3.8.1 107 | 108 | 11 109 | 11 110 | 111 | 112 | 113 | 114 | org.apache.maven.plugins 115 | maven-plugin-plugin 116 | 3.6.0 117 | 118 | 119 | 120 | org.sonatype.plugins 121 | nexus-staging-maven-plugin 122 | 1.6.8 123 | true 124 | 125 | ossrh 126 | https://oss.sonatype.org/ 127 | false 128 | 129 | 130 | 131 | 132 | maven-invoker-plugin 133 | 3.2.0 134 | 135 | 136 | install 137 | 138 | verify 139 | true 140 | 141 | 142 | 143 | integration-test 144 | 145 | install 146 | run 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | ossrh 157 | https://oss.sonatype.org/content/repositories/snapshots 158 | 159 | 160 | ossrh 161 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 162 | 163 | 164 | 165 | 166 | 167 | sign 168 | 169 | 170 | 171 | org.apache.maven.plugins 172 | maven-gpg-plugin 173 | 1.6 174 | 175 | 176 | sign-artifacts 177 | verify 178 | 179 | sign 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | build-extras 190 | 191 | true 192 | 193 | 194 | 195 | 196 | org.apache.maven.plugins 197 | maven-source-plugin 198 | 3.0.1 199 | 200 | 201 | attach-sources 202 | 203 | jar-no-fork 204 | 205 | 206 | 207 | 208 | 209 | org.apache.maven.plugins 210 | maven-javadoc-plugin 211 | 3.2.0 212 | 213 | 214 | attach-javadocs 215 | 216 | jar 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. --------------------------------------------------------------------------------