当前位置: 首页>>代码示例>>Java>>正文


Java Settings.setLocalRepository方法代码示例

本文整理汇总了Java中org.apache.maven.settings.Settings.setLocalRepository方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.setLocalRepository方法的具体用法?Java Settings.setLocalRepository怎么用?Java Settings.setLocalRepository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.settings.Settings的用法示例。


在下文中一共展示了Settings.setLocalRepository方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createEvaluator

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
/**
 * Evaluator usable for interpolating variables in non resolved (interpolated) models.
 * Should not be necessary when dealing with the project's <code>MavenProject</code> instance accessed via<code>NbMavenProject.getMavenProject()</code>
 * Please NOTE that if you have access to <code>Project</code> instance, then
 * the variant with <code>Project</code> as parameter is preferable. Faster and less prone to deadlock.     
 * @since 2.32
 */
public static @NonNull ExpressionEvaluator createEvaluator(@NonNull MavenProject prj) {
    ExpressionEvaluator eval = (ExpressionEvaluator) prj.getContextValue(CONTEXT_EXPRESSION_EVALUATOR);
    if (eval != null) {
        return eval;
    }
    Map<? extends String,? extends String> sysprops = Collections.emptyMap();
    Map<? extends String,? extends String> userprops = Collections.emptyMap();
    File basedir = prj.getBasedir();
    if (basedir != null) {
    FileObject bsd = FileUtil.toFileObject(basedir);
    if (bsd != null) {
        Project p = FileOwnerQuery.getOwner(bsd);
        if (p != null) {
            NbMavenProjectImpl project = p.getLookup().lookup(NbMavenProjectImpl.class);
            if (project != null) {
                sysprops = project.createSystemPropsForPropertyExpressions();
                userprops = project.createUserPropsForPropertyExpressions();
            }
        }
    }
    }
    //ugly
    Settings ss = EmbedderFactory.getProjectEmbedder().getSettings();
    ss.setLocalRepository(EmbedderFactory.getProjectEmbedder().getLocalRepository().getBasedir());

    eval = new NBPluginParameterExpressionEvaluator(
            prj,
            ss,
            sysprops,
            userprops);
    prj.setContextValue(CONTEXT_EXPRESSION_EVALUATOR, eval);
    return eval;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:PluginPropertyUtils.java

示例2: buildSettings

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
private static Settings buildSettings(SettingsBuilder builder,
                                      MavenServerSettings settings,
                                      Properties systemProperties,
                                      Properties userProperties) throws RemoteException {
  SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
  settingsRequest.setGlobalSettingsFile(settings.getGlobalSettingsFile());
  settingsRequest.setUserSettingsFile(settings.getUserSettingsFile());
  settingsRequest.setSystemProperties(systemProperties);
  settingsRequest.setUserProperties(userProperties);

  Settings result = new Settings();
  try {
    result = builder.build(settingsRequest).getEffectiveSettings();
  }
  catch (SettingsBuildingException e) {
    Maven3ServerGlobals.getLogger().info(e);
  }

  result.setOffline(settings.isOffline());

  if (settings.getLocalRepository() != null) {
    result.setLocalRepository(settings.getLocalRepository().getPath());
  }

  if (result.getLocalRepository() == null) {
    result.setLocalRepository(new File(SystemProperties.getUserHome(), ".m2/repository").getPath());
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:Maven30ServerEmbedderImpl.java

示例3: getSettings

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
private Settings getSettings(
    SettingsBuilder builder,
    MavenSettings settings,
    Properties systemProperties,
    Properties userProperties)
    throws RemoteException {
  SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
  request.setGlobalSettingsFile(settings.getGlobalSettings());
  request.setUserSettingsFile(settings.getUserSettings());
  request.setSystemProperties(systemProperties);
  request.setUserProperties(userProperties);

  Settings result = new Settings();
  try {
    result = builder.build(request).getEffectiveSettings();
  } catch (SettingsBuildingException e) {
    MavenServerContext.getLogger().info(e);
  }

  result.setOffline(settings.isOffline());
  if (settings.getLocalRepository() != null) {
    result.setLocalRepository(settings.getLocalRepository().getPath());
  }
  if (result.getLocalRepository() == null) {
    result.setLocalRepository(
        new File(System.getProperty("user.home"), ".m2/repository").getPath());
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:MavenServerImpl.java

示例4: buildSettings

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
private static Settings buildSettings(SettingsBuilder builder,
                                      MavenServerSettings settings,
                                      Properties systemProperties,
                                      Properties userProperties)
  throws RemoteException {
  SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
  settingsRequest.setGlobalSettingsFile(settings.getGlobalSettingsFile());
  settingsRequest.setUserSettingsFile(settings.getUserSettingsFile());
  settingsRequest.setSystemProperties(systemProperties);
  settingsRequest.setUserProperties(userProperties);

  Settings result = new Settings();
  try {
    result = builder.build(settingsRequest).getEffectiveSettings();
  }
  catch (SettingsBuildingException e) {
    Maven3ServerGlobals.getLogger().info(e);
  }

  result.setOffline(settings.isOffline());

  if (settings.getLocalRepository() != null) {
    result.setLocalRepository(settings.getLocalRepository().getPath());
  }

  if (result.getLocalRepository() == null) {
    result.setLocalRepository(new File(SystemProperties.getUserHome(), ".m2/repository").getPath());
  }

  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:Maven3ServerEmbedderImpl.java

示例5: build

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
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() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:38,代码来源:DefaultSettingsBuilder.java

示例6: generateSettingsXml

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
/**
 * methode to generate a custom mvn consumer settings.xml file
 * 
 * @return
 */
private String generateSettingsXml() {
	Settings settings = new Settings();
	settings.setLocalRepository(localRepository);

	//		
	// <mirror>
	// <id>FTRDProxy_central</id>
	// <mirrorOf>central</mirrorOf>
	// <name>FTRD Maven Proxy mirroring central (maven 2) repository</name>
	// </mirror>
	//		

	Mirror mirror = new Mirror();
	mirror.setId(mirrorId);
	mirror.setName("Paas Maven Repo");
	mirror.setUrl(mirrorUrl);
	mirror.setMirrorOf("*");
	settings.getMirrors().add(mirror);

	List<org.apache.maven.settings.Server> servers = new ArrayList<org.apache.maven.settings.Server>();

	org.apache.maven.settings.Server paasInhouse = new org.apache.maven.settings.Server();
	paasInhouse.setId("paas.push.release.repo");
	paasInhouse.setUsername(releaseRepositoryUser);
	paasInhouse.setPassword(releaseRepositoryPassword);
	servers.add(paasInhouse);

	org.apache.maven.settings.Server paasInhouseSnapshot = new org.apache.maven.settings.Server();
	paasInhouseSnapshot.setId("paas.push.snapshot.repo");
	paasInhouseSnapshot.setUsername(snapshotRepositoryUser);
	paasInhouseSnapshot.setPassword(snapshotRepositoryPassword);
	servers.add(paasInhouseSnapshot);

	settings.setServers(servers);

	DefaultSettingsWriter settingsWriter = new DefaultSettingsWriter();

	try {

		StringWriter aWriter = new StringWriter();
		settingsWriter.write(aWriter, null, settings);

		logger.info("settings xml for project sucessfully generated");

		return aWriter.toString();

	} catch (IOException e) {
		logger.error("settings.xml construction failure, JaxbException :" + e.getMessage());
		throw new TechnicalException(e);
	}
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:57,代码来源:SettingsGenerator.java

示例7: getSettings

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
public Settings getSettings()
{
   try
   {
      SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance();
      SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
      String userSettingsLocation = System.getProperty(ALT_USER_SETTINGS_XML_LOCATION);
      // TeamCity sets the settings.xml in a different system property
      String teamCitySettingsLocation = System.getProperty("teamcity.maven.userSettings.path");
      if (userSettingsLocation != null)
      {
         settingsRequest.setUserSettingsFile(new File(userSettingsLocation));
      }
      else if (teamCitySettingsLocation != null)
      {
         settingsRequest.setUserSettingsFile(new File(teamCitySettingsLocation));
      }
      else
      {
         settingsRequest.setUserSettingsFile(new File(getUserHomeDir(), "/.m2/settings.xml"));
      }
      String globalSettingsLocation = System.getProperty(ALT_GLOBAL_SETTINGS_XML_LOCATION);
      if (globalSettingsLocation != null)
      {
         settingsRequest.setGlobalSettingsFile(new File(globalSettingsLocation));
      }
      else
      {
         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)
      {
         String userRepositoryLocation = System.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
         if (userRepositoryLocation != null)
         {
            effectiveSettings.setLocalRepository(userRepositoryLocation);
         }
         else
         {
            effectiveSettings.setLocalRepository(getUserHomePath() + "/.m2/repository");
         }
      }

      return effectiveSettings;
   }
   catch (SettingsBuildingException e)
   {
      throw new RuntimeException(e);
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:57,代码来源:MavenContainer.java

示例8: merge

import org.apache.maven.settings.Settings; //导入方法依赖的package包/类
/**
 * @param dominant
 * @param recessive
 * @param recessiveSourceLevel
 */
public void merge( Settings dominant, Settings recessive, String recessiveSourceLevel )
{
    if ( dominant == null || recessive == null )
    {
        return;
    }

    recessive.setSourceLevel( recessiveSourceLevel );

    List<String> dominantActiveProfiles = dominant.getActiveProfiles();
    List<String> recessiveActiveProfiles = recessive.getActiveProfiles();

    if ( recessiveActiveProfiles != null )
    {
        if ( dominantActiveProfiles == null )
        {
            dominantActiveProfiles = new ArrayList<String>();
            dominant.setActiveProfiles( dominantActiveProfiles );
        }

        for ( String profileId : recessiveActiveProfiles )
        {
            if ( !dominantActiveProfiles.contains( profileId ) )
            {
                dominantActiveProfiles.add( profileId );
            }
        }
    }

    List<String> dominantPluginGroupIds = dominant.getPluginGroups();

    List<String> recessivePluginGroupIds = recessive.getPluginGroups();

    if ( recessivePluginGroupIds != null )
    {
        if ( dominantPluginGroupIds == null )
        {
            dominantPluginGroupIds = new ArrayList<String>();
            dominant.setPluginGroups( dominantPluginGroupIds );
        }

        for ( String pluginGroupId : recessivePluginGroupIds )
        {
            if ( !dominantPluginGroupIds.contains( pluginGroupId ) )
            {
                dominantPluginGroupIds.add( pluginGroupId );
            }
        }
    }

    if ( StringUtils.isEmpty( dominant.getLocalRepository() ) )
    {
        dominant.setLocalRepository( recessive.getLocalRepository() );
    }

    shallowMergeById( dominant.getMirrors(), recessive.getMirrors(), recessiveSourceLevel );
    shallowMergeById( dominant.getServers(), recessive.getServers(), recessiveSourceLevel );
    shallowMergeById( dominant.getProxies(), recessive.getProxies(), recessiveSourceLevel );
    shallowMergeById( dominant.getProfiles(), recessive.getProfiles(), recessiveSourceLevel );

}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:67,代码来源:MavenSettingsMerger.java


注:本文中的org.apache.maven.settings.Settings.setLocalRepository方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。