11// Verify custom package parameter works correctly
22def projectDir = new File (basedir, " project/custom-pkg-app" )
33
4- assert projectDir. exists()
5-
6- // Check POM has correct groupId and artifactId
7- def pomFile = new File (projectDir, " pom.xml" )
8- def pomContent = pomFile. text
9- assert pomContent. contains(" <groupId>com.mycompany</groupId>" )
10- assert pomContent. contains(" <artifactId>custom-pkg-app</artifactId>" )
11- assert pomContent. contains(" <version>1.5.0</version>" )
12- assert pomContent. contains(" <maven.compiler.release>17</maven.compiler.release>" )
13-
14- // Check that package structure uses custom package, NOT groupId
15- assert new File (projectDir, " src/main/java/org/custompackage/application/App.java" ). exists()
16- assert new File (projectDir, " src/test/java/org/custompackage/application/AppTest.java" ). exists()
17-
18- // Should NOT have the groupId package structure
19- assert ! new File (projectDir, " src/main/java/com/mycompany" ). exists()
20-
21- // Check package declaration in source files
22- def appFile = new File (projectDir, " src/main/java/org/custompackage/application/App.java" )
23- def appContent = appFile. text
24- assert appContent. contains(" package org.custompackage.application;" )
25- assert ! appContent. contains(" package com.mycompany;" )
26-
27- def testFile = new File (projectDir, " src/test/java/org/custompackage/application/AppTest.java" )
28- def testContent = testFile. text
29- assert testContent. contains(" package org.custompackage.application;" )
30-
31- // Check test.properties
32- def testPropsFile = new File (projectDir, " src/test/resources/test.properties" )
33- def testPropsContent = testPropsFile. text
34- assert testPropsContent. contains(" app.test.java.version=17" )
35- assert testPropsContent. contains(" app.test.version=1.5.0" )
36- assert testPropsContent. contains(" app.test.name=custom-pkg-app-test" )
37-
38- // Check GitHub workflows exist
39- assert new File (projectDir, " .github/workflows/ci.yml" ). exists()
40- assert new File (projectDir, " .github/workflows/dependency-check.yml" ). exists()
41- assert new File (projectDir, " .github/workflows/gitflow-release.yml" ). exists()
42- assert new File (projectDir, " .github/workflows/gitflow-hotfix.yml" ). exists()
43-
44- // Check .gitignore exists
45- assert new File (projectDir, " .gitignore" ). exists()
46-
47- println " Custom package test passed - package parameter correctly overrides groupId!"
48- return true
4+ try {
5+ println " Starting verification for: ${ basedir} "
6+
7+ println " Checking project directory exists: ${ projectDir} "
8+ assert projectDir. exists() : " Project directory does not exist: ${ projectDir} "
9+
10+ // Check POM has correct groupId and artifactId
11+ def pomFile = new File (projectDir, " pom.xml" )
12+ println " Checking POM file: ${ pomFile} "
13+ assert pomFile. exists() : " POM file does not exist: ${ pomFile} "
14+
15+ def pomContent = pomFile. text
16+ assert pomContent. contains(" <groupId>com.mycompany</groupId>" ) : " POM missing correct groupId"
17+ assert pomContent. contains(" <artifactId>custom-pkg-app</artifactId>" ) : " POM missing correct artifactId"
18+ assert pomContent. contains(" <version>1.5.0</version>" ) : " POM missing correct version"
19+ assert pomContent. contains(" <maven.compiler.release>17</maven.compiler.release>" ) : " POM missing Java 17 compiler release"
20+ println " PASS: POM file validated"
21+
22+ // Check that package structure uses custom package, NOT groupId
23+ println " Checking custom package structure..."
24+ def appJavaFile = new File (projectDir, " src/main/java/org/custompackage/application/App.java" )
25+ assert appJavaFile. exists() : " App.java does not exist at: ${ appJavaFile} "
26+
27+ def testJavaFile = new File (projectDir, " src/test/java/org/custompackage/application/AppTest.java" )
28+ assert testJavaFile. exists() : " AppTest.java does not exist at: ${ testJavaFile} "
29+
30+ // Should NOT have the groupId package structure
31+ def wrongPackageDir = new File (projectDir, " src/main/java/com/mycompany" )
32+ assert ! wrongPackageDir. exists() : " Wrong package structure exists (should use custom package, not groupId): ${ wrongPackageDir} "
33+ println " PASS: Custom package structure validated"
34+
35+ // Check package declaration in source files
36+ println " Checking package declarations..."
37+ def appContent = appJavaFile. text
38+ assert appContent. contains(" package org.custompackage.application;" ) :
39+ " App.java has incorrect package declaration"
40+ assert ! appContent. contains(" package com.mycompany;" ) :
41+ " App.java contains wrong package declaration (com.mycompany)"
42+
43+ def testContent = testJavaFile. text
44+ assert testContent. contains(" package org.custompackage.application;" ) :
45+ " AppTest.java has incorrect package declaration"
46+ println " PASS: Package declarations validated"
47+
48+ // Check test.properties
49+ def testPropsFile = new File (projectDir, " src/test/resources/test.properties" )
50+ println " Checking test properties: ${ testPropsFile} "
51+ assert testPropsFile. exists() : " test.properties does not exist: ${ testPropsFile} "
52+
53+ def testPropsContent = testPropsFile. text
54+ assert testPropsContent. contains(" app.test.java.version=17" ) :
55+ " test.properties missing java.version=17"
56+ assert testPropsContent. contains(" app.test.version=1.5.0" ) :
57+ " test.properties missing version=1.5.0"
58+ assert testPropsContent. contains(" app.test.name=custom-pkg-app-test" ) :
59+ " test.properties missing name=custom-pkg-app-test"
60+ println " PASS: Test properties validated"
61+
62+ // Check GitHub workflows exist
63+ println " Checking GitHub workflows..."
64+ assert new File (projectDir, " .github/workflows/ci.yml" ). exists() :
65+ " ci.yml does not exist"
66+ assert new File (projectDir, " .github/workflows/dependency-check.yml" ). exists() :
67+ " dependency-check.yml does not exist"
68+ assert new File (projectDir, " .github/workflows/gitflow-release.yml" ). exists() :
69+ " gitflow-release.yml does not exist"
70+ assert new File (projectDir, " .github/workflows/gitflow-hotfix.yml" ). exists() :
71+ " gitflow-hotfix.yml does not exist"
72+ println " PASS: GitHub workflows exist"
73+
74+ // Check .gitignore exists
75+ def gitignoreFile = new File (projectDir, " .gitignore" )
76+ println " Checking .gitignore: ${ gitignoreFile} "
77+ assert gitignoreFile. exists() : " .gitignore does not exist: ${ gitignoreFile} "
78+ println " PASS: .gitignore exists"
79+
80+ println " VERIFICATION PASSED"
81+ return true
82+ } catch (AssertionError e) {
83+ println " ERROR: ASSERTION FAILED: ${ e.message} "
84+ throw e
85+ } catch (Exception e) {
86+ println " ERROR: UNEXPECTED: ${ e.message} "
87+ e. printStackTrace()
88+ throw e
89+ }
0 commit comments