Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17, 21 ]
java: [ 21 ]

steps:
- uses: actions/checkout@v4
Expand Down
21 changes: 0 additions & 21 deletions src/main/resources/META-INF/archetype-post-generate.groovy

This file was deleted.

6 changes: 6 additions & 0 deletions src/main/resources/META-INF/maven/archetype-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<requiredProperty key="javaVersion">
<defaultValue>17</defaultValue>
</requiredProperty>
<requiredProperty key="gitignore">
<defaultValue>.gitignore</defaultValue>
</requiredProperty>
<requiredProperty key="github">
<defaultValue>.github</defaultValue>
</requiredProperty>
</requiredProperties>

<fileSets>
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/projects/basic/archetype.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ groupId=com.example.test
artifactId=test-project
version=1.0.0-SNAPSHOT
package=com.example.test
javaVersion=17
javaVersion=17
gitignore=.gitignore
github=.github
2 changes: 1 addition & 1 deletion src/test/resources/projects/basic/goal.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
clean test
clean test
61 changes: 42 additions & 19 deletions src/test/resources/projects/basic/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
// Verify the generated project
def projectDir = new File(basedir, "project/test-project")

// Check basic structure
assert projectDir.exists() : "Project directory should exist: ${projectDir}"
assert new File(projectDir, "pom.xml").exists() : "pom.xml should exist"
assert new File(projectDir, "LICENSE").exists() : "LICENSE should exist"
assert new File(projectDir, ".gitignore").exists() : ".gitignore should exist"

// Check GitHub workflows
assert new File(projectDir, ".github/workflows").exists() : ".github/workflows should exist"
assert new File(projectDir, ".github/workflows/ci.yml").exists() : "CI workflow should exist"
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists() : "Dependency check workflow should exist"
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists() : "Gitflow release workflow should exist"
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists() : "Gitflow hotfix workflow should exist"

// Check source directories
assert new File(projectDir, "src/main/java/com/example/test/App.java").exists() : "Main App.java should exist"
assert new File(projectDir, "src/test/java/com/example/test/AppTest.java").exists() : "Test AppTest.java should exist"

