Devops Lab Program 1 18
Devops Lab Program 1 18
VTU LAB
STEP1:Install Eclipse using this link
https://www.eclipse.org/downloads/
ENTERPRISE JAVA AND WEB DEVELOPERS
PROGRAMS
PROGRAMS
LA
Then set environment variable path both user and system
■ Have a JDK installation on your system. Either set the JAVA_HOME
environment variable pointing to your JDK installation or have the
B
java executable on your PATH.
VTb) To install apache maven pls go to link as in below and download zip file
of bin
https://maven.apache.org/download.cgi
U
c) To unzip the Source zip archive
Run in Windows cmd prompt
unzip apache-maven-3.9.9-bin.zip
If don't want to run directly extract the file to Program Files
PROGRAMS
d) Setup a PATH in environmental settings
LA
B
VT
f) TO INSTALL GRADLE FOR WINDOWS follow procedure as in below
1. Create a new directory C:\Gradle with File Explorer.
2. Open a second File Explorer window and go to the directory where the
U
Gradle distribution was downloaded. Double-click the ZIP archive to
expose the content. Drag the content folder gradle-8.12.1 to your newly
created C:\Gradle folder.
Alternatively you can unpack the Gradle distribution ZIP into C:\
Gradle using an archiver tool of your choice or run command with
path folder where the folder is created.
unzip apache-maven-3.9.9-bin.zip
Or can directly extract the zip file.
3. Configure your system environment
4. Finally type the command gradle –v to check if the gradle is installed.
VTU LAB
PROGRAMS
PROGRAM-2
Working with Maven: Creating a Maven Project, Understanding the POM
File, Dependency Management and Plugins
STEP3:In Screen shown above, click near the entry place of Filter and type
“apache” or select catalog as Internal
We want a simple maven JAR based application. So, we will choose
the “maven-archetype-quickstart” artifact to create the project.
VTU LAB
PROGRAMS
STEP4: Enter
Group Id:com.program2.maven
Artifact Id:program2-example-jar
Keep snapshot as it is
Package:com.program2.maven.program2
VTU LAB
PROGRAMS
VTU LAB
package: com.program2.maven.program2
PROGRAMS
VTU LAB
PROGRAMS
PROGRAMS
Description
What is groupId in maven ?
groupId identifies a particular project uniquely across all projects, so we should follow a
LA
naming convention. A very simple and commonly used way of doing this is to use the
reverse of your domain, i.e. com.javarewind.maven.
A good way of maintaining the integrity of groupId is to use the project structure. In
case the project consists of multiple modules then every module should append an
B
identifier to the parent groupId.
i.e. com.javarewind.maven, com.java rewind.spring, com.javarewind.struts .. etc.
VT
artifactId is the name of war file without version, if you are creating it by yourself you
are free to took any name of your choice in lower case and without any strange
symbol. But if this is a third party jar than we have to take the name of the jar as
U
suggested by its distribution.
—
HOW POM.XML LOOKS IS AS IN SCREEN BELOW
VTU LAB
PROGRAMS
PROGRAM3:Working with Gradle: Setting Up a Gradle Project,
Understanding Build Scripts (Groovy and Kotlin DSL), Dependency
Management and Task Automation
VTU LAB
Then first make a new directory the command is
mkdir pgm3
PROGRAMS
For changing to a current directory the command is
cd pgm3
Now run
gradle init
After execution of command the screen shows as in below where we opt
for build type select as 1
After selecting Implementation language it will ask for Java version and
project name
VTU LAB
After providing version and project name
Select application structure as Single application structure and Domain
Specific Language as Kotlin
PROGRAMS
It will take atleast 3-5 minutes to run the configuration script we have set
through steps finally the output be as in below If You want to see the
structure of an application run the command as tree
VTU LAB
PROGRAMS
STEP3: Type command gradle init it will ask for migrate from maven to
gradle type yes
PROGRAMS
STEP6:
Type the
command gradle
build
Now to get exact program output of our java file Locate to build gradle File from ur
local repository and Copy paste the code as in below shown in red color
plugins {
id("java-library")
VTU LAB
id("maven-publish")
id("application")
}
PROGRAMS
application {
mainClass.set("com.pgm4.test.App") // Use .set() for properties
}
repositories {
mavenCentral()
// Uncomment if you need to publish locally
// mavenLocal()
}
dependencies {
testImplementation("junit:junit:4.13.2") // Use Kotlin syntax for dependencies
}
group = "com.pgm4.test"
version = "0.0.1-SNAPSHOT"
description = "pgm4"
java.sourceCompatibility = JavaVersion.VERSION_11 // Consider upgrading
publishing
{ publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
tasks.withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
}
VTU LAB
AFTER DOING ALL CHANGES FINAL STEP
To run
commands gradle
clean build gradle
PROGRAMS
run
You will get Output as
Hello World! Welcome to pgm4