private Set<String> getClassPathEntries(final String classPath) { if (Validate.isNullOrEmpty(classPath)) { return Collections.emptySet(); } return new LinkedHashSet<String>(Arrays.asList(classPath.split(String.valueOf(File.pathSeparatorChar)))); }
public ConfigureSettingsFromFileTask(final String pathToSettingsXmlFile) throws InvalidConfigurationFileException { assert pathToSettingsXmlFile != null && pathToSettingsXmlFile.length() > 0; String resolvedPath = null; try { resolvedPath = pathToSettingsXmlFile; Validate.isReadable(resolvedPath, "Path to the settings.xml ('" + pathToSettingsXmlFile + "') must be defined and accessible"); } // rewrap exception catch (IllegalArgumentException e) { throw new InvalidConfigurationFileException(e.getMessage()); } this.settingsXmlFile = new File(resolvedPath); }
@Override public MavenWorkingSession execute(final MavenWorkingSession session) { Validate.notNull(pomFile, "Path to pom.xml file must not be null"); Validate.readable(pomFile, "Path to the POM ('" + pomFile + "') file must be defined and accessible"); return session.loadPomFromFile(pomFile, profiles); }
/** * Checks that the specified String is not null or empty and represents a readable file, throws exception if it is * empty or null and does not represent a path to a file. * * @param path * The path to check * @param message * The exception message * @throws IllegalArgumentException * Thrown if path is empty, null or invalid */ public static void readable(final String path, final String message) throws IllegalArgumentException { notNullOrEmpty(path, message); readable(new File(path), message); }
/** * Checks that the specified String is not null or empty and represents a readable file, throws exception if it is * empty or null and does not represent a path to a file. * * @param path * The path to check * @param message * The exception message * @throws IllegalArgumentException * Thrown if path is empty, null or invalid */ public static void isReadable(final String path, String message) throws IllegalArgumentException { notNullOrEmpty(path, message); isReadable(new File(path), message); } }
/** * Checks that the specified String is not null or empty and represents a readable file, throws exception if it is * empty or null and does not represent a path to a file. * * @param path * The path to check * @param message * The exception message * @throws IllegalArgumentException * Thrown if path is empty, null or invalid */ public static void readable(final File path, final String message) throws IllegalArgumentException { notNull(path, message); if (!isReadable(path)) { throw new IllegalArgumentException(message); } }
@Override public ConfiguredMavenImporter configureFromClassloaderResource(String path, ClassLoader cl) throws IllegalArgumentException, UnsupportedOperationException, InvalidConfigurationFileException { Validate.isNullOrEmpty(path); Validate.notNull(cl, "ClassLoader is required"); final File file = FileUtil.INSTANCE.fileFromClassLoaderResource(path, cl); return this.configureFromFile(file); }
public static LoadPomTask loadPomFromClassLoaderResource(String pathToPomResource, ClassLoader cl, String... profiles) throws IllegalArgumentException, InvalidConfigurationFileException { Validate.notNullOrEmpty(pathToPomResource, "path to CL resource must be specified"); Validate.notNull(cl, "ClassLoader must be specified"); final File file = FileUtil.INSTANCE.fileFromClassLoaderResource(pathToPomResource, cl); return new LoadPomTask(file, profiles); }
@Override public MavenWorkingSession execute(MavenWorkingSession session) { String pomFile = SecurityActions.getProperty(POM_FILE_KEY); if (Validate.isNullOrEmpty(pomFile)) { throw new InvalidEnvironmentException(CONSTRUCTION_EXCEPTION); } Validate.isReadable(pomFile, "POM file " + pomFile + " does not represent a readable file"); String userSettings = SecurityActions.getProperty(USER_SETTINGS_KEY); if (Validate.isNullOrEmpty(userSettings)) { throw new InvalidEnvironmentException(CONSTRUCTION_EXCEPTION); } boolean hasSettingsXml = true; try { Validate.isReadable(userSettings, "Settings.xml file " + userSettings + " does not represent a readable file"); } catch (final IllegalArgumentException iae) { hasSettingsXml = false; } if (hasSettingsXml) { session = new ConfigureSettingsFromFileTask(userSettings).execute(session); } String activeProfiles = SecurityActions.getProperty(ACTIVE_PROFILES_KEY); String[] profiles = new String[0]; if (!Validate.isNullOrEmpty(activeProfiles)) { profiles = activeProfiles.split(","); } return LoadPomTask.loadPomFromFile(pomFile, profiles).execute(session); }
public static List<String> explicitlyActivatedProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> activated = new ArrayList<String>(); for (String profileId : profiles) { Validate.notNullOrEmpty(profileId, "Invalid name (\"" + profileId + "\") of a profile to be activated"); if (!(profileId.startsWith("-") || profileId.startsWith("!"))) { activated.add(profileId); } } return activated; }
protected AbstractCompilingProcessor<ARCHIVETYPE> compile(File inputDirectory, File outputDirectory, ScopeType... scopes) { Validate.notNullAndNoNullValues(scopes, "Cannot compile sources, there were no scopes defined"); Validate.notNull(inputDirectory, "Directory with sources to be compiled must not be null"); Validate.notNull(outputDirectory, "Target directory for compiled sources must not be null");
static void packageDirectories(final File outputFile, final File... directories) throws IOException { Validate.notNullAndNoNullValues(directories, "Directories to be packaged must be specified"); final ZipOutputStream zipFile = new ZipOutputStream(new FileOutputStream(outputFile)); for (File directory : directories) { for (String entry : fileListing(directory)) { FileInputStream fis = null; try { File fileEntry = new File(directory, entry); //Do not add zip entries for directories if (fileEntry.isFile()) { fis = new FileInputStream(fileEntry); zipFile.putNextEntry(new ZipEntry(entry)); IOUtil.copy(fis, zipFile); } } finally { safelyClose(fis); } } } safelyClose(zipFile); }
public ResolveStageBaseImpl(final MavenWorkingSession session) { Validate.stateNotNull(session, "Maven Working session must not be null"); this.session = session; }
@Override public FORMATSTAGETYPE using(final MavenResolutionStrategy strategy) throws IllegalArgumentException { // first, get dependencies specified for resolution in the session Validate.notEmpty(session.getDependenciesForResolution(), "No dependencies were set for resolution"); final Collection<MavenResolvedArtifact> resolvedArtifacts = session.resolveDependencies(strategy); // Proceed to format stage return this.createFormatStage(resolvedArtifacts); }
if (Validate.isNullOrEmptyOrQuestionMark(resolvedVersion)) { if (Validate.isNullOrEmptyOrQuestionMark(resolvedVersion) && dependency.getPackaging().equals(PackagingType.JAR) && dependency.getClassifier().equals(PackagingType.TEST_JAR.getClassifier())) { MavenCoordinate coordinate = MavenCoordinates.createCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), PackagingType.TEST_JAR, PackagingType.TEST_JAR.getClassifier()); MavenDependency newDependency = new MavenDependencyImpl(coordinate, dependency.getScope(), dependency.isOptional(), dependency.getExclusions().toArray(new MavenDependencyExclusion[0])); if (Validate.isNullOrEmptyOrQuestionMark(resolvedVersion)) {
private UNCONFIGURABLERESOLVERSYSTEMTYPE configureFromClassloaderResource(final String path, final ClassLoader loader) throws IllegalArgumentException, UnsupportedOperationException, InvalidConfigurationFileException { Validate.isNullOrEmpty(path); Validate.notNull(loader, "ClassLoader is required"); final File file = FileUtil.INSTANCE.fileFromClassLoaderResource(path, loader); return this.fromFile(file); }
public static LoadPomTask loadPomFromClassLoaderResource(String pathToPomResource, ClassLoader cl, String... profiles) throws IllegalArgumentException, InvalidConfigurationFileException { Validate.notNullOrEmpty(pathToPomResource, "path to CL resource must be specified"); Validate.notNull(cl, "ClassLoader must be specified"); final File file = FileUtil.INSTANCE.fileFromClassLoaderResource(pathToPomResource, cl); return new LoadPomTask(file, profiles); }
/** * Checks that the specified String is not null or empty and represents a readable file, throws exception if it is * empty or null and does not represent a path to a file. * * @param path * The path to check * @param message * The exception message * @throws IllegalArgumentException * Thrown if path is empty, null or invalid */ public static void readable(final String path, final String message) throws IllegalArgumentException { notNullOrEmpty(path, message); readable(new File(path), message); }