| 
									
										
										
										
											2017-11-23 01:19:42 +06:00
										 |  |  | allprojects { | 
					
						
							|  |  |  |     repositories { | 
					
						
							|  |  |  |         jcenter()  | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | subprojects { | 
					
						
							| 
									
										
										
										
											2017-01-11 17:40:04 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:42 +06:00
										 |  |  |     version = '1.0' | 
					
						
							| 
									
										
										
										
											2017-01-11 17:40:04 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:42 +06:00
										 |  |  | apply plugin: 'eclipse' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | println 'This will be executed during the configuration phase.' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task configured { | 
					
						
							|  |  |  |     println 'This will also be executed during the configuration phase.' | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-11 17:40:04 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:42 +06:00
										 |  |  | task execFirstTest { | 
					
						
							|  |  |  |     doLast { | 
					
						
							|  |  |  |         println 'This will be executed during the execution phase.' | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-01-11 17:40:04 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:42 +06:00
										 |  |  | task execSecondTest { | 
					
						
							|  |  |  |     doFirst { | 
					
						
							|  |  |  |       println 'This will be executed first during the execution phase.' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     doLast { | 
					
						
							|  |  |  |       println 'This will be executed last during the execution phase.' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     println 'This will be executed during the configuration phase as well.' | 
					
						
							| 
									
										
										
										
											2017-01-11 17:40:04 -03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-01 06:40:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | task welcome { | 
					
						
							|  |  |  |     doLast { | 
					
						
							|  |  |  |         println 'Welcome on the Baeldung!' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task welcomeWithGroup { | 
					
						
							|  |  |  |     group 'Sample category' | 
					
						
							|  |  |  |     doLast { | 
					
						
							|  |  |  |         println 'Welcome on the Baeldung!' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task welcomeWithGroupAndDescription { | 
					
						
							|  |  |  |     group 'Sample category' | 
					
						
							|  |  |  |     description 'Tasks which shows welcome message' | 
					
						
							|  |  |  |     doLast { | 
					
						
							|  |  |  |         println 'Welcome on the Baeldung!' | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class PrintToolVersionTask extends DefaultTask { | 
					
						
							|  |  |  |     String tool | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     @TaskAction | 
					
						
							|  |  |  |     void printToolVersion() { | 
					
						
							|  |  |  |         switch (tool) { | 
					
						
							|  |  |  |             case 'java': | 
					
						
							|  |  |  |                 println System.getProperty("java.version") | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             case 'groovy': | 
					
						
							|  |  |  |                 println GroovySystem.version | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 throw new IllegalArgumentException("Unknown tool") | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task printJavaVersion(type : PrintToolVersionTask) { | 
					
						
							|  |  |  |     tool 'java' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task printGroovyVersion(type : PrintToolVersionTask) { | 
					
						
							|  |  |  |     tool 'groovy' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import com.baeldung.PrintToolVersionBuildSrcTask | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task printJavaVersionBuildSrc(type : PrintToolVersionBuildSrcTask) { | 
					
						
							|  |  |  |     tool 'java' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task printGroovyVersionBuildSrc(type : PrintToolVersionBuildSrcTask) { | 
					
						
							|  |  |  |     tool 'groovy' | 
					
						
							|  |  |  | } |