println "Integration test passed: All expected files were created!"
return true
try {
println "Starting verification for: ${basedir}"

// Check basic structure
println "Checking project directory exists: ${projectDir}"
assert projectDir.exists() : "Project directory should exist: ${projectDir}"

println "Checking pom.xml..."
assert new File(projectDir, "pom.xml").exists() : "pom.xml should exist"

println "Checking LICENSE..."
assert new File(projectDir, "LICENSE").exists() : "LICENSE should exist"

println "Checking .gitignore..."
assert new File(projectDir, ".gitignore").exists() : ".gitignore should exist"
println "PASS: Basic structure validated"

// Check GitHub workflows
println "Checking GitHub workflows..."
assert new File(projectDir, ".github/workflows").exists() : ".github/workflows should exist"
assert new File(projectDir, ".github/workflows/ci.yml").exists() : "CI workflow should exist"
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists() : "Dependency check workflow should exist"
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists() : "Gitflow release workflow should exist"
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists() : "Gitflow hotfix workflow should exist"
println "PASS: GitHub workflows validated"

// Check source directories
println "Checking source directories..."
assert new File(projectDir, "src/main/java/com/example/test/App.java").exists() : "Main App.java should exist"
assert new File(projectDir, "src/test/java/com/example/test/AppTest.java").exists() : "Test AppTest.java should exist"
println "PASS: Source directories validated"

println "VERIFICATION PASSED"
return true
} catch (AssertionError e) {
println "ERROR: ASSERTION FAILED: ${e.message}"
throw e
} catch (Exception e) {
println "ERROR: UNEXPECTED: ${e.message}"
e.printStackTrace()
throw e
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ groupId=com.mycompany
artifactId=custom-pkg-app
version=1.5.0
package=org.custompackage.application
javaVersion=17
javaVersion=17
gitignore=.gitignore
github=.github
2 changes: 1 addition & 1 deletion src/test/resources/projects/custom-package/goal.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
clean test
clean test
131 changes: 86 additions & 45 deletions src/test/resources/projects/custom-package/verify.groovy
Original file line number Diff line number Diff line change
@@ -1,48 +1,89 @@
// Verify custom package parameter works correctly
def projectDir = new File(basedir, "project/custom-pkg-app")

assert projectDir.exists()

// Check POM has correct groupId and artifactId
def pomFile = new File(projectDir, "pom.xml")
def pomContent = pomFile.text
assert pomContent.contains("<groupId>com.mycompany</groupId>")
assert pomContent.contains("<artifactId>custom-pkg-app</artifactId>")
assert pomContent.contains("<version>1.5.0</version>")
assert pomContent.contains("<maven.compiler.release>17</maven.compiler.release>")

// Check that package structure uses custom package, NOT groupId
assert new File(projectDir, "src/main/java/org/custompackage/application/App.java").exists()
assert new File(projectDir, "src/test/java/org/custompackage/application/AppTest.java").exists()

// Should NOT have the groupId package structure
assert !new File(projectDir, "src/main/java/com/mycompany").exists()

// Check package declaration in source files
def appFile = new File(projectDir, "src/main/java/org/custompackage/application/App.java")
def appContent = appFile.text
assert appContent.contains("package org.custompackage.application;")
assert !appContent.contains("package com.mycompany;")

def testFile = new File(projectDir, "src/test/java/org/custompackage/application/AppTest.java")
def testContent = testFile.text
assert testContent.contains("package org.custompackage.application;")

// Check test.properties
def testPropsFile = new File(projectDir, "src/test/resources/test.properties")
def testPropsContent = testPropsFile.text
assert testPropsContent.contains("app.test.java.version=17")
assert testPropsContent.contains("app.test.version=1.5.0")
assert testPropsContent.contains("app.test.name=custom-pkg-app-test")

// Check GitHub workflows exist
assert new File(projectDir, ".github/workflows/ci.yml").exists()
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists()
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists()
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists()

// Check .gitignore exists
assert new File(projectDir, ".gitignore").exists()

println "Custom package test passed - package parameter correctly overrides groupId!"
return true
try {
println "Starting verification for: ${basedir}"

println "Checking project directory exists: ${projectDir}"
assert projectDir.exists() : "Project directory does not exist: ${projectDir}"

// Check POM has correct groupId and artifactId
def pomFile = new File(projectDir, "pom.xml")
println "Checking POM file: ${pomFile}"
assert pomFile.exists() : "POM file does not exist: ${pomFile}"

def pomContent = pomFile.text
assert pomContent.contains("<groupId>com.mycompany</groupId>") : "POM missing correct groupId"
assert pomContent.contains("<artifactId>custom-pkg-app</artifactId>") : "POM missing correct artifactId"
assert pomContent.contains("<version>1.5.0</version>") : "POM missing correct version"
assert pomContent.contains("<maven.compiler.release>17</maven.compiler.release>") : "POM missing Java 17 compiler release"
println "PASS: POM file validated"

// Check that package structure uses custom package, NOT groupId
println "Checking custom package structure..."
def appJavaFile = new File(projectDir, "src/main/java/org/custompackage/application/App.java")
assert appJavaFile.exists() : "App.java does not exist at: ${appJavaFile}"

def testJavaFile = new File(projectDir, "src/test/java/org/custompackage/application/AppTest.java")
assert testJavaFile.exists() : "AppTest.java does not exist at: ${testJavaFile}"

// Should NOT have the groupId package structure
def wrongPackageDir = new File(projectDir, "src/main/java/com/mycompany")
assert !wrongPackageDir.exists() : "Wrong package structure exists (should use custom package, not groupId): ${wrongPackageDir}"
println "PASS: Custom package structure validated"

// Check package declaration in source files
println "Checking package declarations..."
def appContent = appJavaFile.text
assert appContent.contains("package org.custompackage.application;") :
"App.java has incorrect package declaration"
assert !appContent.contains("package com.mycompany;") :
"App.java contains wrong package declaration (com.mycompany)"

def testContent = testJavaFile.text
assert testContent.contains("package org.custompackage.application;") :
"AppTest.java has incorrect package declaration"
println "PASS: Package declarations validated"

// Check test.properties
def testPropsFile = new File(projectDir, "src/test/resources/test.properties")
println "Checking test properties: ${testPropsFile}"
assert testPropsFile.exists() : "test.properties does not exist: ${testPropsFile}"

def testPropsContent = testPropsFile.text
assert testPropsContent.contains("app.test.java.version=17") :
"test.properties missing java.version=17"
assert testPropsContent.contains("app.test.version=1.5.0") :
"test.properties missing version=1.5.0"
assert testPropsContent.contains("app.test.name=custom-pkg-app-test") :
"test.properties missing name=custom-pkg-app-test"
println "PASS: Test properties validated"

// Check GitHub workflows exist
println "Checking GitHub workflows..."
assert new File(projectDir, ".github/workflows/ci.yml").exists() :
"ci.yml does not exist"
assert new File(projectDir, ".github/workflows/dependency-check.yml").exists() :
"dependency-check.yml does not exist"
assert new File(projectDir, ".github/workflows/gitflow-release.yml").exists() :
"gitflow-release.yml does not exist"
assert new File(projectDir, ".github/workflows/gitflow-hotfix.yml").exists() :
"gitflow-hotfix.yml does not exist"
println "PASS: GitHub workflows exist"

// Check .gitignore exists
def gitignoreFile = new File(projectDir, ".gitignore")
println "Checking .gitignore: ${gitignoreFile}"
assert gitignoreFile.exists() : ".gitignore does not exist: ${gitignoreFile}"
println "PASS: .gitignore exists"

println "VERIFICATION PASSED"
return true
} catch (AssertionError e) {
println "ERROR: ASSERTION FAILED: ${e.message}"
throw e
} catch (Exception e) {
println "ERROR: UNEXPECTED: ${e.message}"
e.printStackTrace()
throw e
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ groupId=org.mycompany
artifactId=default-pkg-app
version=2.0.0
package=org.mycompany
javaVersion=17
javaVersion=17
gitignore=.gitignore
github=.github
2 changes: 1 addition & 1 deletion src/test/resources/projects/default-package/goal.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
clean test
clean test
Loading
Loading