Huluvu424242 / plantuml-maven-plugin

A maven plugin to generate UML diagrams using PlantUML syntax
Apache License 2.0
6 stars 7 forks source link

truncatePattern seems not evaluated in the mojo code #17

Closed Huluvu424242 closed 4 years ago

Huluvu424242 commented 4 years ago

No occurence of truncatePattern will be used -> merge conflict has removed this code?

code from giflw


for (final File file : files) {
                getLog().info("Processing file <" + file + ">");

                if (this.outputInSourceDirectory) {
                    this.option.setOutputDir(file.getParentFile());
                } else {

                    Path fileBasePath = file.getParentFile().toPath();

                    if (truncatePattern != null && truncatePattern.length() > 0) {
                        String[] truncateTokens = truncatePattern.split("/");
                        int truncateIndex = 0;
                        int endIndex = 0;
                        for (final Path path : fileBasePath) {
                            endIndex++;
                            String currentTruncateToken = truncateTokens[truncateIndex];

                            if ("*".equals(currentTruncateToken) || path.getFileName().toString().equals(currentTruncateToken)) {
                                truncateIndex++;
                                if (truncateIndex == truncateTokens.length) {
                                    // All tokens are found
                                    Path root = fileBasePath.getRoot();
                                    Path subpath = fileBasePath.subpath(0, endIndex);
                                    if (root != null) {
                                        fileBasePath = root.resolve(subpath);
                                    } else {
                                        // this is very unlikely because the
                                        // File has an absolute path
                                        fileBasePath = subpath;
                                    }
                                    break;
                                }
                            } else {
                                // doesn't match, reset the pattern
                                truncateIndex = 0;
                            }
                        }
                    }

                    Path relativize = fileBasePath.relativize(file.toPath().getParent());
                    File outputDir = outputDirectory.toPath().resolve(relativize).toFile();
                    this.option.setOutputDir(outputDir);
                }

                final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), file, this.option.getOutputDir(), this.option.getConfig(), this.option.getCharset(), this.option.getFileFormatOption());
                for (final GeneratedImage image : sourceFileReader.getGeneratedImages()) {
                    getLog().debug(image + " " + image.getDescription());
                }
            }
Huluvu424242 commented 4 years ago

code from bvfalcon

for (final File file : files) {
                getLog().info("Processing file <" + file + ">");

                if (this.outputInSourceDirectory) {
                    this.option.setOutputDir(file.getParentFile());
                } else {

                    Path fileBasePath = file.getParentFile().toPath();

                    if (truncatePattern != null && truncatePattern.length() > 0) {
                        String[] truncateTokens = truncatePattern.split("/");
                        int truncateIndex = 0;
                        int endIndex = 0;
                        for (final Path path : fileBasePath) {
                            endIndex++;
                            String currentTruncateToken = truncateTokens[truncateIndex];

                            if ("*".equals(currentTruncateToken) || path.getFileName().toString().equals(currentTruncateToken)) {
                                truncateIndex++;
                                if (truncateIndex == truncateTokens.length) {
                                    // All tokens are found
                                    Path root = fileBasePath.getRoot();
                                    Path subpath = fileBasePath.subpath(0, endIndex);
                                    if (root != null) {
                                        fileBasePath = root.resolve(subpath);
                                    } else {
                                        // this is very unlikely because the
                                        // File has an absolute path
                                        fileBasePath = subpath;
                                    }
                                    break;
                                }
                            } else {
                                // doesn't match, reset the pattern
                                truncateIndex = 0;
                            }
                        }
                    }

                    Path relativize = fileBasePath.relativize(file.toPath().getParent());
                    File outputDir = outputDirectory.toPath().resolve(relativize).toFile();
                    this.option.setOutputDir(outputDir);
                }

                final SourceFileReader sourceFileReader = new SourceFileReader(new Defines(), file, this.option.getOutputDir(), this.option.getConfig(), this.option.getCharset(), this.option.getFileFormatOption());
                for (final GeneratedImage image : sourceFileReader.getGeneratedImages()) {
                    getLog().debug(image + " " + image.getDescription());
                }
            }