Permalink
Browse files

Generating all maven examples

  • Loading branch information...
lyncodev committed Feb 10, 2017
1 parent aa68d4c commit b40b2664916044fe388324e1cb493ff888db0619
Showing with 1,839 additions and 27 deletions.
  1. +1 −0 generate-maven/dependencies.gradle
  2. +33 −0 generate-maven/generate-maven-projects.sh
  3. +163 −0 generate-maven/generate-pom.gradle
  4. +47 −25 maven-jtwig-core-simple/pom.xml
  5. +2 −2 maven-jtwig-core-simple/src/main/java/org/jtwig/example/SimpleApp.java
  6. +1 −0 maven-jtwig-core-simple/src/main/resources/templates/example.twig
  7. +48 −0 maven-jtwig-json-extension-simple/pom.xml
  8. +45 −0 maven-jtwig-json-extension-simple/src/main/java/org/jtwig/example/json/SimpleJsonApp.java
  9. +48 −0 maven-jtwig-render-extension-simple/pom.xml
  10. +13 −0 maven-jtwig-render-extension-simple/src/main/java/org/jtwig/examples/ExampleAppStarter.java
  11. +20 −0 maven-jtwig-render-extension-simple/src/main/java/org/jtwig/examples/config/JtwigConfig.java
  12. +17 −0 maven-jtwig-render-extension-simple/src/main/java/org/jtwig/examples/controller/IndexController.java
  13. +1 −0 maven-jtwig-render-extension-simple/src/main/resources/templates/hello.twig
  14. +1 −0 maven-jtwig-render-extension-simple/src/main/resources/templates/index.twig
  15. +42 −0 maven-jtwig-spaceless-extension-simple/pom.xml
  16. +16 −0 ...twig-spaceless-extension-simple/src/main/java/org/jtwig/example/spaceless/SpacelessSimpleApp.java
  17. +60 −0 maven-jtwig-spaceless-extension-simple/src/main/resources/template.twig
  18. +84 −0 maven-jtwig-spring-asset-extension-simple/pom.xml
  19. +13 −0 maven-jtwig-spring-asset-extension-simple/src/main/java/org/jtwig/example/asset/SampleWebApp.java
  20. +37 −0 ...-spring-asset-extension-simple/src/main/java/org/jtwig/example/asset/configuration/WebConfig.java
  21. +13 −0 ...ng-asset-extension-simple/src/main/java/org/jtwig/example/asset/controller/ExampleController.java
  22. +3 −0 maven-jtwig-spring-asset-extension-simple/src/main/resources/public/css/style.css
  23. +8 −0 maven-jtwig-spring-asset-extension-simple/src/main/resources/templates/index.twig
  24. +10 −0 maven-jtwig-spring-boot-angularjs2/.gitignore
  25. +19 −0 maven-jtwig-spring-boot-angularjs2/README.md
  26. +73 −0 maven-jtwig-spring-boot-angularjs2/pom.xml
  27. +16 −0 maven-jtwig-spring-boot-angularjs2/src/main/java/org/jtwig/example/AppMain.java
  28. +42 −0 maven-jtwig-spring-boot-angularjs2/src/main/java/org/jtwig/example/config/DevelopmentWebConfig.java
  29. +24 −0 maven-jtwig-spring-boot-angularjs2/src/main/java/org/jtwig/example/config/ProductionWebConfig.java
  30. +13 −0 maven-jtwig-spring-boot-angularjs2/src/main/java/org/jtwig/example/controllers/IndexController.java
  31. +3 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/.gitignore
  32. +6 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/app/app.component.ts
  33. +10 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/app/app.module.ts
  34. +6 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/app/main.ts
  35. +14 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/assets/css/styles.css
  36. +33 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/package.json
  37. +43 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/systemjs.config.js
  38. +13 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/tsconfig.json
  39. +7 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/client/typings.json
  40. +23 −0 maven-jtwig-spring-boot-angularjs2/src/main/resources/templates/index.twig.html
  41. +10 −0 maven-jtwig-spring-boot-hot-reloading-extension/.gitignore
  42. +95 −0 maven-jtwig-spring-boot-hot-reloading-extension/pom.xml
  43. +13 −0 ...jtwig-spring-boot-hot-reloading-extension/src/main/java/org/jtwig/example/boot/WebAppStarter.java
  44. +26 −0 ...ig-spring-boot-hot-reloading-extension/src/main/java/org/jtwig/example/boot/config/WebConfig.java
  45. +15 −0 ...boot-hot-reloading-extension/src/main/java/org/jtwig/example/boot/controller/IndexController.java
  46. +1 −0 maven-jtwig-spring-boot-hot-reloading-extension/src/main/resources/templates/index.twig.html
  47. +78 −0 maven-jtwig-spring-boot-simple/pom.xml
  48. +22 −0 maven-jtwig-spring-boot-simple/src/main/java/org/jtwig/boot/controller/SampleController.java
  49. +1 −0 maven-jtwig-spring-boot-simple/src/main/resources/templates/index.twig
  50. +72 −0 maven-jtwig-spring-simple/pom.xml
  51. +24 −0 maven-jtwig-spring-simple/src/main/java/org/jtwig/example/config/WebConfig.java
  52. +15 −0 maven-jtwig-spring-simple/src/main/java/org/jtwig/example/controller/IndexController.java
  53. +1 −0 maven-jtwig-spring-simple/src/main/webapp/WEB-INF/templates/index.twig.html
  54. +44 −0 maven-jtwig-spring-simple/src/main/webapp/WEB-INF/web.xml
  55. +9 −0 maven-jtwig-translate-extension-properties/README.md
  56. +48 −0 maven-jtwig-translate-extension-properties/pom.xml
  57. +37 −0 ...nslate-extension-properties/src/main/java/org/jtwig/example/translate/SimpleAppWithTranslate.java
  58. +3 −0 maven-jtwig-translate-extension-properties/src/main/resources/templates/example.twig
  59. +1 −0 maven-jtwig-translate-extension-properties/src/main/resources/translations/example.en.properties
  60. +1 −0 maven-jtwig-translate-extension-properties/src/main/resources/translations/example.it.properties
  61. +1 −0 maven-jtwig-translate-extension-properties/src/main/resources/translations/example.pt.properties
  62. +9 −0 maven-jtwig-translate-extension-xliff/README.md
  63. +54 −0 maven-jtwig-translate-extension-xliff/pom.xml
  64. +37 −0 ...g-translate-extension-xliff/src/main/java/org/jtwig/example/translate/SimpleAppWithTranslate.java
  65. +3 −0 maven-jtwig-translate-extension-xliff/src/main/resources/templates/example.twig
  66. +11 −0 maven-jtwig-translate-extension-xliff/src/main/resources/translations/example.en.xml
  67. +11 −0 maven-jtwig-translate-extension-xliff/src/main/resources/translations/example.it.xml
  68. +11 −0 maven-jtwig-translate-extension-xliff/src/main/resources/translations/example.pt.xml
  69. +7 −0 maven-jtwig-web-simple/README.md
  70. +66 −0 maven-jtwig-web-simple/pom.xml
  71. +26 −0 maven-jtwig-web-simple/src/main/java/org/jtwig/example/HelloWorldServlet.java
  72. +1 −0 maven-jtwig-web-simple/src/main/webapp/WEB-INF/templates/index.twig.html
  73. +15 −0 maven-jtwig-web-simple/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1 @@
