in python/rpdk/java/codegen.py [0:0]
def init_shared(self, project, src, tst, resources):
"""Writing project configuration"""
# .gitignore
path = project.root / ".gitignore"
LOG.debug("Writing .gitignore: %s", path)
contents = resource_stream(__name__, "data/java.gitignore").read()
project.safewrite(path, contents)
# pom.xml
path = project.root / "pom.xml"
LOG.debug("Writing Maven POM: %s", path)
template = self.env.get_template("init/shared/pom.xml")
artifact_id = "{}-handler".format(project.hypenated_name)
contents = template.render(
group_id=self.package_name,
artifact_id=artifact_id,
executable=EXECUTABLE,
schema_file_name=project.schema_filename,
package_name=self.package_name,
)
project.safewrite(path, contents)
# lombok.config
path = project.root / "lombok.config"
LOG.debug("Writing Lombok Config: %s", path)
template = self.env.get_template("init/shared/lombok.config")
contents = template.render()
project.safewrite(path, contents)
LOG.debug("Writing callback context")
template = self.env.get_template("init/shared/CallbackContext.java")
path = src / "CallbackContext.java"
contents = template.render(package_name=self.package_name)
project.safewrite(path, contents)
path = src / "Configuration.java"
LOG.debug("Writing configuration: %s", path)
template = self.env.get_template("init/shared/StubConfiguration.java")
contents = template.render(
package_name=self.package_name,
schema_file_name=project.schema_filename,
pojo_name="ResourceModel",
)
project.safewrite(path, contents)
# CloudFormation/SAM template for handler lambda
path = project.root / "template.yml"
LOG.debug("Writing SAM template: %s", path)
template = self.env.get_template(
"template.yml"
) # this template is in the CLI itself
handler_params = {
"Handler": project.entrypoint,
"Runtime": project.runtime,
"CodeUri": self.CODE_URI.format(artifact_id),
}
contents = template.render(
resource_type=project.type_name,
functions={
"TypeFunction": handler_params,
"TestEntrypoint": {
**handler_params,
"Handler": project.test_entrypoint,
},
},
)
project.safewrite(path, contents)
# generate docs
path = project.root / "README.md"
LOG.debug("Writing README: %s", path)
template = self.env.get_template("init/shared/README.md")
contents = template.render(
type_name=project.type_name,
schema_path=project.schema_path,
executable=EXECUTABLE,
)
project.safewrite(path, contents)
# log4j2
path = resources / "log4j2.xml"
LOG.debug("Writing log4j2: %s", path)
contents = resource_stream(__name__, "data/log4j2.xml").read()
project.safewrite(path, contents)
self.init_handlers(project, src, tst)