Created
April 24, 2017 03:35
-
-
Save gabanox/a7bf1fb08f8118c50415bfe8b0dc459e to your computer and use it in GitHub Desktop.
AWS Lambda function bootstrapping for Java Maven Projects
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
#!/bin/bash | |
project="${1}Service" | |
package=$2 | |
if [ $# -lt 2 ] | |
then | |
echo "Debe especificar el nombre del proyecto y el nombre del paquete ej. [Nombre] Comercios [Paquete] com.hipermediasoft" | |
exit 1 | |
fi | |
mavenproject=$(echo $1 | awk '{print tolower($1)"-service";}' ) | |
echo "Creando estructura para proyecto Maven.." | |
mkdir $project | |
cd $project | |
mkdir -p src/main/java/ | |
mkdir -p src/test/java/ | |
cat > ./pom.xml <<DELIM | |
<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/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>doc-examples</groupId> | |
<artifactId>lambda-java-example</artifactId> | |
<packaging>jar</packaging> | |
<version>1.0-SNAPSHOT</version> | |
<name>lambda-java-example</name> | |
<properties> | |
<maven.compiler.source>1.8</maven.compiler.source> | |
<maven.compiler.target>1.8</maven.compiler.target> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>com.amazonaws</groupId> | |
<artifactId>aws-lambda-java-core</artifactId> | |
<version>1.1.0</version> | |
</dependency> | |
<dependency> | |
<groupId>com.amazonaws</groupId> | |
<artifactId>aws-lambda-java-log4j</artifactId> | |
<version>1.0.0</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>2.3</version> | |
<configuration> | |
<createDependencyReducedPom>false</createDependencyReducedPom> | |
</configuration> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> | |
DELIM | |
sed -i '' -e "s/doc-examples/$package/g" pom.xml | |
sed -i '' -e "s/lambda-java-example/$mavenproject/g" pom.xml | |
cat > ./README.md <<DELIM | |
# Project Title | |
One Paragraph of project description goes here | |
## Getting Started | |
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. | |
### Prerequisites | |
What things you need to install the software and how to install them | |
### Installing | |
A step by step series of examples that tell you have to get a development env running | |
## Running the tests | |
Explain how to run the automated tests for this system | |
### Break down into end to end tests | |
Explain what these tests test and why | |
## Deployment | |
Add additional notes about how to deploy this on a live system | |
DELIM | |
echo "¡Listo!.. ahora importe el proyecto Maven en su IDE" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment