All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.plugins.tasks.util.MavenModuleDetector Maven / Gradle / Ivy

Go to download

This plug-in scans the workspace files for open tasks and generates a trend report.

There is a newer version: 4.13
Show newest version
package hudson.plugins.tasks.util;

import org.apache.commons.lang.StringUtils;

/**
 * Detects maven module names by parsing the name of a source file.
 */
public final class MavenModuleDetector {
    /**
     * Guesses a maven module name based on the source folder.
     *
     * @param fileName
     *            the absolute path of the file (UNIX style) to guess the module
     *            for
     * @return the guessed module name or an empty string
     */
    public static String guessModuleName(final String fileName) {
        if (fileName.contains("/src")) {
            String module = StringUtils.substringBefore(fileName, "/src/");
            if (module.contains("/")) {
                module = StringUtils.substringAfterLast(module, "/");
            }
            if (StringUtils.isNotBlank(module)) {
                return module;
            }
        }
        return StringUtils.EMPTY;
    }

    /**
     * Creates a new instance of MavenModuleDetector.
     */
    private MavenModuleDetector() {
        // prevents instantiation
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy