Addressing paths for the name of the POM file when submitted to the API
This commit is contained in:
@@ -16,7 +16,9 @@ export async function generateSnapshot(directory: string, context?: any, job?: a
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const mavenDependencies = new MavenDependencyGraph(depgraph);
|
const mavenDependencies = new MavenDependencyGraph(depgraph);
|
||||||
const manifest = mavenDependencies.createManifest(path.join(directory, 'pom.xml'));
|
// The filepath to the POM needs to be relative to the root of the GitHub repository for the links to work once uploaded
|
||||||
|
const pomFile = getRepositoryRelativePath(path.join(directory, 'pom.xml'));
|
||||||
|
const manifest = mavenDependencies.createManifest(pomFile);
|
||||||
const snapshot = new Snapshot(getDetector(), context, job);
|
const snapshot = new Snapshot(getDetector(), context, job);
|
||||||
snapshot.addManifest(manifest);
|
snapshot.addManifest(manifest);
|
||||||
|
|
||||||
@@ -107,3 +109,15 @@ function checkForMultiModule(reactorJsonFile) {
|
|||||||
throw new Error(`Failed to load file ${reactorJsonFile}: ${err}`);
|
throw new Error(`Failed to load file ${reactorJsonFile}: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO this is assuming the checkout was made into the base path of the workspace...
|
||||||
|
function getRepositoryRelativePath(file) {
|
||||||
|
const workspaceDirectory = path.resolve(process.env.GITHUB_WORKSPACE || '.');
|
||||||
|
const fileResolved = path.dirname(path.resolve(file));
|
||||||
|
|
||||||
|
if (fileResolved.startsWith(workspaceDirectory)) {
|
||||||
|
return fileResolved.substring(workspaceDirectory.length + path.sep.length);
|
||||||
|
} else {
|
||||||
|
return path.resolve(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user