MCPcopy Index your code
hub / github.com/github/copilot-sdk / validateJava

Function validateJava

scripts/docs-validation/validate.ts:368–504  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

366}
367
368async function validateJava(): Promise<ValidationResult[]> {
369 const results: ValidationResult[] = [];
370 const javaDir = path.join(VALIDATION_DIR, "java");
371 const manifest = loadManifest();
372
373 if (!fs.existsSync(javaDir)) {
374 console.log(" No Java files to validate");
375 return results;
376 }
377
378 // Create a minimal Maven project structure
379 const srcDir = path.join(javaDir, "src", "main", "java");
380 fs.mkdirSync(srcDir, { recursive: true });
381
382 // Copy all .java files into src/main/java/ (copy, not move, for idempotency)
383 const files = await glob("*.java", { cwd: javaDir });
384 for (const file of files) {
385 fs.copyFileSync(path.join(javaDir, file), path.join(srcDir, file));
386 }
387
388 // Read the SDK version from java/pom.xml
389 const sdkPomPath = path.join(ROOT_DIR, "java", "pom.xml");
390 const sdkPomContent = fs.readFileSync(sdkPomPath, "utf-8");
391 const versionMatch = sdkPomContent.match(
392 /<artifactId>copilot-sdk-java<\/artifactId>\s*<version>([^<]+)<\/version>/,
393 );
394 const sdkVersion = versionMatch ? versionMatch[1] : "1.0.0-SNAPSHOT";
395
396 // Create pom.xml that references the local SDK
397 const pomXml = `<?xml version="1.0" encoding="UTF-8"?>
398<project xmlns="http://maven.apache.org/POM/4.0.0"
399 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
400 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
401 <modelVersion>4.0.0</modelVersion>
402 <groupId>docs</groupId>
403 <artifactId>docs-validation-java</artifactId>
404 <version>1.0.0</version>
405 <properties>
406 <maven.compiler.source>17</maven.compiler.source>
407 <maven.compiler.target>17</maven.compiler.target>
408 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
409 </properties>
410 <dependencies>
411 <dependency>
412 <groupId>com.github</groupId>
413 <artifactId>copilot-sdk-java</artifactId>
414 <version>${sdkVersion}</version>
415 </dependency>
416 </dependencies>
417</project>`;
418
419 fs.writeFileSync(path.join(javaDir, "pom.xml"), pomXml);
420
421 // First, install the local SDK into the local Maven repo
422 const pomPath = path.join(ROOT_DIR, "java", "pom.xml");
423 try {
424 execSync(`mvn install -f "${pomPath}" -DskipTests -q`, {
425 encoding: "utf-8",

Callers

nothing calls this directly

Calls 6

loadManifestFunction · 0.85
joinMethod · 0.80
logMethod · 0.45
pushMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…