{"id":19143241,"url":"https://github.com/devenes/maven-server-automation","last_synced_at":"2026-04-09T20:35:41.524Z","repository":{"id":107131277,"uuid":"495509002","full_name":"devenes/maven-server-automation","owner":"devenes","description":"Purpose of the this hands-on project is to have understanding about how to use Maven with Java as a build tool.","archived":false,"fork":false,"pushed_at":"2022-05-26T19:27:31.000Z","size":6060,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T15:44:14.433Z","etag":null,"topics":["aws","cloudformation","java","jdk","maven","maven-plugin","maven-pom","maven-repository","terraform"],"latest_commit_sha":null,"homepage":"https://devenes.github.io/maven-server-automation/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devenes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-23T17:27:51.000Z","updated_at":"2022-06-02T11:46:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"de0cbd16-ff46-4d2f-875c-8185ce48a7be","html_url":"https://github.com/devenes/maven-server-automation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fmaven-server-automation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fmaven-server-automation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fmaven-server-automation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devenes%2Fmaven-server-automation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devenes","download_url":"https://codeload.github.com/devenes/maven-server-automation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240224156,"owners_count":19767709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cloudformation","java","jdk","maven","maven-plugin","maven-pom","maven-repository","terraform"],"created_at":"2024-11-09T07:30:04.786Z","updated_at":"2026-04-09T20:35:36.476Z","avatar_url":"https://github.com/devenes.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\" id=\"top\"\u003e \n  \u003cimg src=\"maven.jpg\" alt=\"Maven Server Automation\" /\u003e\n\n  \u0026#xa0;\n\n  \u003c!-- \u003ca href=\"https://mavenserverautomation.netlify.app\"\u003eDemo\u003c/a\u003e --\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003eMaven As a Build Tool\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cdiv align=\"center\"\u003e\n  \n  [![pages-build-deployment](https://github.com/devenes/maven-server-automation/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/devenes/maven-server-automation/actions/workflows/pages/pages-build-deployment)  \u003cimg alt=\"Github top language\" src=\"https://img.shields.io/github/languages/top/devenes/maven-server-automation?color=purple\"\u003e \u003cimg alt=\"Github language count\" src=\"https://img.shields.io/github/languages/count/devenes/maven-server-automation?color=purple\"\u003e  \u003cimg alt=\"Repository size\" src=\"https://img.shields.io/github/repo-size/devenes/maven-server-automation?color=purple\"\u003e  \u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/devenes/maven-server-automation?color=purple\"\u003e\n\n  \u003c!-- \u003cimg alt=\"Github issues\" src=\"https://img.shields.io/github/issues/devenes/maven-server-automation?color=purple\" /\u003e --\u003e\n\n  \u003c!-- \u003cimg alt=\"Github forks\" src=\"https://img.shields.io/github/forks/devenes/maven-server-automation?color=purple\" /\u003e --\u003e\n\n  \u003c!-- \u003cimg alt=\"Github stars\" src=\"https://img.shields.io/github/stars/devenes/maven-server-automation?color=purple\" /\u003e --\u003e\n\n\u003c/div\u003e\n\u003c/p\u003e\n\n\u003c!-- Status --\u003e\n\n\u003c!-- \u003ch4 align=\"center\"\u003e \n\t🚧  Maven Server Automation 🚀 Under construction...  🚧\n\u003c/h4\u003e \n\n\u003chr\u003e --\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#dart-about\"\u003eAbout\u003c/a\u003e \u0026#xa0; | \u0026#xa0; \n  \u003ca href=\"#rocket-technologies\"\u003eTechnologies\u003c/a\u003e \u0026#xa0; | \u0026#xa0;\n  \u003ca href=\"#white_check_mark-requirements\"\u003eRequirements\u003c/a\u003e \u0026#xa0; | \u0026#xa0;\n  \u003ca href=\"#checkered_flag-starting\"\u003eStarting\u003c/a\u003e \u0026#xa0; | \u0026#xa0;\n  \u003ca href=\"#memo-license\"\u003eLicense\u003c/a\u003e \u0026#xa0; | \u0026#xa0;\n  \u003ca href=\"https://github.com/devenes\" target=\"_blank\"\u003eAuthor\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n## :dart: About ##\n\nPurpose of the this hands-on project is to have the understanding about how to use Maven with Java as a build tool.\n\n## :rocket: Technologies ##\n\nThe following tools were used in this project:\n\n- [Java](https://www.java.com/en/download/)\n- [Maven](https://maven.apache.org/)\n- [Git](https://git-scm.com/)\n- [Terraform](https://www.terraform.io/)\n\n## :white_check_mark: Requirements ##\n\nBefore starting :checkered_flag:, you need to have [Java](https://www.java.com/), [Maven](https://maven.apache.org/) and [Git](https://git-scm.com/) installed.\n\n## :checkered_flag: Starting ##\n\n\n\n### Learning Outcomes\n\nAt the end of the this hands-on training, you will be able to;\n\n- install Maven and Java-11 on Amazon Linux 2 EC2 instance\n\n- explain various build phases of a Java Application\n\n- use Maven's clean, compile, package, install and site commands\n\n\n## Outline\n\n- Part 1 - Launch Amazon Linux 2 EC2 Instance with Cloudformation Template\n\n- Part 2 - Generate a Java application using Maven's Archetype Plugin\n\n- Part 3 - Run Maven Commands\n\n\n## Part 1 - Launch Amazon Linux 2 EC2 Instance and Connect with SSH\n\n- Launch an EC2 instance using ```maven-java-template.yml``` file located in this folder.\n    - This template will create an EC2 instance with Java-11 and Maven.\n\n- Connect to your instance with SSH.\n\n- Check if you can see the Maven's binary directory under ```/home/ec2-user/```.\n\n- Run the command below to check if Java is available.\n\n```bash\njava -version\n```\n\n- Cat ```~/.bash_profile``` file to check if Maven's path is correctly transferred. If not paste the necessary lines manually.\n\n```\n# Append the lines below into ~/.bash_profile file by making necessary changes.\nM2_HOME=/home/ec2-user/\u003capache-maven-directory-with-its-version\u003e\nexport PATH=$PATH:$M2_HOME/bin\n```\n\n- Run the command below to check if mvn commands are available.\n\n```bash\nmvn --version\n```\n\n- If not, run the command below and wait for the EC2 machine to get ready.\n\n```bash\nsudo reboot\n```\n\n## Part 2 - Generate a Java application using Maven's Archetype Plugin\n\n- Run the command below to produce an outline of a Java project with Maven.\n\n```bash\nmvn archetype:generate -DgroupId=com.devenes.maven -DartifactId=maven-experiment -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false\n```\n\n- Cd into the project folder.\n\n- Run the command below to be able to use tree command.\n\n```bash\nsudo yum install -y tree\n```\n\n- Run the command below to show the directory structure of the project.\n\n```bash\ntree\n```\n\n- Go into the folder where App.java resides and ```cat``` the auto generated ```hello world``` application in Java.\n\n- Replace the content of the App.java file with the content of the App.java file in this repo.\n\n- Go into the project's root folder.\n\n- Replace the content of the ```pom.xml``` file with the content of the pom.xml file in this repo.\n\n- Since we've install Java-11 on the EC2 machine, uncomment the ```properties``` tag of the new pom.xml file.\n\n- Explain that the ```maven.compiler.source``` property specifies the version of source code accepted and the ```maven.compiler.target``` generates class files compatible with the specified version of JVM.\n\n- Explain that ```dependencyManagement``` section in the pom file will import multiple dependencies with compatible versions.  \n\n\n## Part 3 - Run Maven Commands\n\n\n\u003e### mvn compile\n \n- Run the command below.\n\n```bash\nmvn compile\n```\n\n- Go into the folder ```\u003cproject-root\u003e/target/classes/``` and show the class file.\n\n- Run the command below to show how to test a Maven project.\n\n\n\u003e### mvn clean test\n\n```bash\nmvn clean test\n```\n\n- Show that there is a new folder named ```target``` in the project root. \n\n- inspect the target folder with tree command.\n\n- Show the content of the file ```\u003cproject-root\u003e/target/surefire-report/com.devenes.maven.AppTest.txt``` as the output of the test.\n\n\u003e### mvn package\n\n- Run the command below.\n\n```bash\nmvn clean package\n```\n\n- Go into the folder ```\u003cproject-root\u003e/target/``` and show the ```maven-experiment-1.0-SNAPSHOT.jar``` file as the output of the ```mvn package``` command.\n\n- Run the command below to start the application.\n\n```bash\njava -jar maven-experiment-1.0-SNAPSHOT.jar\n```\n\n- Explain the error in the standard output. \n    - Maven's jar file is not an executable jar file. The jar file does not have both the ```Main Class``` and the necessary packages to run the application. \n\n- Add the plugin below to the pom file and run ```mvn clean package``` command again.\n\n```xml\n\u003cbuild\u003e\n  \u003cplugins\u003e\n    \u003cplugin\u003e\n      \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n      \u003cartifactId\u003emaven-assembly-plugin\u003c/artifactId\u003e\n      \u003cexecutions\u003e\n          \u003cexecution\u003e\n              \u003cphase\u003epackage\u003c/phase\u003e\n              \u003cgoals\u003e\n                  \u003cgoal\u003esingle\u003c/goal\u003e\n              \u003c/goals\u003e\n              \u003cconfiguration\u003e\n                  \u003carchive\u003e\n                  \u003cmanifest\u003e\n                      \u003cmainClass\u003e\n                          com.devenes.maven.App\n                      \u003c/mainClass\u003e\n                  \u003c/manifest\u003e\n                  \u003c/archive\u003e\n                  \u003cdescriptorRefs\u003e\n                      \u003cdescriptorRef\u003ejar-with-dependencies\u003c/descriptorRef\u003e\n                  \u003c/descriptorRefs\u003e\n              \u003c/configuration\u003e\n          \u003c/execution\u003e\n      \u003c/executions\u003e\n    \u003c/plugin\u003e\n  \u003c/plugins\u003e\n\u003c/build\u003e\n```\n\n```bash\nmvn clean package\n```\n\n\u003e### Run The Application\n\n- Now, open up a fresh terminal on your local computer and run the command below.\n\n```bash\nscp -i \u003cpath-to-your-pem-file\u003e -r \u003cpath-to-your-home-directory\u003e/.aws ec2-user@\u003cIP-of-your-instance\u003e:/home/ec2-user/\n```\n\n- Check if the the credentials are transferred to EC2 instance.\n\n- Go into your target folder.\n\n- Run the command below to start the application. This time we are running the executable jar file with suffix ```jar-with-dependencies```.\n\n```bash\njava -jar maven-experiment-1.0-SNAPSHOT-jar-with-dependencies.jar\n```\n\n- Explain what the application does in the background.\n    - Note that to be able see the object and the S3 bucket, we should comment the lines 142 and 150.\n\n\u003e### mvn install\n\n- Run the command below to install our own package into .m2 folder.\n\n```bash\nmvn install\n```\n\n- Go into ```~/.m2/repository``` folder and show where our package is installed.\n\n\u003e### mvn site\n\n- Add two more plugins to run the command ```mvn site```\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-site-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e3.7.1\u003c/version\u003e\n\u003c/plugin\u003e\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-project-info-reports-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e3.0.0\u003c/version\u003e\n\u003c/plugin\u003e\n```\n\n- Run the command below.\n\n```bash\nmvn clean site\n```\n\n- Show the output ```site``` directory under target directory.\n\n- Run the command below to install Apache Server.\n\n```bash\nsudo yum install -y httpd\nsudo systemctl start httpd\nsudo systemctl enable httpd\n```\n\n- Run the command below to copy the contents of the site folder under ```/var/www/html``` folder.\n\n```bash\nsudo cp -a site/. /var/www/html\n```\n\nor start the server with the command below.\n\n```bash\npython3 -m http.server     \n```\n\n## Run the Application on AWS\n\n```java\njava -jar maven-experiment-1.0-SNAPSHOT-jar-with-dependencies.jar \n```\n\n- Output:\n\n\n```bash\n===========================================\nGetting Started with Amazon S3\n===========================================\n\nCreating bucket my-first-s3-bucket-d7b250f9-be4d-4534-bc22-9c32d83dc3b1\n\nListing buckets\n - cf-templates-1qe8zcgon5jhvi2-us-east-1\n - my-first-s3-bucket-d7b250f9-be4d-4534-bc22-9c32d83dc3b1\n - terraform-12321env-bucket\n\nUploading a new object to S3 from a file\n\nMay 26, 2022 2:19:30 PM com.amazonaws.util.Base64 warn\nWARNING: JAXB is unavailable. Will fallback to SDK implementation which may be less performant.If you are using Java 9+, you will need to include javax.xml.bind:jaxb-api as a dependency.\nDownloading an object\nContent-Type: text/plain\n    abcdefghijklmnopqrstuvwxyz\n    01234567890112345678901234\n    !@#$%^\u0026*()-=[]{};':',.\u003c\u003e/?\n    01234567890112345678901234\n    abcdefghijklmnopqrstuvwxyz\n\nListing objects\n - MyObjectKey  (size = 135)\n\nDeleting an object\n\nDeleting bucket my-first-s3-bucket-d7b250f9-be4d-4534-bc22-9c32d83dc3b1\n```\n\n## :memo: License ##\n\nThis project is under license from Apache. For more details, see the [LICENSE](LICENSE) file.\n\n\nMade with :heart: by \u003ca href=\"https://github.com/devenes\" target=\"_blank\"\u003edevenes\u003c/a\u003e\n\n\u0026#xa0;\n\n\u003ca href=\"#top\"\u003eBack to top\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevenes%2Fmaven-server-automation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevenes%2Fmaven-server-automation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevenes%2Fmaven-server-automation/lists"}