apply from: '../generate-maven/generate-pom.gradle'
@@ -0,0 +1,33 @@
#!/bin/bash
cd ..
ROOT_DIR=`pwd`
for project in `ls | grep "gradle-"`
do
mavenReplica=`echo $project | sed 's/gradle/maven/g'`
if [ ! -d $mavenReplica ]; then
echo "Generating project $mavenReplica"
cp -r $project $mavenReplica
mv $mavenReplica/build.gradle $mavenReplica/build.gradle.bak
cat generate-maven/dependencies.gradle > $mavenReplica/build.gradle
echo "" >> $mavenReplica/build.gradle
cat $mavenReplica/build.gradle.bak >> $mavenReplica/build.gradle
rm $mavenReplica/build.gradle.bak
cd $mavenReplica
./gradlew generatePomFileForMavenProjectPublication projectPom
rm build.gradle
rm settings.gradle
rm -f gradlew
rm -f gradlew.bat
rm -rf gradle
rm -rf .gradle
rm -f *.iml
if [ -d build ]; then
rm -rf build
fi
cd $ROOT_DIR
git add $mavenReplica
fi
done
@@ -0,0 +1,163 @@
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'maven-publish'
version = releaseVersion()
group = "org.jtwig"
import org.jtwig.version.GetVersion;
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "http://dl.bintray.com/jtwig/maven"
}
}
dependencies {
classpath 'org.jtwig:jtwig-versioning:1.+'
}
}
def releaseVersion () {
def isCi = System.getenv("CI")
if ("true".equals(isCi) && "false".equals(System.getenv("TRAVIS_PULL_REQUEST")) && "master".equals(System.getenv("TRAVIS_BRANCH"))) {
return GetVersion.version(System.getenv('BINTRAY_USER'), System.getenv('BINTRAY_KEY'), rootProject.name)
} else {
return "SNAPSHOT"
}
}
configurations {
provided
}
sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
test.runtimeClasspath += configurations.provided
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar, javadocJar
}
publishing {
publications {
BintrayArchives(MavenPublication) {
from components.java
pom.withXml {
// Generate map of resolved versions
Map resolvedVersionMap = [:]
Set<ResolvedArtifact> resolvedArtifacts = configurations.compile.getResolvedConfiguration().getResolvedArtifacts()
resolvedArtifacts.addAll(configurations.testCompile.getResolvedConfiguration().getResolvedArtifacts())
resolvedArtifacts.each {
ModuleVersionIdentifier mvi = it.getModuleVersion().getId();
resolvedVersionMap.put("${mvi.getGroup()}:${mvi.getName()}", mvi.getVersion())
}
// Update dependencies with resolved versions
asNode().dependencies.first().each {
def groupId = it.get("groupId").first().value().first()
def artifactId = it.get("artifactId").first().value().first()
it.get("version").first().value = resolvedVersionMap.get("${groupId}:${artifactId}")
}
}
}
MavenProject(MavenPublication) {
from components.java
pom.withXml {
// Generate map of resolved versions
Node mainPom = asNode();
Map resolvedVersionMap = [:]
Set<ResolvedArtifact> resolvedArtifacts = configurations.compile.getResolvedConfiguration().getResolvedArtifacts()
resolvedArtifacts.addAll(configurations.testCompile.getResolvedConfiguration().getResolvedArtifacts())
resolvedArtifacts.each {
ModuleVersionIdentifier mvi = it.getModuleVersion().getId();
resolvedVersionMap.put("${mvi.getGroup()}:${mvi.getName()}", mvi.getVersion())
}
// Update dependencies with resolved versions
asNode().dependencies.first().each {
def groupId = it.get("groupId").first().value().first()
def artifactId = it.get("artifactId").first().value().first()
it.get("version").first().value = resolvedVersionMap.get("${groupId}:${artifactId}")
it.get("scope").first().value = "compile"
}
Set<ResolvedArtifact> resolvedTestArtifacts = configurations.testCompile.getResolvedConfiguration().getResolvedArtifacts()
resolvedTestArtifacts.each {
ModuleVersionIdentifier mvi = it.getModuleVersion().getId();
boolean addTestDependency = true
configurations.compile.getResolvedConfiguration().getResolvedArtifacts().each {
ModuleVersionIdentifier cmpDep = it.getModuleVersion().getId();
if (mvi.group == cmpDep.group && mvi.name == cmpDep.name) addTestDependency = false
}
if (addTestDependency) {
Node dependency = mainPom.dependencies.first().appendNode("dependency");
dependency.appendNode("groupId", mvi.getGroup())
dependency.appendNode("artifactId", mvi.getName())
dependency.appendNode("version", mvi.getVersion())
dependency.appendNode("scope", "test")
}
}
configurations.provided.getResolvedConfiguration().getResolvedArtifacts().each {
ModuleVersionIdentifier mvi = it.getModuleVersion().getId();
Node dependency = mainPom.dependencies.first().appendNode("dependency");
dependency.appendNode("groupId", mvi.getGroup())
dependency.appendNode("artifactId", mvi.getName())
dependency.appendNode("version", mvi.getVersion())
dependency.appendNode("scope", "provided")
}
Node repositories = asNode().appendNode("repositories");
project.repositories.each {
if (it.name != "MavenLocal") {
Node repository = repositories.appendNode("repository");
repository.appendNode("id", it.name);
repository.appendNode("url", it.url);
}
}
Node compilerPlugin = asNode().appendNode("build").appendNode("plugins").appendNode("plugin");
compilerPlugin.appendNode("groupId", "org.apache.maven.plugins");
compilerPlugin.appendNode("artifactId", "maven-compiler-plugin");
compilerPlugin.appendNode("version", "3.6.1");
Node compilerPluginConfig = compilerPlugin.appendNode("configuration");
compilerPluginConfig.appendNode("source", project.sourceCompatibility);
compilerPluginConfig.appendNode("target", project.targetCompatibility);
}
}
}
}
task projectPom (type: Copy) {
from "build/publications/MavenProject/pom-default.xml"
into '.'
rename { String fileName ->
fileName.replace("pom-default.xml", "pom.xml")
}
}
@@ -1,26 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jtwig.example</groupId>
<artifactId>jtwig-core-simple</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>bintray</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jtwig</groupId>
<artifactId>jtwig-core</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jtwig</groupId>
<artifactId>gradle-jtwig-core-simple</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.jtwig</groupId>
<artifactId>jtwig-core</artifactId>
<version>5.70</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.5.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>MavenRepo</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>BintrayJCenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
<repository>
<id>maven</id>
<url>http://dl.bintray.com/jtwig/maven</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -5,9 +5,9 @@
public class SimpleApp {
public static void main(String[] args) {
JtwigTemplate template = JtwigTemplate.inlineTemplate("Hello {{ var }}");
JtwigTemplate template = JtwigTemplate.classpathTemplate("templates/example.twig");
JtwigModel model = JtwigModel.newModel().with("var", "World");
template.render(model, System.out);
}
}
}
@@ -0,0 +1 @@
Hello {{ var }}
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jtwig</groupId>
<artifactId>gradle-jtwig-json-extension-simple</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.jtwig</groupId>
<artifactId>jtwig-json-extension</artifactId>
<version>1.51</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>MavenRepo</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<id>BintrayJCenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
<repository>
<id>maven</id>
<url>http://dl.bintray.com/jtwig/maven</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,45 @@
package org.jtwig.example.json;
import org.jtwig.JtwigModel;
import org.jtwig.JtwigTemplate;
import org.jtwig.environment.EnvironmentConfiguration;
import org.jtwig.environment.EnvironmentConfigurationBuilder;
import org.jtwig.json.JsonExtension;
public class SimpleJsonApp {
public static void main(String[] args) {
EnvironmentConfiguration configuration = EnvironmentConfigurationBuilder.configuration()
.extensions().add(JsonExtension.defaultJsonExtension()).and()
.build();
JtwigTemplate jtwigTemplate = JtwigTemplate.inlineTemplate("{{ json_encode(variable) }}", configuration);
JtwigModel jtwigModel = JtwigModel.newModel().with("variable", new Model(
"My Name", 30, "Committer"
));
System.out.println(jtwigTemplate.render(jtwigModel));
}
private static class Model {
private final String name;
private final int age;
private final String group;
public Model(String name, int age, String group) {
this.name = name;
this.age = age;
this.group = group;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String getGroup() {
return group;
}
}
}
Oops, something went wrong.

0 comments on commit b40b266

Please sign in to comment.