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; }
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; }
public static List<String> explicitlyDisabledProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> disabled = new ArrayList<String>(); for (String profileId : profiles) { if (profileId != null && (profileId.startsWith("-") || profileId.startsWith("!"))) { String disabledId = profileId.substring(1); Validate.notNullOrEmpty(disabledId, "Invalid name (\"" + profileId + "\") of a profile do be disabled"); disabled.add(disabledId); } } return disabled; } }
/** * Fetches a value specified by key * * @param map XPP3 map equivalent * @param key navigation key * @param defaultValue Default value if no such key exists * @return String representation of the value */ static String valueAsString(Map<String, Object> map, Key key, String defaultValue) { Validate.notNullOrEmpty(key.key, "Key for plugin configuration must be set"); if (map.containsKey(key.key)) { return map.get(key.key).toString().length() == 0 ? defaultValue : map.get(key.key).toString(); } return defaultValue; }
public static List<String> explicitlyDisabledProfiles(String... profiles) { if (profiles.length == 0) { return Collections.<String> emptyList(); } List<String> disabled = new ArrayList<String>(); for (String profileId : profiles) { if (profileId != null && (profileId.startsWith("-") || profileId.startsWith("!"))) { String disabledId = profileId.substring(1); Validate.notNullOrEmpty(disabledId, "Invalid name (\"" + profileId + "\") of a profile do be disabled"); disabled.add(disabledId); } } return disabled; } }
/** * Fetches a value specified by key * * @param map XPP3 map equivalent * @param key navigation key * @param defaultValue Default value if no such key exists * @return String representation of the value */ static String valueAsString(Map<String, Object> map, Key key, String defaultValue) { Validate.notNullOrEmpty(key.key, "Key for plugin configuration must be set"); if (map.containsKey(key.key)) { return map.get(key.key).toString().length() == 0 ? defaultValue : map.get(key.key).toString(); } return defaultValue; }
/** * Checks that the specified String is not null or empty and represents a writeable directory, throws exception if * it is empty or null and does not represent a path to a directory. * * @param path * The path to check * @param message * The exception message * @throws IllegalArgumentException * Thrown if path is empty, null or invalid */ public static void writeableDirectory(final String path, String message) throws IllegalArgumentException { notNullOrEmpty(path, message); File file = new File(path); if (!file.exists() || !file.isDirectory() || !file.canWrite() || !file.canExecute()) { throw new IllegalArgumentException(message); } }
/** * Checks that the specified String is not null or empty and represents a writeable directory, throws exception if * it is empty or null and does not represent a path to a directory. * * @param path * The path to check * @param message * The exception message * @throws IllegalArgumentException * Thrown if path is empty, null or invalid */ public static void writeableDirectory(final String path, String message) throws IllegalArgumentException { notNullOrEmpty(path, message); File file = new File(path); if (!file.exists() || !file.isDirectory() || !file.canWrite() || !file.canExecute()) { throw new IllegalArgumentException(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 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 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 isReadable(final String path, String message) throws IllegalArgumentException { notNullOrEmpty(path, message); isReadable(new File(path), message); } }
public static LoadPomTask loadPomFromFile(final String pathToPomFile, final String... profiles) throws IllegalArgumentException, InvalidConfigurationFileException { Validate.notNullOrEmpty(pathToPomFile, "Path to a POM file must be specified"); Validate.readable(pathToPomFile, "Path to the pom.xml ('" + pathToPomFile + "')file must be defined and accessible"); return new LoadPomTask(new File(pathToPomFile), profiles); }
public static LoadPomTask loadPomFromFile(final String pathToPomFile, final String... profiles) throws IllegalArgumentException, InvalidConfigurationFileException { Validate.notNullOrEmpty(pathToPomFile, "Path to a POM file must be specified"); Validate.readable(pathToPomFile, "Path to the pom.xml ('" + pathToPomFile + "')file must be defined and accessible"); return new LoadPomTask(new File(pathToPomFile), profiles); }
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); }
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); }
Validate.notNullOrEmpty(key.key, "Key for plugin configuration must be set"); if (map.containsKey(key.key)) { Object rawMapOrObject = map.get(key.key);
Validate.notNullOrEmpty(key.key, "Key for plugin configuration must be set"); if (map.containsKey(key.key)) { Object rawMapOrObject = map.get(key.key);
/** * Gets manager for local repository * * @return the manager */ public LocalRepositoryManager localRepositoryManager(final RepositorySystemSession session, boolean legacyLocalRepository) { Validate.notNull(session, "session must be specified"); String localRepositoryPath = settings.getLocalRepository(); Validate.notNullOrEmpty(localRepositoryPath, "Path to a local repository must be defined"); SWRLocalRepositoryManager factory = SWRLocalRepositoryManager.ENHANCED; // here we rely either on system property or flag passed by caller if (useLegacyLocalRepository || legacyLocalRepository) { factory = SWRLocalRepositoryManager.LEGACY; } if (settings.isOffline()) { factory = SWRLocalRepositoryManager.SIMPLE; } LocalRepositoryManager manager = factory.localRepositoryManager(system, session, new File(localRepositoryPath)); return manager; }
/** * Gets manager for local repository * * @return the manager */ public LocalRepositoryManager localRepositoryManager(final RepositorySystemSession session, boolean legacyLocalRepository) { Validate.notNull(session, "session must be specified"); String localRepositoryPath = settings.getLocalRepository(); Validate.notNullOrEmpty(localRepositoryPath, "Path to a local repository must be defined"); SWRLocalRepositoryManager factory = SWRLocalRepositoryManager.ENHANCED; // here we rely either on system property or flag passed by caller if (useLegacyLocalRepository || legacyLocalRepository) { factory = SWRLocalRepositoryManager.LEGACY; } if (settings.isOffline()) { factory = SWRLocalRepositoryManager.SIMPLE; } LocalRepositoryManager manager = factory.localRepositoryManager(system, session, new File(localRepositoryPath)); return manager; }