@Test public void testGetDefaultPropertiesOnMinimalPom() throws Exception { Model model = new Model(); model.setPomFile(new File("target/test-classes/maven/test/minimal.xml")); MavenProject project = new MavenProject(model); project.setFile(new File("target/test-classes/maven/test/minimal.xml")); project.setArtifactId("acme"); project.setGroupId("corp.acme"); project.setVersion("1.0.0-SNAPSHOT"); final ProjectArtifact artifact = new ProjectArtifact(project); project.setArtifact(artifact); Build build = new Build(); build.setDirectory(new File(project.getBasedir(), "target").getAbsolutePath()); build.setOutputDirectory(new File(project.getBasedir(), "target/classes").getAbsolutePath()); project.setBuild(build); Properties properties = MavenUtils.getDefaultProperties(project); assertThat(properties.getProperty("maven-symbolicname")).isEqualTo(DefaultMaven2OsgiConverter .getBundleSymbolicName(artifact)); assertThat(properties.getProperty(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME)).isEqualTo(DefaultMaven2OsgiConverter .getBundleSymbolicName(artifact)); assertThat(properties.getProperty(org.osgi.framework.Constants.BUNDLE_VERSION)).isEqualTo(DefaultMaven2OsgiConverter .getVersion(project.getVersion())); assertThat(properties.getProperty(org.osgi.framework.Constants.BUNDLE_DESCRIPTION)).isNull(); assertThat(properties.getProperty(Analyzer.BUNDLE_LICENSE)).isNull(); assertThat(properties.getProperty(Analyzer.BUNDLE_VENDOR)).isNull(); assertThat(properties.getProperty(Analyzer.BUNDLE_DOCURL)).isNull(); assertThat(properties.getProperty(Analyzer.BUNDLE_LICENSE)).isNull(); assertThat(properties.getProperty(Analyzer.BUNDLE_NAME)).isEqualTo(project.getArtifactId()); }
public static Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact()); properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put("bundle.file.name", DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact())); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion())); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuilder licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getModel().getProperties()); for (String s : currentProject.getFilters()) { File filterFile = new File(s); if (filterFile.isFile()) { properties.putAll(PropertyUtils.loadProperties(filterFile)); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath()); properties.put("project.build.directory", currentProject.getBuild().getDirectory()); properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory()); properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots())); properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots())); properties.put("project.resources", toString(currentProject.getResources())); properties.put("project.testResources", toString(currentProject.getTestResources())); return properties; }
MavenUtils { public static Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact()); properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put("bundle.file.name", DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact())); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion())); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuilder licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getModel().getProperties()); for (String s : currentProject.getFilters()) { File filterFile = new File(s); if (filterFile.isFile()) { properties.putAll(PropertyUtils.loadProperties(filterFile)); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath()); properties.put("project.build.directory", currentProject.getBuild().getDirectory()); properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory()); properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots())); properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots())); properties.put("project.resources", toString(currentProject.getResources())); properties.put("project.testResources", toString(currentProject.getTestResources())); return properties; } }
MavenUtils { public static Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact()); properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put("bundle.file.name", DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact())); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion())); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuilder licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getModel().getProperties()); for (String s : currentProject.getFilters()) { File filterFile = new File(s); if (filterFile.isFile()) { properties.putAll(PropertyUtils.loadProperties(filterFile)); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath()); properties.put("project.build.directory", currentProject.getBuild().getDirectory()); properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory()); properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots())); properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots())); properties.put("project.resources", toString(currentProject.getResources())); properties.put("project.testResources", toString(currentProject.getTestResources())); return properties; }  }
MavenUtils { public static Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact()); properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put("bundle.file.name", DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact())); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion())); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuilder licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getModel().getProperties()); for (String s : currentProject.getFilters()) { File filterFile = new File(s); if (filterFile.isFile()) { properties.putAll(PropertyUtils.loadProperties(filterFile)); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath()); properties.put("project.build.directory", currentProject.getBuild().getDirectory()); properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory()); properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots())); properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots())); properties.put("project.resources", toString(currentProject.getResources())); properties.put("project.testResources", toString(currentProject.getTestResources())); return properties; }  static Properties getDefaultProperties(MavenProject currentProject); }
MavenUtils { public static Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact()); properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put("bundle.file.name", DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact())); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion())); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuilder licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getModel().getProperties()); for (String s : currentProject.getFilters()) { File filterFile = new File(s); if (filterFile.isFile()) { properties.putAll(PropertyUtils.loadProperties(filterFile)); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath()); properties.put("project.build.directory", currentProject.getBuild().getDirectory()); properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory()); properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots())); properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots())); properties.put("project.resources", toString(currentProject.getResources())); properties.put("project.testResources", toString(currentProject.getTestResources())); return properties; }  static Properties getDefaultProperties(MavenProject currentProject); static final String MAVEN_SYMBOLICNAME; }