org.apache.maven.settings.Settings.setLocalRepository()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.apache.maven.settings.Settings.setLocalRepository()方法的一些代码示例,展示了Settings.setLocalRepository()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.setLocalRepository()方法的具体详情如下:
包路径:org.apache.maven.settings.Settings
类名称:Settings
方法名:setLocalRepository

Settings.setLocalRepository介绍

[英]Set the local repository.
Default value is:${user.home}/.m2/repository
[中]设置本地存储库。
默认值为:${user.home}/.m2/repository

代码示例

代码示例来源:origin: apache/maven

@Override
public SettingsBuildingResult build( SettingsBuildingRequest request )
  throws SettingsBuildingException
{
  DefaultSettingsProblemCollector problems = new DefaultSettingsProblemCollector( null );
  Source globalSettingsSource =
    getSettingsSource( request.getGlobalSettingsFile(), request.getGlobalSettingsSource() );
  Settings globalSettings = readSettings( globalSettingsSource, request, problems );
  Source userSettingsSource =
    getSettingsSource( request.getUserSettingsFile(), request.getUserSettingsSource() );
  Settings userSettings = readSettings( userSettingsSource, request, problems );
  settingsMerger.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL );
  problems.setSource( "" );
  userSettings = interpolate( userSettings, request, problems );
  // for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
  String localRepository = userSettings.getLocalRepository();
  if ( localRepository != null && localRepository.length() > 0 )
  {
    File file = new File( localRepository );
    if ( !file.isAbsolute() && file.getPath().startsWith( File.separator ) )
    {
      userSettings.setLocalRepository( file.getAbsolutePath() );
    }
  }
  if ( hasErrors( problems.getProblems() ) )
  {
    throw new SettingsBuildingException( problems.getProblems() );
  }
  return new DefaultSettingsBuildingResult( userSettings, problems.getProblems() );
}

代码示例来源:origin: apache/maven

dominant.setLocalRepository( recessive.getLocalRepository() );

代码示例来源:origin: apache/maven

settings.setLocalRepository( interpolatedTrimmed( parser.nextText(), "localRepository" ) );

代码示例来源:origin: apache/maven

/**
   * @param settings could be null
   * @return a new instance of settings or null if settings was null.
   */
  public static Settings copySettings( Settings settings )
  {
    if ( settings == null )
    {
      return null;
    }

    Settings clone = new Settings();
    clone.setActiveProfiles( settings.getActiveProfiles() );
    clone.setInteractiveMode( settings.isInteractiveMode() );
    clone.setLocalRepository( settings.getLocalRepository() );
    clone.setMirrors( settings.getMirrors() );
    clone.setModelEncoding( settings.getModelEncoding() );
    clone.setOffline( settings.isOffline() );
    clone.setPluginGroups( settings.getPluginGroups() );
    clone.setProfiles( settings.getProfiles() );
    clone.setProxies( settings.getProxies() );
    clone.setServers( settings.getServers() );
    clone.setSourceLevel( settings.getSourceLevel() );
    clone.setUsePluginRegistry( settings.isUsePluginRegistry() );

    return clone;
  }
}

代码示例来源:origin: ru.yandex.qatools.clay/clay-maven-settings-builder

/**
 * Set the local repository.<br /><b>Default value is:</b>
 * <tt>${user.home}/.m2/repository</tt>
 *
 * @param localRepository
 */
public FluentSettingsBuilder withLocalRepository(String localRepository) {
  if (localRepository == null) return this;
  settings.setLocalRepository(localRepository);
  return this;
}

代码示例来源:origin: ru.yandex.qatools.clay/clay-maven-settings-builder

public FluentSettingsBuilder withLocalRepository(File localRepository) {
  if (localRepository == null) return this;
  settings.setLocalRepository(localRepository.getAbsolutePath());
  return this;
}

代码示例来源:origin: org.apache.maven/maven-settings

settings.setLocalRepository( interpolatedTrimmed( parser.nextText(), "localRepository" ) );

代码示例来源:origin: org.jboss.shrinkwrap.resolver/shrinkwrap-resolver-impl-maven

private Settings enrichWithLocalRepository(Settings settings) {
  // set default value if not set at all
  if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) {
    settings.setLocalRepository(DEFAULT_REPOSITORY_PATH);
  }
  // override any value with system property based location
  String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
  if (altLocalRepository != null && altLocalRepository.length() > 0) {
    settings.setLocalRepository(altLocalRepository);
  }
  return settings;
}

代码示例来源:origin: shrinkwrap/resolver

private Settings enrichWithLocalRepository(Settings settings) {
  // set default value if not set at all
  if (settings.getLocalRepository() == null || settings.getLocalRepository().length() == 0) {
    settings.setLocalRepository(DEFAULT_REPOSITORY_PATH);
  }
  // override any value with system property based location
  String altLocalRepository = SecurityActions.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
  if (altLocalRepository != null && altLocalRepository.length() > 0) {
    settings.setLocalRepository(altLocalRepository);
  }
  return settings;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-maven-embedder

/**
 * this method  should rather use the embedder's settings, however there's no clear
 * way of retrieving/using them.
 * @deprecated rather not use, doesn't contain the global setting values
 */
@Deprecated
public Settings getSettings() {
  //TODO need probably some kind of caching..
  Settings sets = createUserSettingsModel();
  if (sets.getLocalRepository() == null) {
    sets.setLocalRepository(new File(getM2UserDir(), "repository").toString());
  }
  return sets;
}

代码示例来源:origin: org.codehaus.mevenide/nb-mvn-embedder

/**
 * this method  should rather use the embedder's settings, however there's no clear
 * way of retrieving/using them.
 * @deprecated rather not use, doesn't contain the global setting values
 */
@Deprecated
public Settings getSettings() {
  //TODO need probably some kind of caching..
  Settings sets = createUserSettingsModel();
  if (sets.getLocalRepository() == null) {
    sets.setLocalRepository(new File(getM2UserDir(), "repository").toString());
  }
  return sets;
}

代码示例来源:origin: ru.yandex.qatools.clay/clay-maven-settings-builder

public static FluentSettingsBuilder newSettings() {
  Settings settings = new Settings();
  settings.setLocalRepository(getDefaultLocalRepository());
  return new FluentSettingsBuilder(settings);
}

代码示例来源:origin: org.uberfire/uberfire-maven-integration

String userHome = System.getProperty( "user.home" );
if (userHome != null) {
  settings.setLocalRepository( userHome + "/.m2/repository" );
} else {
  log.error("Cannot find maven local repository");

代码示例来源:origin: org.kie.soup/kie-soup-maven-integration

String userHome = System.getProperty( "user.home" );
if (userHome != null) {
  settings.setLocalRepository( userHome + "/.m2/repository" );
} else {
  log.error("Cannot find maven local repository");

代码示例来源:origin: ru.yandex.qatools.clay/clay-maven-settings-builder

public static FluentSettingsBuilder loadSettings(File settingsFile)
    throws FileNotFoundException, SettingsBuildingException {
  if (settingsFile == null) {
    throw new NullPointerException("Settings file can't be null");
  }
  if (!settingsFile.exists()) {
    throw new FileNotFoundException(String.format("Settings file [%s] not found",
        settingsFile.getAbsoluteFile()));
  }
  DefaultSettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
  request.setGlobalSettingsFile(settingsFile);
  Settings settings = new DefaultSettingsBuilderFactory()
      .newInstance()
      .build(request)
      .getEffectiveSettings();
  if (settings.getLocalRepository() == null) {
    settings.setLocalRepository(getDefaultLocalRepository());
  }
  return new FluentSettingsBuilder(settings);
}

代码示例来源:origin: org.codehaus.mevenide/nb-project

locrepo = null;
sett.setLocalRepository(locrepo);

代码示例来源:origin: org.jboss.forge/maven-impl

public Settings getSettings()
{
 try
 {
   SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance();
   SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
   settingsRequest
       .setUserSettingsFile(new File(getUserHomeDir(), "/.m2/settings.xml"));
   if (M2_HOME != null)
    settingsRequest.setGlobalSettingsFile(new File(M2_HOME, "/conf/settings.xml"));
   SettingsBuildingResult settingsBuildingResult = settingsBuilder.build(settingsRequest);
   Settings effectiveSettings = settingsBuildingResult.getEffectiveSettings();
   if (effectiveSettings.getLocalRepository() == null)
   {
    effectiveSettings.setLocalRepository(getUserHomePath() + "/.m2/repository");
   }
   return effectiveSettings;
 }
 catch (SettingsBuildingException e)
 {
   throw new RuntimeException(e);
 }
}

代码示例来源:origin: org.apache.maven/maven-settings-builder

@Override
public SettingsBuildingResult build( SettingsBuildingRequest request )
  throws SettingsBuildingException
{
  DefaultSettingsProblemCollector problems = new DefaultSettingsProblemCollector( null );
  Source globalSettingsSource =
    getSettingsSource( request.getGlobalSettingsFile(), request.getGlobalSettingsSource() );
  Settings globalSettings = readSettings( globalSettingsSource, request, problems );
  Source userSettingsSource =
    getSettingsSource( request.getUserSettingsFile(), request.getUserSettingsSource() );
  Settings userSettings = readSettings( userSettingsSource, request, problems );
  settingsMerger.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL );
  problems.setSource( "" );
  userSettings = interpolate( userSettings, request, problems );
  // for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
  String localRepository = userSettings.getLocalRepository();
  if ( localRepository != null && localRepository.length() > 0 )
  {
    File file = new File( localRepository );
    if ( !file.isAbsolute() && file.getPath().startsWith( File.separator ) )
    {
      userSettings.setLocalRepository( file.getAbsolutePath() );
    }
  }
  if ( hasErrors( problems.getProblems() ) )
  {
    throw new SettingsBuildingException( problems.getProblems() );
  }
  return new DefaultSettingsBuildingResult( userSettings, problems.getProblems() );
}

代码示例来源:origin: io.tesla.maven/maven-settings-builder

public SettingsBuildingResult build( SettingsBuildingRequest request )
  throws SettingsBuildingException
{
  DefaultSettingsProblemCollector problems = new DefaultSettingsProblemCollector( null );
  SettingsSource globalSettingsSource =
    getSettingsSource( request.getGlobalSettingsFile(), request.getGlobalSettingsSource() );
  Settings globalSettings = readSettings( globalSettingsSource, request, problems );
  SettingsSource userSettingsSource =
    getSettingsSource( request.getUserSettingsFile(), request.getUserSettingsSource() );
  Settings userSettings = readSettings( userSettingsSource, request, problems );
  settingsMerger.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL );
  problems.setSource( "" );
  userSettings = interpolate( userSettings, request, problems );
  // for the special case of a drive-relative Windows path, make sure it's absolute to save plugins from trouble
  String localRepository = userSettings.getLocalRepository();
  if ( localRepository != null && localRepository.length() > 0 )
  {
    File file = new File( localRepository );
    if ( !file.isAbsolute() && file.getPath().startsWith( File.separator ) )
    {
      userSettings.setLocalRepository( file.getAbsolutePath() );
    }
  }
  if ( hasErrors( problems.getProblems() ) )
  {
    throw new SettingsBuildingException( problems.getProblems() );
  }
  return new DefaultSettingsBuildingResult( userSettings, problems.getProblems() );
}

代码示例来源:origin: io.fabric8/fabric-maven

settings.setLocalRepository(localRepoPath);

相关文章