-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
383 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...src/main/java/io/spring/start/site/extension/dependency/jte/JteGradleBuildCustomizer.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2012-2024 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 | ||
* | ||
* https://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.start.site.extension.dependency.jte; | ||
|
||
import io.spring.initializr.generator.buildsystem.Dependency; | ||
import io.spring.initializr.generator.buildsystem.gradle.GradleBuild; | ||
import io.spring.initializr.generator.spring.build.BuildCustomizer; | ||
|
||
/** | ||
* {@link BuildCustomizer} to configure the JTE Gradle plugin. | ||
* | ||
* @author Moritz Halbritter | ||
*/ | ||
class JteGradleBuildCustomizer implements BuildCustomizer<GradleBuild> { | ||
|
||
@Override | ||
public void customize(GradleBuild build) { | ||
Dependency jteStarter = build.dependencies().get("jte"); | ||
build.plugins().add("gg.jte.gradle", (plugin) -> plugin.setVersion(jteStarter.getVersion().getValue())); | ||
build.extensions().customize("jte", (jte) -> { | ||
jte.invoke("generate"); | ||
jte.attribute("binaryStaticContent", "true"); | ||
}); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...rc/main/java/io/spring/start/site/extension/dependency/jte/JteHelpDocumentCustomizer.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2012-2024 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 | ||
* | ||
* https://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.start.site.extension.dependency.jte; | ||
|
||
import java.util.Collections; | ||
|
||
import io.spring.initializr.generator.spring.documentation.HelpDocument; | ||
import io.spring.initializr.generator.spring.documentation.HelpDocumentCustomizer; | ||
|
||
/** | ||
* {@link HelpDocumentCustomizer} to add a JTE section. | ||
* | ||
* @author Moritz Halbritter | ||
*/ | ||
class JteHelpDocumentCustomizer implements HelpDocumentCustomizer { | ||
|
||
@Override | ||
public void customize(HelpDocument document) { | ||
document.addSection("jte", Collections.emptyMap()); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
.../src/main/java/io/spring/start/site/extension/dependency/jte/JteMavenBuildCustomizer.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2012-2024 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 | ||
* | ||
* https://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.start.site.extension.dependency.jte; | ||
|
||
import io.spring.initializr.generator.buildsystem.Dependency; | ||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild; | ||
import io.spring.initializr.generator.spring.build.BuildCustomizer; | ||
|
||
/** | ||
* {@link BuildCustomizer} to configure the JTE Maven plugin. | ||
* | ||
* @author Moritz Halbritter | ||
*/ | ||
class JteMavenBuildCustomizer implements BuildCustomizer<MavenBuild> { | ||
|
||
@Override | ||
public void customize(MavenBuild build) { | ||
Dependency jteStarter = build.dependencies().get("jte"); | ||
build.plugins().add("gg.jte", "jte-maven-plugin", (plugin) -> { | ||
plugin.version(jteStarter.getVersion().getValue()); | ||
plugin.execution("jte-generate", (execution) -> { | ||
execution.phase("generate-sources"); | ||
execution.goal("generate"); | ||
execution.configuration((configuration) -> { | ||
configuration.add("sourceDirectory", "${project.basedir}/src/main/jte"); | ||
configuration.add("contentType", "Html"); | ||
configuration.add("binaryStaticContent", "true"); | ||
configuration.add("targetResourceDirectory", "${project.build.outputDirectory}"); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
} |
90 changes: 90 additions & 0 deletions
90
...java/io/spring/start/site/extension/dependency/jte/JteProjectGenerationConfiguration.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2012-2024 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 | ||
* | ||
* https://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.start.site.extension.dependency.jte; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import io.spring.initializr.generator.buildsystem.Build; | ||
import io.spring.initializr.generator.buildsystem.Dependency; | ||
import io.spring.initializr.generator.buildsystem.gradle.GradleBuildSystem; | ||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem; | ||
import io.spring.initializr.generator.condition.ConditionalOnBuildSystem; | ||
import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; | ||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration; | ||
import io.spring.initializr.generator.project.contributor.ProjectContributor; | ||
import io.spring.initializr.generator.spring.build.BuildCustomizer; | ||
import io.spring.initializr.generator.spring.properties.ApplicationPropertiesCustomizer; | ||
import io.spring.initializr.generator.spring.scm.git.GitIgnoreCustomizer; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
|
||
/** | ||
* {@link ProjectGenerationConfiguration} for JTE. | ||
* | ||
* @author Moritz Halbritter | ||
*/ | ||
@ProjectGenerationConfiguration | ||
@ConditionalOnRequestedDependency("jte") | ||
class JteProjectGenerationConfiguration { | ||
|
||
@Bean | ||
ProjectContributor jteTemplateDirectoryProjectContributor() { | ||
return (projectRoot) -> { | ||
Path templatesDirectory = projectRoot.resolve("src/main/jte"); | ||
Files.createDirectories(templatesDirectory); | ||
}; | ||
} | ||
|
||
@Bean | ||
ApplicationPropertiesCustomizer jteApplicationPropertiesCustomizer() { | ||
return (properties) -> properties.add("gg.jte.development-mode", true); | ||
} | ||
|
||
@Bean | ||
BuildCustomizer<Build> jteBuildCustomizer() { | ||
// https://github.com/casid/jte/issues/381 | ||
return (build) -> { | ||
Dependency jteStarter = build.dependencies().get("jte"); | ||
build.dependencies() | ||
.add("jte-core", Dependency.withCoordinates("gg.jte", "jte").version(jteStarter.getVersion()).build()); | ||
}; | ||
} | ||
|
||
@Bean | ||
GitIgnoreCustomizer jteGitIgnoreCustomizer() { | ||
return (gitignore) -> gitignore.addSectionIfAbsent("JTE").add("/jte-classes/"); | ||
} | ||
|
||
@Bean | ||
JteHelpDocumentCustomizer jteHelpDocumentCustomizer() { | ||
return new JteHelpDocumentCustomizer(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnBuildSystem(GradleBuildSystem.ID) | ||
JteGradleBuildCustomizer jteGradleBuildCustomizer() { | ||
return new JteGradleBuildCustomizer(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnBuildSystem(MavenBuildSystem.ID) | ||
JteMavenBuildCustomizer jteMavenBuildCustomizer() { | ||
return new JteMavenBuildCustomizer(); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
start-site/src/main/java/io/spring/start/site/extension/dependency/jte/package-info.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2012-2019 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
/** | ||
* Extensions for generation of projects that depend on JTE. | ||
*/ | ||
package io.spring.start.site.extension.dependency.jte; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## JTE | ||
|
||
This project has been configured to use [JTE precompiled templates](https://jte.gg/pre-compiling/). | ||
|
||
However, to ease development, those are not enabled out of the box. | ||
For production deployments, you should remove | ||
|
||
```properties | ||
gg.jte.development-mode=true | ||
``` | ||
|
||
from the `application.properties` file and set | ||
|
||
```properties | ||
gg.jte.use-precompiled-templates=true | ||
``` | ||
|
||
instead. | ||
For more details, please take a look at [the official documentation](https://jte.gg/spring-boot-starter-3/). |
Oops, something went wrong.