Skip to content

Commit

Permalink
Merge pull request #7 from telekom/maven_central
Browse files Browse the repository at this point in the history
Test script for deployment to Maven central
  • Loading branch information
Anrufliste authored May 17, 2023
2 parents 9549a1e + 11c37d6 commit 97dfc16
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 76 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,28 @@ jobs:
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
# Verify gpg secret key
gpg --list-secret-keys --keyid-format LONG
- uses: actions/checkout@v3
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish package
run: mvn --batch-mode deploy
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
- id: publish-to-central
name: Publish to Central Repository
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
run: |
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
clean deploy
113 changes: 93 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>de.telekom.phonenumber</groupId>
<artifactId>normalizer</artifactId>
<name>Phonenumber Normalizer</name>
<description>Library to work with phonenumbers, especially to fix googles PhoneLib ignoring German Landline specifics.</description>
<version>1.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<licenses>
<license>
Expand All @@ -33,6 +33,26 @@
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>Emil Thies</name>
<email>[email protected]</email>
<organization>Deutsche Telekom AG</organization>
<organizationUrl>https://github.com/telekom</organizationUrl>
</developer>
<developer>
<name>Jens Hellwig</name>
<email>[email protected]</email>
<organization>Deutsche Telekom AG</organization>
<organizationUrl>https://github.com/telekom</organizationUrl>
</developer>
<developer>
<name>Kai Kreuzer</name>
<email>[email protected]</email>
<organization>Deutsche Telekom AG</organization>
<organizationUrl>https://github.com/telekom</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/telekom/phonenumber-normalizer.git</connection>
Expand Down Expand Up @@ -120,15 +140,15 @@
<version>2.203</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.17</version>
<scope>test</scope>
<type>pom</type>
<exclusions>
<exclusion>
<!-- Used Version 7.5 has https://devhub.checkmarx.com/cve-details/CVE-2022-4065/?utm_source=jetbrains&utm_medium=referral&utm_campaign=idea&utm_term=maven -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.17</version>
<scope>test</scope>
<type>pom</type>
<exclusions>
<exclusion>
<!-- Used Version 7.5 has https://devhub.checkmarx.com/cve-details/CVE-2022-4065/?utm_source=jetbrains&utm_medium=referral&utm_campaign=idea&utm_term=maven -->
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</exclusion>
Expand Down Expand Up @@ -164,7 +184,6 @@

<build>
<plugins>

<!-- Configure JaCoCo -->
<plugin>
<groupId>org.jacoco</groupId>
Expand Down Expand Up @@ -214,17 +233,63 @@
<year>2023</year>
</properties>
<licenseSets>
<licenseSet>
<header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
<excludes>
<exclude>**/README</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/**</exclude>
</excludes>
</licenseSet>
<licenseSet>
<header>com/mycila/maven/plugin/license/templates/APACHE-2.txt</header>
<excludes>
<exclude>**/README</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/**</exclude>
</excludes>
</licenseSet>
</licenseSets>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-source</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

<pluginManagement>
Expand Down Expand Up @@ -299,4 +364,12 @@

</pluginManagement>
</build>
</project>

<distributionManagement>
<repository>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ public interface PhoneNumberAreaLabel {
* Get a location name for a E164 formated number
*
* @param e164number number following E164 schema eg. +4961511234567
* @return Optional<String> - nullable optional with either a national label or if non is available a country label
* @return nullable optional with either a national label or if non is available a country label
*/
Optional<String> getLocationByE164Number(String e164number);

/**
* Get a location name for a nationalnumber and region code
*
* @param nationalNumber - number without the country prefix like 61511234567 (for number +4961511234567)
* @param regionCode - region code for the number plan like de, us
* @return Optional<String> - nullable optional with location name if present
* @param nationalNumber number without the country prefix like 61511234567 (for number +4961511234567)
* @param regionCode region code for the number plan like de, us
* @return nullable optional with location name if present
*/
Optional<String> getLocationByNationalNumberAndRegionCode(String nationalNumber, String regionCode);

/**
* Get country name string by country code
*
* @param countryCode - specific telephony code of country (telephone number prefix) like 49 (Germany), 1 (US),
* @return Optional<String> - nullable optional with country name if present
* @return nullable optional with country name if present
*/
Optional<String> getCountryNameByCountryCode(String countryCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
* Concrete implementation of {@link PhoneNumberAreaLabel}, which is using per default provided label configuration from resources folder:
* <ul>
* <li>Country Calling Code to German Country Names</li>
* <li>AU-NDC: "Weihnachtsinsel" & "Kokosinseln"</li>
* <li>DE-NDC: German City-Names replacing formal abbreviation with long name</>
* <li>RU-NDC: Country seperation "Russland" & "Kasachstan"</li>
* <li>AU-NDC: "Weihnachtsinsel" &amp; "Kokosinseln"</li>
* <li>DE-NDC: German City-Names replacing formal abbreviation with long name</li>
* <li>RU-NDC: Country seperation "Russland" &amp; "Kasachstan"</li>
* <li>US-NDC: For US and CA just the state names</li>
* </ul>
*/
Expand Down Expand Up @@ -85,8 +85,10 @@ public class PhoneNumberAreaLabelImpl implements PhoneNumberAreaLabel {
private HashMap<?, ?> internationalCountryCodes;

/**
* Loading {@link PhoneNumberAreaLabelImpl#internationalCountryCodes} from {@link PhoneNumberAreaLabelImpl#countryCodeResource}<br/>
* Loading {@link PhoneNumberAreaLabelImpl#areaCodes} from {@link PhoneNumberAreaLabelImpl#numberPlanResources}
* <ul>
* <li>Loading {@link PhoneNumberAreaLabelImpl#internationalCountryCodes} from {@link PhoneNumberAreaLabelImpl#countryCodeResource}</li>
* <li>Loading {@link PhoneNumberAreaLabelImpl#areaCodes} from {@link PhoneNumberAreaLabelImpl#numberPlanResources}</li>
* </ul>
*/
@PostConstruct
public void initFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public interface PhoneNumberNormalizer {

/**
* Normalizes the number using PhoneLib with some additions to compensate.
* <p/>
* <p>
* Preferable to {@link PhoneNumberNormalizer#normalizePhoneNumber(String, String)}, because default NDC can be provided, so that more compensation for generating a valid E164 can be done.
* </p>
* @param number plain number to normalize
* @param deviceContext information like CC, NDC and {@link de.telekom.phonenumbernormalizer.dto.DeviceContextLineType} from which the number is dialled
* @return E164 formatted phone number or at least a dialable version of the number
Expand All @@ -47,8 +48,9 @@ public interface PhoneNumberNormalizer {

/**
* Normalizes the number using PhoneLib with some additions to compensate.
* <p/>
* <p>
* Not as powerful as {@link PhoneNumberNormalizer#normalizePhoneNumber(String, DeviceContext)}, because no default NDC can be set.
* </p>
* @param number plain number to normalize
* @param regionCode ISO2 code of the country, which number-plan is used for normalization
* @return E164 formatted phone number or at least a dialable version of the number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@


/**
* Concrete implementation of {@link PhoneNumberNormalizer} using {@link PhoneLibWrapper} to normalize a number by mitigating some inaccuracies when it comes to number plans of optional NDC and NAC as zero.<br/>
* Concrete implementation of {@link PhoneNumberNormalizer} using {@link PhoneLibWrapper} to normalize a number by mitigating some inaccuracies when it comes to number plans of optional NDC and NAC as zero.
* <p>
* Also supports {@link DeviceContext} to enrich a phone number during normalization if the optional NDC is missing.
* </p>
*/
@RequiredArgsConstructor
@Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public interface DeviceContext {
/**
* Getter for the Country (Calling) Code of the countries number plan, where the device is originated.
* Without international dialing prefix nor trunc code. If not known or not set, it should return DeviceContext.UNKNOWN_VALUE.
* <p/>
* <p>
* E.G. "49" for Germany
*
* </p>
* @return either a string containing one to three digits representing a country calling code or "unknown"
*
* @see DeviceContext#getCountryCode()
Expand All @@ -68,9 +68,9 @@ public interface DeviceContext {
/**
* Setter for the Country (Calling) Code of the countries number plan, where the device is originated.
* Without international deailing prefix nor trunc code. If not known it should be set to DeviceContext.UNKNOWN_VALUE.
* <p/>
* <p>
* E.G. "49" for Germany
*
* </p>
* @param countryCode either a string containing one to three digits representing a country calling code or "unknown"
*
* @see DeviceContext#getCountryCode()
Expand All @@ -81,9 +81,9 @@ public interface DeviceContext {
/**
* Getter for the National Destination Code (NDC) of the countries number plan, where the device is originated.
* Without National Access Code (NAC) nor trunc code. If not known or not set, it should return DeviceContext.UNKNOWN_VALUE.
* <p/>
* <p>
* E.G. "228" for Bonn in Germany where the Deutsche Telekom Headquarter is located
*
* </p>
* @return either a string containing a variable amount of digits representing a country calling code or "unknown"
*
* @see DeviceContext#setNationalDestinationCode(String)
Expand All @@ -94,9 +94,9 @@ public interface DeviceContext {
/**
* Setter for the National Destination Code (NDC) of the countries number plan, where the device is originated.
* Without National Access Code (NAC) nor trunc code. If not known it should be set to DeviceContext.UNKNOWN_VALUE.
* <p/>
* <p>
* E.G. "228" for Bonn in Germany where the Deutsche Telekom Headquarter is located
*
* </p>
* @param nationalDestinationCode either a string containing a variable amount of digits representing a country calling code or "unknown"
*
* @see DeviceContext#getCountryCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

/**
* The enum values define the line-type in the context of a device involved in the call
* <p/>
* <p>
* Currently supported values are for fixed-line, mobile and unknown (also for anything else).
*
* </p>
* @see DeviceContextLineType#FIXEDLINE
* @see DeviceContextLineType#MOBILE
* @see DeviceContextLineType#UNKNOWN
Expand Down Expand Up @@ -163,7 +163,7 @@ public static DeviceContextLineType of(String value) {

/**
* Return the string representation of a line-type enum value
* @return (String) - line-type string representation
* @return line-type string representation
*
* @see DeviceContextLineType#FIXEDLINE_VALUE
* @see DeviceContextLineType#MOBILE_VALUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@
/**
* This class provides basic logic to check a given number against a simple set of rules to identify if it is short numbers, which does not need normalization.
* It also needs to provide its country calling code, to specify where the rules apply.
* <p/>
* <p>
* PhoneLib already provide a ShortNumbers, but for EU wide 116xxx range only a few countries are configured to support the range.
* For Germany only currently assigned numbers are configured which is in contrast to Googles definition of checks,
* but nevertheless the <a href="https://issuetracker.google.com/u/1/issues/183669955">corresponding Issues</a> has been rejected.
* <p/>
* </p><p>
* Additionally, we designed the NumberPlanFactory to have a NumberPlan class for each DeviceContextLineType, so we can support short numbers which are valid only in fixed-line or mobile context.
*
* </p>
* @see NumberPlanFactory
* @see de.telekom.phonenumbernormalizer.dto.DeviceContextLineType
*/
public abstract class NumberPlan {
private static final Logger LOGGER = LoggerFactory.getLogger(NumberPlan.class);

/**
* A subclass needs to provide a Map<String, Integer> as tbe rules to identify short numbers
* A subclass needs to provide a Map&lt;String, Integer&gt; as tbe rules to identify short numbers
* The key (String) is representing a prefix for the number and the value (Integer) is the total length of the short code (including the prefix)
* <p/>
* e.g. "110"; 3 - the total length is already the length of the prefix, so its exactly the short number
* e.g. "1100"; 5 - the total length is longer than the length of the prefix, so all number from 11000 to 11009 are coverd
* e.g. both rules above can be combined, because longer prefixes are evaluated first, so that partical ranges of rules with shorter prefix can be overriden.
*
* <ul>
* <li>e.g. "110"; 3 - the total length is already the length of the prefix, so its exactly the short number</li>
* <li>e.g. "1100"; 5 - the total length is longer than the length of the prefix, so all number from 11000 to 11009 are coverd</li>
* <li>e.g. both rules above can be combined, because longer prefixes are evaluated first, so that partical ranges of rules with shorter prefix can be overriden.</li>
* </ul>
* @return Map of rules for the short codes
*
* @see NumberPlan#isNumberPlanValid()
Expand Down
Loading

0 comments on commit 97dfc16

Please sign in to comment.