/** * The method that is used to determine the SCM type based on the SCM url pattern * @see <a href="https://maven.apache.org/components/scm/scm-url-format.html">Maven SCM URL Format</a> * @param scmUrl - the SCM url that needs to be parsed to determine the SCM type, the value of url is typically the * "connection" or "developerConnection" element value of the maven <scm/> * @return String - the SCM type, e.g. for git it will be "git" , for subversion it will be "svn" * @throws ScmRepositoryException - any SCM related exceptions that might happen when checking the SCM type * @throws NoSuchScmProviderException - if an invalid url is given as part of maven <scm> "connection" or "developerConnection" */ public String getScmType(String scmUrl) throws ScmRepositoryException, NoSuchScmProviderException { return ScmUrlUtils.getProvider(scmUrl); }
/** * Get the provider specific part of the scm url. * * @param scmUrl A valid scm url to parse * @return The provider specific part of the scm url */ public static String getProviderSpecificPart( String scmUrl ) { String delimiter = getDelimiter( scmUrl ); scmUrl = scmUrl.substring( 4 ); int firstDelimiterIndex = scmUrl.indexOf( delimiter ); return scmUrl.substring( firstDelimiterIndex + 1 ); }
/** * Validate that the scm url is in the correct format. * <p/> * <strong>Note</strong>: does not validate scm provider specific format. * </p> * * @param scmUrl The scm url to validate * @return <code>true</code> if the scm url is in the correct format, * otherwise <code>false</code> */ public static boolean isValid( String scmUrl ) { List<String> messages = validate( scmUrl ); return messages.isEmpty(); }
/** * {@inheritDoc} */ public List<String> validateScmRepository( String scmUrl ) { List<String> messages = new ArrayList<String>(); messages.addAll( ScmUrlUtils.validate( scmUrl ) ); String providerType = ScmUrlUtils.getProvider( scmUrl ); ScmProvider provider; try { provider = getProviderByType( providerType ); } catch ( NoSuchScmProviderException e ) { messages.add( "No such provider installed '" + providerType + "'." ); return messages; } String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) ); List<String> providerMessages = provider.validateScmUrl( scmSpecificUrl, ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ) ); if ( providerMessages == null ) { throw new RuntimeException( "The SCM provider cannot return null from validateScmUrl()." ); } messages.addAll( providerMessages ); return messages; }
/** * {@inheritDoc} */ public ScmRepository makeScmRepository( String scmUrl ) throws ScmRepositoryException, NoSuchScmProviderException { if ( scmUrl == null ) { throw new NullPointerException( "The scm url cannot be null." ); } char delimiter = ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ); String providerType = ScmUrlUtils.getProvider( scmUrl ); ScmProvider provider = getProviderByType( providerType ); String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) ); ScmProviderRepository providerRepository = provider.makeProviderScmRepository( scmSpecificUrl, delimiter ); return new ScmRepository( providerType, providerRepository ); }
/** * {@inheritDoc} */ public List<String> validateScmRepository( String scmUrl ) { List<String> messages = new ArrayList<String>(); messages.addAll( ScmUrlUtils.validate( scmUrl ) ); String providerType = ScmUrlUtils.getProvider( scmUrl ); ScmProvider provider; try { provider = getProviderByType( providerType ); } catch ( NoSuchScmProviderException e ) { messages.add( "No such provider installed '" + providerType + "'." ); return messages; } String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) ); List<String> providerMessages = provider.validateScmUrl( scmSpecificUrl, ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ) ); if ( providerMessages == null ) { throw new RuntimeException( "The SCM provider cannot return null from validateScmUrl()." ); } messages.addAll( providerMessages ); return messages; }
/** * {@inheritDoc} */ public ScmRepository makeScmRepository( String scmUrl ) throws ScmRepositoryException, NoSuchScmProviderException { if ( scmUrl == null ) { throw new NullPointerException( "The scm url cannot be null." ); } char delimiter = ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ); String providerType = ScmUrlUtils.getProvider( scmUrl ); ScmProvider provider = getProviderByType( providerType ); String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) ); ScmProviderRepository providerRepository = provider.makeProviderScmRepository( scmSpecificUrl, delimiter ); return new ScmRepository( providerType, providerRepository ); }
/** * {@inheritDoc} */ public ScmProvider getProviderByUrl( String scmUrl ) throws ScmRepositoryException, NoSuchScmProviderException { if ( scmUrl == null ) { throw new NullPointerException( "The scm url cannot be null." ); } String providerType = ScmUrlUtils.getProvider( scmUrl ); return getProviderByType( providerType ); }
/** * Get the scm provider from the scm url. * * @param scmUrl A valid scm url to parse * @return The scm provider from the scm url */ public static String getProvider( String scmUrl ) { String delimiter = getDelimiter( scmUrl ); scmUrl = scmUrl.substring( 4 ); int firstDelimiterIndex = scmUrl.indexOf( delimiter ); return scmUrl.substring( 0, firstDelimiterIndex ); }
/** * Validate that the scm url is in the correct format. * <p/> * <strong>Note</strong>: does not validate scm provider specific format. * </p> * * @param scmUrl The scm url to validate * @return <code>true</code> if the scm url is in the correct format, * otherwise <code>false</code> */ public static boolean isValid( String scmUrl ) { List<String> messages = validate( scmUrl ); return messages.isEmpty(); }
/** * {@inheritDoc} */ public ScmProvider getProviderByUrl( String scmUrl ) throws ScmRepositoryException, NoSuchScmProviderException { if ( scmUrl == null ) { throw new NullPointerException( "The scm url cannot be null." ); } String providerType = ScmUrlUtils.getProvider( scmUrl ); return getProviderByType( providerType ); }
/** * Get the provider specific part of the scm url. * * @param scmUrl A valid scm url to parse * @return The provider specific part of the scm url */ public static String getProviderSpecificPart( String scmUrl ) { String delimiter = getDelimiter( scmUrl ); scmUrl = scmUrl.substring( 4 ); int firstDelimiterIndex = scmUrl.indexOf( delimiter ); return scmUrl.substring( firstDelimiterIndex + 1 ); }
String providerType = ScmUrlUtils.getProvider( scmUrl );
/** * Get the scm provider from the scm url. * * @param scmUrl A valid scm url to parse * @return The scm provider from the scm url */ public static String getProvider( String scmUrl ) { String delimiter = getDelimiter( scmUrl ); scmUrl = scmUrl.substring( 4 ); int firstDelimiterIndex = scmUrl.indexOf( delimiter ); return scmUrl.substring( 0, firstDelimiterIndex ); }
String providerType = ScmUrlUtils.getProvider( releaseDescriptor.getScmSourceUrl() ); String scmSpecificUrl = releaseDescriptor.getScmSourceUrl().substring( providerType.length() + 5 );
getDelimiter( scmUrl );