diff options
Diffstat (limited to 'src/main/java/org/gentoo/java/ebuilder/maven/MavenLicenses.java')
-rw-r--r-- | src/main/java/org/gentoo/java/ebuilder/maven/MavenLicenses.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenLicenses.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenLicenses.java new file mode 100644 index 0000000..e2db62c --- /dev/null +++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenLicenses.java @@ -0,0 +1,62 @@ +package org.gentoo.java.ebuilder.maven; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * translate licenses from pom.xml to portage + * + * @author Zhang Zongyu + */ +public class MavenLicenses { + + /** + * Location of the resource file mapping licenses. + */ + private static final String licenseMapFile + = "/licenseMap.properties"; + + /** + * the Map that will convert license from maven + * to portage. + */ + private Map<String, String> licenseMap; + + /** + * Load cache from resource + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + MavenLicenses() { + Properties mapProperty = new Properties(); + try { + mapProperty.load( + this.getClass().getResourceAsStream( + licenseMapFile)); + } catch (final IOException ex) { + throw new RuntimeException( + "Failed to read license map from resource", ex); + } + + licenseMap = (Map)mapProperty; + } + + /** + * query the LicenseMap + * + * @param licenseName the licenses/license/name in pom.xml + * + * @return license identifier that works with Portage + */ + public String getEquivalentLicense(String licenseName) { + final String portageLicense = licenseMap.get(licenseName); + + if (portageLicense == null) { + return "!!!equivalentPortageLicenseName-not-found!!!"; + } else { + return portageLicense; + } + } +} |