@Override protected ExitStatus run(OptionSet options) throws Exception { SourceOptions sourceOptions = new SourceOptions(options); List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration( options, this, repositoryConfiguration); if (System.getProperty("grape.root") == null) { System.setProperty("grape.root", "."); } GroovyCompiler groovyCompiler = new GroovyCompiler(configuration); groovyCompiler.compile(sourceOptions.getSourcesArray()); return ExitStatus.OK; }
@Override protected synchronized ExitStatus run(OptionSet options) throws Exception { synchronized (this.monitor) { if (this.runner != null) { throw new RuntimeException( "Already running. Please stop the current application before running another (use the 'stop' command)."); } SourceOptions sourceOptions = new SourceOptions(options); List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); repositoryConfiguration.add(0, new RepositoryConfiguration("local", new File("repository").toURI(), true)); SpringApplicationRunnerConfiguration configuration = new SpringApplicationRunnerConfigurationAdapter( options, this, repositoryConfiguration); this.runner = new SpringApplicationRunner(configuration, sourceOptions.getSourcesArray(), sourceOptions.getArgsArray()); this.runner.compileAndRun(); return ExitStatus.OK; } }
@Override protected synchronized ExitStatus run(OptionSet options) throws Exception { if (this.runner != null) { throw new RuntimeException( "Already running. Please stop the current application before running another (use the 'stop' command)."); } SourceOptions sourceOptions = new SourceOptions(options); List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); repositoryConfiguration.add(0, new RepositoryConfiguration("local", new File("repository").toURI(), true)); SpringApplicationRunnerConfiguration configuration = new SpringApplicationRunnerConfigurationAdapter( options, this, repositoryConfiguration); this.runner = new SpringApplicationRunner(configuration, sourceOptions.getSourcesArray(), sourceOptions.getArgsArray()); this.runner.compileAndRun(); return ExitStatus.OK; }
private GroovyCompiler createCompiler(OptionSet options) { List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration( options, this, repositoryConfiguration); GroovyCompiler groovyCompiler = new GroovyCompiler(configuration); groovyCompiler.getAstTransformations().add(0, new GrabAnnotationTransform()); return groovyCompiler; }
private static GroovyCompilerConfiguration createCompilerConfiguration( OptionSet options, CompilerOptionHandler compilerOptionHandler) { List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); return new OptionSetGroovyCompilerConfiguration(options, compilerOptionHandler, repositoryConfiguration) { @Override public boolean isAutoconfigure() { return false; } }; }
@Before public void setupResolver() { GroovyCompilerConfiguration configuration = new GroovyCompilerConfiguration() { @Override public boolean isGuessImports() { return true; } @Override public boolean isGuessDependencies() { return true; } @Override public boolean isAutoconfigure() { return false; } @Override public GroovyCompilerScope getScope() { return GroovyCompilerScope.DEFAULT; } @Override public List<RepositoryConfiguration> getRepositoryConfiguration() { return RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); } @Override public String[] getClasspath() { return new String[] { "." }; } }; this.resolver = new GroovyGrabDependencyResolver(configuration); }
private URLClassLoader populateClassloader(OptionSet options) throws MalformedURLException { DependencyResolutionContext resolutionContext = new DependencyResolutionContext(); List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory .createDefaultRepositoryConfiguration(); repositoryConfiguration.add(0, new RepositoryConfiguration("local", new File("repository").toURI(), true)); boolean quiet = true; if (options.has(debugOption)) { System.setProperty("groovy.grape.report.downloads", "true"); quiet = false; } AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create(null, repositoryConfiguration, resolutionContext, quiet); HashMap<String, Object> dependency = new HashMap<>(); dependency.put("group", "org.springframework.cloud.launcher"); dependency.put("module", "spring-cloud-launcher-deployer"); dependency.put("version", getVersion()); dependency.put("transitive", false); URI[] uris = grapeEngine.resolve(null, dependency); URLClassLoader loader = new URLClassLoader(new URL[] { uris[0].toURL() }, getClass().getClassLoader().getParent().getParent()); log.debug("resolved URIs " + Arrays.asList(loader.getURLs())); return loader; }
protected OptionSetGroovyCompilerConfiguration(OptionSet optionSet, CompilerOptionHandler compilerOptionHandler) { this(optionSet, compilerOptionHandler, RepositoryConfigurationFactory.createDefaultRepositoryConfiguration()); }
public static void install(GroovyClassLoader classLoader) { install(classLoader, new DependencyResolutionContext(), RepositoryConfigurationFactory .createDefaultRepositoryConfiguration()); }
public DefaultAetherGrapeEngine() { groovyClassLoader = getGroovyClassLoader(); grapeEngine = AetherGrapeEngineFactory.create(groovyClassLoader, RepositoryConfigurationFactory.createDefaultRepositoryConfiguration(), new DependencyResolutionContext()); }