import { Output } from "@alloy-js/core"; import { expect, it } from "vitest"; import { ProjectDirectory } from "../src/components/index.js"; import { MavenProjectConfig } from "../src/index.js"; it("generates barebones pom.xml file", () => { const projectConfig: MavenProjectConfig = { groupId: "me.example", artifactId: "test", version: "1.0.0", javaVersion: 8, }; expect( , ).toRenderTo({ "pom.xml": ` 4.0.0 me.example test 1.0.0 8 8 UTF-8 `, }); }); it("generates complex configuration", () => { // Some fields are duplicate, just to show it can handle array data const projectConfig: MavenProjectConfig = { groupId: "me.example", artifactId: "test", version: "1.0.0", javaVersion: 8, repositories: [ { id: "central", url: "https://repo.maven.apache.org/maven2" }, { id: "central", url: "https://repo.maven.apache.org/maven2" }, ], pluginRepositories: [ { id: "central", url: "https://repo.maven.apache.org/maven2" }, { id: "central", url: "https://repo.maven.apache.org/maven2" }, ], build: { plugins: [ { groupId: "org.apache.maven.plugins", artifactId: "maven-compiler-plugin", version: "3.8.1", executions: [ { id: "default-compile", phase: "compile", goals: ["compile", "test"], }, { id: "default-testCompile", phase: "test-compile", goals: ["testCompile", "test"], }, ], configuration: { source: 8, target: 8, }, }, { groupId: "org.apache.maven.plugins", artifactId: "maven-compiler-plugin", version: "3.8.1", executions: [ { id: "default-compile", phase: "compile", goals: ["compile", "test"], }, { id: "default-testCompile", phase: "test-compile", goals: ["testCompile", "test"], }, ], configuration: { source: 8, target: 8, }, }, ], resources: [ { directory: "src/main/resources", filtering: true, targetPath: "target/classes", includes: ["**/*.properties", "**/*.xml"], excludes: ["**/*.xml", "**/*.json"], }, { directory: "src/main/resources", filtering: true, targetPath: "target/classes", includes: ["**/*.properties", "**/*.xml"], excludes: ["**/*.xml", "**/*.json"], }, ], }, }; expect( , ).toRenderTo({ "pom.xml": ` 4.0.0 me.example test 1.0.0 8 8 UTF-8 central https://repo.maven.apache.org/maven2 central https://repo.maven.apache.org/maven2 central https://repo.maven.apache.org/maven2 central https://repo.maven.apache.org/maven2 org.apache.maven.plugins maven-compiler-plugin 3.8.1 default-compile compile compile test default-testCompile test-compile testCompile test 8 8 org.apache.maven.plugins maven-compiler-plugin 3.8.1 default-compile compile compile test default-testCompile test-compile testCompile test 8 8 src/main/resources **/*.properties **/*.xml **/*.xml **/*.json true target/classes src/main/resources **/*.properties **/*.xml **/*.xml **/*.json true target/classes `, }); });