*/
private final Map<String, String> index;
- public ClassPathTypeIndex(final String projectRoot, final String version) {
- index = buildIndex(projectRoot, version);
+ public ClassPathTypeIndex(final String projectRoot) {
+ index = buildIndex(projectRoot);
}
/**
return index.get(clazz.replace("/", "."));
}
- private Map<String, String> buildIndex(final String projectRoot, final String version) {
+ private Map<String, String> buildIndex(final String projectRoot) {
try {
return Files.walk(Paths.get(projectRoot))
.filter(path -> path.toString().contains("src/main/java"))
.map(Path::toString)
.map(s -> s.replace(projectRoot, ""))
.distinct()
- .collect(Collectors.toMap(ClassPathTypeIndex::key, o -> generateLink(o, version)));
+ .collect(Collectors.toMap(ClassPathTypeIndex::key, o -> generateLink(o)));
} catch (IOException e) {
throw new IllegalStateException(format("%s not found", projectRoot), e);
}
public interface LinkGenerator {
- static String resolveBranch(final String version) {
- if (version.contains("SNAPSHOT")) {
- return "master";
- } else {
- return "stable%2F" + version.replace(".", "");
- }
- }
-
- default String generateLink(final String raw, final String version) {
+ default String generateLink(final String raw) {
//https://git.fd.io/hc2vpp/tree/interface-role/api/src/main/yang/
[email protected]?h=stable%2F1707
- return "https://git.fd.io/hc2vpp/tree" + raw + "?h=" + resolveBranch(version);
+ return "https://git.fd.io/hc2vpp/tree" + raw + "?h={project-branch}";
}
}
/**
* @param projectRoot for ex.: /home/jsrnicek/Projects/hc2vpp
- * @param version for ex.: 17.07 to get generateLink for correct branch
*/
- ModelLinkIndex(final String projectRoot, final String version) {
- modelLinkIndex = buildIndex(projectRoot, version);
+ ModelLinkIndex(final String projectRoot) {
+ modelLinkIndex = buildIndex(projectRoot);
}
private static String key(String raw) {
.orElse("https://datatracker.ietf.org/"));
}
- private Map<String, String> buildIndex(final String projectRoot, final String version) {
+ private Map<String, String> buildIndex(final String projectRoot) {
try {
return Files.walk(Paths.get(projectRoot))
.filter(path -> path.toString().contains("src/main/yang"))
.map(Path::toString)
.map(s -> s.replace(projectRoot, ""))
.distinct()
- .collect(Collectors.toMap(ModelLinkIndex::key, o -> generateLink(o, version)));
+ .collect(Collectors.toMap(ModelLinkIndex::key, o -> generateLink(o)));
} catch (IOException e) {
throw new IllegalStateException(format("%s not found", projectRoot), e);
}
private final ModelLinkIndex modelLinkIndex;
private final ModelTypeIndex modelTypeIndex;
- public YangTypeLinkIndex(final String projectRoot, final String version) {
- modelLinkIndex = new ModelLinkIndex(projectRoot, version);
+ public YangTypeLinkIndex(final String projectRoot) {
+ modelLinkIndex = new ModelLinkIndex(projectRoot);
try {
modelTypeIndex = new ModelTypeIndex();
} catch (IOException e) {
String outPath = project.build.outputDirectory
log.info "Generating yang type generateLink index"
- YangTypeLinkIndex yangTypeIndex = new YangTypeLinkIndex(projectRoot, project.version)
+ YangTypeLinkIndex yangTypeIndex = new YangTypeLinkIndex(projectRoot)
log.info "Classpath type generateLink index"
- ClassPathTypeIndex classPathIndex = new ClassPathTypeIndex(projectRoot, project.version)
+ ClassPathTypeIndex classPathIndex = new ClassPathTypeIndex(projectRoot)
log.info "Generating VPP API to YANG mapping"
PLUGIN_CLASSES.stream()