mirror of
https://github.com/zaaarf/route-cartographer.git
synced 2024-12-05 00:24:53 +01:00
fix: don't try to recreate the routemap file
This commit is contained in:
parent
f5bff65ba8
commit
324d7e24e5
1 changed files with 25 additions and 5 deletions
|
@ -29,6 +29,11 @@ import java.util.stream.Collectors;
|
|||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
||||
public class RouteCompass extends AbstractProcessor {
|
||||
|
||||
/**
|
||||
* The filename of the output.
|
||||
*/
|
||||
private static final String ROUTE_MAP_FILENAME = "route_map";
|
||||
|
||||
/**
|
||||
* A {@link Map} tying each component class to the routes it contains.
|
||||
*/
|
||||
|
@ -38,7 +43,7 @@ public class RouteCompass extends AbstractProcessor {
|
|||
* A {@link Set} containing all the supported annotation classes.
|
||||
*/
|
||||
private final Set<Class<? extends Annotation>> annotationClasses = new HashSet<>();
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor, it only initialises {@link #annotationClasses}.
|
||||
*/
|
||||
|
@ -85,11 +90,23 @@ public class RouteCompass extends AbstractProcessor {
|
|||
}
|
||||
|
||||
try {
|
||||
FileObject serviceProvider = this.processingEnv.getFiler().createResource(
|
||||
StandardLocation.SOURCE_OUTPUT, "", "route_map"
|
||||
CharSequence startingContents;
|
||||
try {
|
||||
FileObject existingRouteMap = this.processingEnv.getFiler().getResource(
|
||||
StandardLocation.SOURCE_OUTPUT, "", ROUTE_MAP_FILENAME
|
||||
);
|
||||
startingContents = existingRouteMap.getCharContent(true);
|
||||
existingRouteMap.delete();
|
||||
} catch (IOException ex) {
|
||||
startingContents = "";
|
||||
}
|
||||
|
||||
FileObject routeMap = this.processingEnv.getFiler().createResource(
|
||||
StandardLocation.SOURCE_OUTPUT, "", ROUTE_MAP_FILENAME
|
||||
);
|
||||
|
||||
PrintWriter out = new PrintWriter(serviceProvider.openWriter());
|
||||
PrintWriter out = new PrintWriter(routeMap.openWriter());
|
||||
out.println(startingContents); //print with an extra newline
|
||||
for(String componentClass : this.foundRoutes.keySet()) {
|
||||
out.println(componentClass + ":");
|
||||
|
||||
|
@ -152,7 +169,10 @@ public class RouteCompass extends AbstractProcessor {
|
|||
String parent = this.getFullRoute(a, e)[0];
|
||||
for(int i = 0; i < routes.length; i++) {
|
||||
StringBuilder sb = new StringBuilder(parent);
|
||||
if(!parent.endsWith("/")) sb.append("/");
|
||||
if(!parent.endsWith("/") && !routes[i].startsWith("/"))
|
||||
sb.append("/");
|
||||
if(parent.endsWith("/") && routes[i].startsWith("/"))
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
sb.append(routes[i]);
|
||||
routes[i] = sb.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue