-
Notifications
You must be signed in to change notification settings - Fork 40
/
MavenComplete.txt
630 lines (230 loc) · 7.73 KB
/
MavenComplete.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
Maven:
1.Introduction
2.POM File[Project Object Model]
1.Introduction
--------------
---------------
Maven is a "Yiddish"[German lang], its meaning is "Accumulator of knowledge".
Maven is a build tool, It will perform
1. Directory structures to the applications.(Desktop/web..)
2. Downloads the required dependencies[JARS]
3. Compile the source code
4. Compile Test code.
5. packaging the applications(jar/war/ear)
6. Run applications
7. Starts the server automatically
8. Deploying the application(on server)
9. Perform Unit Testing
10. Prepare Reports and Documents
11. Undeployment of our applications
12. Stop server.
.......
.......many more jobs done by Maven
Plugins:
get dependencies
compilation
test
run
packaging
deploy
start server
reports
.....
POM:
Project configuration details are existed here like dependencies, repositories, plugins, resources..
2.
POM (Project Object Model) :
----------------------------
----------------------------
-It is heart in Maven
-It provides all the project build configurations which are required by MAVEN.
-It is an XML file, in the initial versions of Maven, POM file name is project.xml, later on pom.xml
-When we create Maven project then pom.xml file will be created automatically.
-In Maven projects, pom.xml file is able to provide no of responsibilities.
1.Project Description
2.Repository
3.Dependency Management
4.Project Inheritance
5.Build Configurations
6.Build profiles
1.Project Description
details about project name,version name, packaging type..
pom.xml
<project..>
<modelVersion>4.0.0</modelVersion>------supports Maven version 2.x and 3.x(4.0 is not a maven version)
<groupId>com.example.banking<groupId>
<artifactId>acccounts</artifactId>
<description>Application for Accounting</description>
<packaging>jar/war/ear</packaging>
---
---
</project>
groupId - is an unique id for our company i.e. package name
artifactId - Application name
2.Repository
------------
Repository is a place[location in system, in internet, a system in our company] which will provide all the dependent jar files to our application.
Repositories are able to manage all the jar files which are required by our applications.
There are three types of Repositories are existed in MAVEN.
1. Local Repository
2. Central Repository
3. Remote Repository
1. Local Repository
- It is a location in our system, which will be created by any mvn command initially.
- In our system local repository is existed at "C:\Users\sdegaonk\.m2\repository".
- When we require jar files in our application then Maven firest searches in local repository.
2. Central Repository
- It is a default repository in Maven,it exists in internet at a particular URL.
- Apache Software Foundations provides a separate central repository in the form of "https://repo.maven.apache.org/maven2/"
- We can use third party provided central repositories in Maven
1. https://mvnrepository.com
2. https://repository.jboss.org/nexus/content/groups/public/
If we want to use third party provided repositories in our applications then we must configure it in pom.xml
<project>
..
<repositories>
<repository>
<id>jboss</id>
<name>jboss repo</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
....
</project>
3.Remote Repositories
If the dependencies are not present in local repo, central repo then Maven will search for them in Remote repo
3. http://10.109.32.183:8081/nexus/content/groups/public
3. Dependency Management
- In Maven projects, dependency means that a dependent JAR file
- Maven is not giving any option to the developers to download the required JAR files, Maven will download the required jar files and Maven will keep that JAR files in our application, but we must specify which dependencies we need in our applications.
<project>
....
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.4.6-Final</version>
<scope>provided</scope>
<dependency>
<dependencies>
...
</project>
Maven is following Trasitive dependencies
A---->B----->C----->D
Scopes in Maven:
1. compile
2. provided
3. runtime
4. test
5. system
6. import
1.compile
required jar file during compile,test and run e.g. hibernate core
2.provided
required jar file during compile and test but not at run time e.g. servlet-api.jar as application server provides servlet-api.jar at runtime
3.runtime
jar available for test cases and runtime
4.test
available at test compilation and test execution e.g. junit
5.system
will not get any jar from remote repo
otherwise same as provided
6.import
import repo
4.Project Inheritance
----------------------
Getting configuration details from one POM to another.
Parent POM:
<project..>
<modelversion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
---
</project>
Child POM
<project...>
<parent>
<groupId>com.example</groupId>
<artifactId>my-parent</artifactId>
<version>1.0.0</version>
</parent>
---
</project>
5.Build Configurations
----------------------
Plugin Configurations
Resources Configurations
Plugin Configurations:
There are two types of Plugins
1. Build Plugins
2. Reporting Plugins
Build Plugins:
1. clean:
2. compiler
3. deploy
4. install
5. resources
6. ear: - create ear file for our current project
7. jar
8. war
Reporting Plugins:
1.javadoc:
2.project-info-reports
3.surfire-reports
----
----
Maven by default uses 1.5 compiler, to change compiler:
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
2.Resource Configurations
-------------------------
<project
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
6.Build profiles
----------------
Development Mode
Testing Mode
Production Mode
under resources folder db.properties
------------------------------------
jdbc.connection.url=${jdbc.connection.url}
<project>
---
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<jdbc.connection.url>jdbc:oracle:thin:@localhost:1521:XE</jdbc.connection.url>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<jdbc.connection.url>jdbc:mysql://localhost:3306/db_name</jdbc.connection.url>
</properties>
</profile>
</profiles>
</project>