/** * Given a project containing groupId + artifactId, convert the groupId to groupId.base, then return the classpath prefix * * <pre> * org.kuali.student.db:ks-impex-rice-db = classpath:org/kuali/student/ks-impex-rice-db * org.kuali.common:kuali-util = classpath:org/kuali/common/kuali-util * </pre> */ public static String getClassPathPrefix(Project project) { return getClassPathPrefix(project.getGroupId(), project.getArtifactId()); }
/** * Given groupId:artifactId, convert the groupId to groupId.base, then return a resource friendly prefix * * <pre> * org.kuali.student.db:ks-impex-rice-db = org/kuali/student/ks-impex-rice-db * org.kuali.common:kuali-util = org/kuali/common/kuali-util * </pre> */ public static String getResourcePath(Project project) { Properties properties = project.getProperties(); String groupIdPath = properties.getProperty(Constants.GROUP_ID_PATH_KEY); Assert.hasText(groupIdPath, "groupIdPath has no text"); String artifactId = project.getArtifactId(); return groupIdPath + "/" + artifactId; }
/** * Create a skeleton <code>Project</code> object from the <code>gav</code>. Nothing but the GAV info (groupId:artifactId:packaging:version:classifier) gets filled in. Does not * read <code>project.properties</code> from disk. */ public static Project getProject(String gav) { logger.debug("Processing [{}]", gav); String[] tokens = StringUtils.split(gav, ":"); Project project = new Project(); if (tokens.length > 0) { project.setGroupId(RepositoryUtils.toNull(tokens[0])); } if (tokens.length > 1) { project.setArtifactId(RepositoryUtils.toNull(tokens[1])); } if (tokens.length > 2) { project.setPackaging(RepositoryUtils.toNull(tokens[2])); } if (tokens.length > 3) { project.setVersion(RepositoryUtils.toNull(tokens[3])); } if (tokens.length > 4) { project.setClassifier(RepositoryUtils.toNull(tokens[4])); } return project; }
/** * Return a <code>Project</code> object by copying values from the <code>properties</code> object into a <code>Project</code> object. */ public static Project getProject(Properties properties) { List<String> skipKeys = Arrays.asList("project.dependencies"); String startsWith = "project."; List<String> keys = PropertyUtils.getStartsWithKeys(properties, startsWith); Project project = new Project(); project.setProperties(properties); Map<String, Object> description = ReflectionUtils.describe(project); Set<String> beanProperties = description.keySet(); for (String key : keys) { if (skipKeys.contains(key)) { continue; } String value = properties.getProperty(key); String beanProperty = getBeanProperty(key, startsWith); if (beanProperties.contains(beanProperty)) { ReflectionUtils.copyProperty(project, beanProperty, value); } } String csv = RepositoryUtils.toNull(properties.getProperty("project.dependencies")); List<Dependency> dependencies = getDependencies(csv); project.setDependencies(dependencies); return project; }
/** * */ @Deprecated public static org.kuali.common.util.property.ProjectProperties getProjectProperties(ProjectContext context) { // Get a project object based on the context information Project project = loadProject(context); // Create a properties context object from the project.properties file from META-INF PropertiesContext propertiesContext = new PropertiesContext(project.getProperties()); propertiesContext.setEncoding(project.getEncoding()); propertiesContext.setLocations(context.getPropertyLocations()); // Return a project properties object return new org.kuali.common.util.property.ProjectProperties(project, propertiesContext); }
public static org.kuali.common.util.property.ProjectProperties getProjectProperties(org.kuali.common.util.Project project, List<String> locations) { PropertiesContext pc = new PropertiesContext(); pc.setEncoding(project.getEncoding()); pc.setLocations(locations); return new org.kuali.common.util.property.ProjectProperties(project, pc); } }
public static String getProjectId(Project project) { return getProjectId(project.getGroupId(), project.getArtifactId()); }
@Deprecated public static String getGav(Project project) { return getGav(project.getGroupId(), project.getArtifactId()); }
protected String getIdString(ProjectProperties pp) { org.kuali.common.util.Project p = pp.getProject(); StringBuilder sb = new StringBuilder(); sb.append(p.getGroupId()); sb.append(":"); sb.append(p.getArtifactId()); return sb.toString(); }
/** * Use the groupId and artifactId from this project to load the corresponding project.properties file and cache it in our internal Map */ public static synchronized Properties loadProperties(Project project) { String projectId = getProjectId(project.getGroupId(), project.getArtifactId()); Properties properties = PROJECT_PROPERTIES_CACHE.get(projectId); if (properties == null) { properties = loadAndCache(project, projectId); } return properties; }
public static String getPropertiesFileLocation(Project project) { Assert.hasText(project.getGroupId(), "groupId has no text"); Assert.hasText(project.getArtifactId(), "artifactId has no text"); Properties properties = new Properties(); properties.setProperty(Constants.GROUP_ID_PATH_KEY, Str.getPath(project.getGroupId())); properties.setProperty(Constants.ARTIFACT_ID_KEY, project.getArtifactId()); return PPH.replacePlaceholders(Constants.PROJECT_PROPERTIES_LOCATION, properties); }