-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
46 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/ProjectHelper.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.palladiosimulator.retriever.extraction.rules.util | ||
|
||
import java.nio.file.Path | ||
import java.util.Map | ||
import org.jdom2.Document | ||
import java.util.Set | ||
|
||
class ProjectHelper { | ||
static def findMavenProjectRoot(Path currentPath, Map<Path, Document> xmls) { | ||
if (currentPath === null || xmls === null) { | ||
return null | ||
} | ||
val closestPom = xmls.keySet.stream // Only keep poms above the current compilation unit. | ||
.filter[path|path.fileName.toString == "pom.xml"] | ||
.filter[path|currentPath.startsWith(path.parent)] // Take the longest path, which is the pom.xml closest to the compilation unit | ||
.max([a, b|a.size.compareTo(b.size)]) | ||
|
||
if (closestPom.present) { | ||
return closestPom.get.parent | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
static def findProjectRoot(Path currentPath, Set<Path> systemRoots) { | ||
if (currentPath === null || systemRoots === null) { | ||
return null | ||
} | ||
val closestSystemRoot = systemRoots.stream // Only keep build files above the current compilation unit. | ||
.filter([path|currentPath.startsWith(path.parent)]) // Take the longest path, which is the build file closest to the compilation unit | ||
.max([a, b|a.size.compareTo(b.size)]) | ||
|
||
if (closestSystemRoot.present) { | ||
return closestSystemRoot.get.parent | ||
} else { | ||
return null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters