Java 类org.gradle.api.Transformer 实例源码

项目:Reer    文件:PCHUtils.java   
public static void generatePCHFile(List<String> headers, File headerFile) {
    if (!headerFile.getParentFile().exists()) {
        headerFile.getParentFile().mkdirs();
    }

    try {
        FileUtils.writeLines(headerFile, CollectionUtils.collect(headers, new Transformer<String, String>() {
            @Override
            public String transform(String header) {
                if (header.startsWith("<")) {
                    return "#include ".concat(header);
                } else {
                    return "#include \"".concat(header).concat("\"");
                }
            }
        }));
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:Reer    文件:CompileTaskConfig.java   
private void configureCompileTaskCommon(AbstractNativeCompileTask task, final NativeBinarySpecInternal binary, final LanguageSourceSetInternal sourceSet) {
    task.setToolChain(binary.getToolChain());
    task.setTargetPlatform(binary.getTargetPlatform());
    task.setPositionIndependentCode(binary instanceof SharedLibraryBinarySpec);

    task.includes(((HeaderExportingSourceSet) sourceSet).getExportedHeaders().getSourceDirectories());
    task.includes(new Callable<List<FileCollection>>() {
        public List<FileCollection> call() {
            Collection<NativeDependencySet> libs = binary.getLibs((DependentSourceSet) sourceSet);
            return CollectionUtils.collect(libs, new Transformer<FileCollection, NativeDependencySet>() {
                public FileCollection transform(NativeDependencySet original) {
                    return original.getIncludeRoots();
                }
            });
        }
    });

    for (String toolName : languageTransform.getBinaryTools().keySet()) {
        Tool tool = binary.getToolByName(toolName);
        if (tool instanceof PreprocessingTool) {
            task.setMacros(((PreprocessingTool) tool).getMacros());
        }

        task.setCompilerArgs(tool.getArgs());
    }
}
项目:Reer    文件:WatchServicePoller.java   
private List<FileWatcherEvent> handleWatchKey(WatchKey watchKey) {
    final Path watchedPath = (Path) watchKey.watchable();
    Transformer<FileWatcherEvent, WatchEvent<?>> watchEventTransformer = new Transformer<FileWatcherEvent, WatchEvent<?>>() {
        @Override
        public FileWatcherEvent transform(WatchEvent<?> event) {
            WatchEvent.Kind kind = event.kind();
            File file = null;
            if (kind.type() == Path.class) {
                WatchEvent<Path> ev = Cast.uncheckedCast(event);
                file = watchedPath.resolve(ev.context()).toFile();
            }
            return toEvent(kind, file);
        }
    };

    List<WatchEvent<?>> watchEvents = watchKey.pollEvents();
    watchKey.reset();
    if (watchEvents.isEmpty()) {
        return Collections.singletonList(FileWatcherEvent.delete(watchedPath.toFile()));
    } else {
        return CollectionUtils.collect(watchEvents, watchEventTransformer);
    }
}
项目:Reer    文件:TestExecutionRequestAction.java   
private static List<InternalJvmTestRequest> toProviderInternalJvmTestRequest(Collection<InternalJvmTestRequest> internalJvmTestRequests, Collection<String> testClassNames) {
    // handle consumer < 2.7
    if(internalJvmTestRequests.isEmpty()){
        return CollectionUtils.collect(testClassNames, new Transformer<InternalJvmTestRequest, String>() {
            @Override
            public InternalJvmTestRequest transform(String testClass) {
                return new ProviderInternalJvmTestRequest(testClass, null);
            }
        });
    } else {
        return CollectionUtils.collect(internalJvmTestRequests, new Transformer<InternalJvmTestRequest, InternalJvmTestRequest>() {
            @Override
            public InternalJvmTestRequest transform(InternalJvmTestRequest internalTestMethod) {
                return new ProviderInternalJvmTestRequest(internalTestMethod.getClassName(), internalTestMethod.getMethodName());
            }
        });
    }
}
项目:Reer    文件:JsonProjectDependencyRenderer.java   
private List createInsightDependencyChildren(RenderableDependency dependency, final Set<Object> visited, final Configuration configuration) {
    Iterable<? extends RenderableDependency> children = dependency.getChildren();
    return CollectionUtils.collect(children, new Transformer<Object, RenderableDependency>() {
        @Override
        public Object transform(RenderableDependency childDependency) {
            boolean alreadyVisited = !visited.add(childDependency.getId());
            boolean leaf = childDependency.getChildren().isEmpty();
            boolean alreadyRendered = alreadyVisited && !leaf;
            String childName = replaceArrow(childDependency.getName());
            boolean hasConflict = !childName.equals(childDependency.getName());
            String name = leaf ? configuration.getName() : childName;

            LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(6);
            map.put("name", name);
            map.put("resolvable", childDependency.getResolutionState());
            map.put("hasConflict", hasConflict);
            map.put("alreadyRendered", alreadyRendered);
            map.put("isLeaf", leaf);
            map.put("children", Collections.emptyList());
            if (!alreadyRendered) {
                map.put("children", createInsightDependencyChildren(childDependency, visited, configuration));
            }
            return map;
        }
    });
}
项目:Reer    文件:NormalizingGroovyCompiler.java   
private void resolveAndFilterSourceFiles(final GroovyJavaJointCompileSpec spec) {
    final List<String> fileExtensions = CollectionUtils.collect(spec.getGroovyCompileOptions().getFileExtensions(), new Transformer<String, String>() {
        @Override
        public String transform(String extension) {
            return '.' + extension;
        }
    });
    FileCollection filtered = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            for (String fileExtension : fileExtensions) {
                if (hasExtension(element, fileExtension)) {
                    return true;
                }
            }
            return false;
        }
    });

    spec.setSource(new SimpleFileCollection(filtered.getFiles()));
}
项目:Reer    文件:PomReader.java   
public PomReader(final LocallyAvailableExternalResource resource) throws SAXException {
    final String systemId = resource.getLocalResource().getFile().toURI().toASCIIString();
    Document pomDomDoc = resource.withContent(new Transformer<Document, InputStream>() {
        public Document transform(InputStream inputStream) {
            try {
                return parseToDom(inputStream, systemId);
            } catch (Exception e) {
                throw new MetaDataParseException("POM", resource, e);
            }
        }
    });
    projectElement = pomDomDoc.getDocumentElement();
    if (!PROJECT.equals(projectElement.getNodeName()) && !MODEL.equals(projectElement.getNodeName())) {
        throw new SAXParseException("project must be the root tag", systemId, systemId, 0, 0);
    }
    parentElement = getFirstChildElement(projectElement, PARENT);

    setDefaultParentGavProperties();
    setPomProperties();
    setActiveProfileProperties();
}
项目:Reer    文件:FilterChain.java   
public void expand(final Map<String, ?> properties) {
    transformers.add(new Transformer<Reader, Reader>() {
        public Reader transform(Reader original) {
            try {
                Template template;
                try {
                    SimpleTemplateEngine engine = new SimpleTemplateEngine();
                    template = engine.createTemplate(original);
                } finally {
                    original.close();
                }
                StringWriter writer = new StringWriter();
                template.make(properties).writeTo(writer);
                return new StringReader(writer.toString());
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    });
}
项目:Reer    文件:PluginRequestCollector.java   
public List<PluginRequest> listPluginRequests() {
    List<PluginRequest> pluginRequests = collect(specs, new Transformer<PluginRequest, DependencySpecImpl>() {
        public PluginRequest transform(DependencySpecImpl original) {
            return new DefaultPluginRequest(original.id, original.version, original.apply, original.lineNumber, scriptSource);
        }
    });

    ListMultimap<PluginId, PluginRequest> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequest>() {
        public PluginId transform(PluginRequest pluginRequest) {
            return pluginRequest.getId();
        }
    });

    // Check for duplicates
    for (PluginId key : groupedById.keySet()) {
        List<PluginRequest> pluginRequestsForId = groupedById.get(key);
        if (pluginRequestsForId.size() > 1) {
            PluginRequest first = pluginRequests.get(0);
            PluginRequest second = pluginRequests.get(1);

            InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber());
            throw new LocationAwareException(exception, second.getScriptDisplayName(), second.getLineNumber());
        }
    }
    return pluginRequests;
}
项目:Reer    文件:DefaultResolvedArtifactResults.java   
@Override
public SelectedArtifactResults select(Transformer<HasAttributes, Collection<? extends HasAttributes>> selector) {
    Set<ResolvedArtifactSet> allArtifactSets = newLinkedHashSet();
    final Map<Long, ResolvedArtifactSet> resolvedArtifactsById = newLinkedHashMap();

    for (Map.Entry<Long, ArtifactSet> entry : artifactsById.entrySet()) {
        Set<? extends ResolvedVariant> variants = entry.getValue().getVariants();
        ResolvedVariant selected = (ResolvedVariant) selector.transform(variants);
        ResolvedArtifactSet resolvedArtifacts;
        if (selected == null) {
            resolvedArtifacts = ResolvedArtifactSet.EMPTY;
        } else {
            resolvedArtifacts = selected.getArtifacts();
            if (!buildableArtifacts.contains(entry.getValue().getId())) {
                resolvedArtifacts = NoBuildDependenciesArtifactSet.of(resolvedArtifacts);
            }
            allArtifactSets.add(resolvedArtifacts);
        }
        resolvedArtifactsById.put(entry.getKey(), resolvedArtifacts);
    }

    return new DefaultSelectedArtifactResults(CompositeArtifactSet.of(allArtifactSets), resolvedArtifactsById);
}
项目:Reer    文件:GenerateBuildDashboard.java   
@Internal
private Set<Report> getEnabledInputReports() {
    Set<NamedDomainObjectSet<? extends Report>> enabledReportSets = CollectionUtils.collect(aggregated, new Transformer<NamedDomainObjectSet<? extends Report>, Reporting<? extends ReportContainer<?>>>() {
        public NamedDomainObjectSet<? extends Report> transform(Reporting<? extends ReportContainer<?>> reporting) {
            return reporting.getReports().getEnabled();
        }
    });
    return new LinkedHashSet<Report>(CollectionUtils.flattenCollections(Report.class, enabledReportSets));
}
项目:Reer    文件:DependencyResolvingClasspath.java   
@Override
public void finishArtifacts() {
    artifactsResults = artifactsBuilder.complete().select(new Transformer<HasAttributes, Collection<? extends HasAttributes>>() {
        @Override
        public HasAttributes transform(Collection<? extends HasAttributes> hasAttributes) {
            // Select the first variant
            return hasAttributes.iterator().next();
        }
    });
}
项目:Reer    文件:LibExeStaticLibraryArchiver.java   
LibExeStaticLibraryArchiver(BuildOperationProcessor buildOperationProcessor, CommandLineToolInvocationWorker commandLineToolInvocationWorker, CommandLineToolContext invocationContext, Transformer<StaticLibraryArchiverSpec, StaticLibraryArchiverSpec> specTransformer) {
    this.buildOperationProcessor = buildOperationProcessor;
    this.specTransformer = specTransformer;
    this.argsTransformer = new LibExeSpecToArguments();
    this.commandLineToolInvocationWorker = commandLineToolInvocationWorker;
    this.invocationContext = invocationContext;
}
项目:Reer    文件:CopySpecWrapper.java   
public CopySpec rename(final Closure closure) {
    delegate.rename(new Transformer<String, String>() {
        @Override
        public String transform(String s) {
            Object res = closure.call(s);
            return res == null ? null : res.toString();
        }
    });
    return this;
}
项目:Reer    文件:RelativeFileNameTransformer.java   
public static Transformer<String, File> from(File file) {
    if (file.isFile()) {
        File parentFile = file.getParentFile();
        return new RelativeFileNameTransformer(parentFile, parentFile);
    }
    return new RelativeFileNameTransformer(file, file);
}
项目:Reer    文件:ModelRuleExtractor.java   
public List<ExtractedModelRule> getRules() {
    return CollectionUtils.collect(rules, new Transformer<ExtractedModelRule, ExtractedRuleDetails>() {
        @Override
        public ExtractedModelRule transform(ExtractedRuleDetails extractedRuleDetails) {
            return extractedRuleDetails.rule;
        }
    });
}
项目:Reer    文件:ModelRegistrations.java   
public static <T> Builder unmanagedInstance(final ModelReference<T> modelReference, final Factory<? extends T> factory, final Action<? super MutableModelNode> initializer) {
    return unmanagedInstanceOf(modelReference, new Transformer<T, MutableModelNode>() {
        @Override
        public T transform(MutableModelNode modelNode) {
            T t = factory.create();
            initializer.execute(modelNode);
            return t;
        }
    });
}
项目:Reer    文件:LayoutCommandLineConverter.java   
public BuildLayoutParameters convert(ParsedCommandLine options, BuildLayoutParameters target) throws CommandLineArgumentException {
    Transformer<File, String> resolver = new BasicFileResolver(target.getCurrentDir());
    if (options.hasOption(NO_SEARCH_UPWARDS)) {
        target.setSearchUpwards(false);
    }
    if (options.hasOption(PROJECT_DIR)) {
        target.setProjectDir(resolver.transform(options.option(PROJECT_DIR).getValue()));
    }
    if (options.hasOption(GRADLE_USER_HOME)) {
        target.setGradleUserHomeDir(resolver.transform(options.option(GRADLE_USER_HOME).getValue()));
    }
    return target;
}
项目:Reer    文件:AsmBackedClassGenerator.java   
public void addActionMethod(Method method) throws Exception {
    Type returnType = Type.getType(method.getReturnType());

    Type[] originalParameterTypes = CollectionUtils.collectArray(method.getParameterTypes(), Type.class, new Transformer<Type, Class>() {
        public Type transform(Class clazz) {
            return Type.getType(clazz);
        }
    });
    int numParams = originalParameterTypes.length;
    Type[] closurisedParameterTypes = new Type[numParams];
    System.arraycopy(originalParameterTypes, 0, closurisedParameterTypes, 0, numParams);
    closurisedParameterTypes[numParams - 1] = CLOSURE_TYPE;

    String methodDescriptor = Type.getMethodDescriptor(returnType, closurisedParameterTypes);

    // GENERATE public <return type> <method>(Closure v) { return <method>(…, ConfigureUtil.configureUsing(v)); }
    MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, method.getName(), methodDescriptor, null, EMPTY_STRINGS);
    methodVisitor.visitCode();

    // GENERATE <method>(…, ConfigureUtil.configureUsing(v));
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);

    for (int stackVar = 1; stackVar < numParams; ++stackVar) {
        methodVisitor.visitVarInsn(closurisedParameterTypes[stackVar - 1].getOpcode(Opcodes.ILOAD), stackVar);
    }

    // GENERATE ConfigureUtil.configureUsing(v);
    methodVisitor.visitVarInsn(Opcodes.ALOAD, numParams);
    methodDescriptor = Type.getMethodDescriptor(ACTION_TYPE, CLOSURE_TYPE);
    methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, CONFIGURE_UTIL_TYPE.getInternalName(), "configureUsing", methodDescriptor, false);

    methodDescriptor = Type.getMethodDescriptor(Type.getType(method.getReturnType()), originalParameterTypes);
    methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, generatedType.getInternalName(), method.getName(), methodDescriptor, false);

    methodVisitor.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
    methodVisitor.visitMaxs(0, 0);
    methodVisitor.visitEnd();
}
项目:Reer    文件:DefaultBuildOperationProcessor.java   
private static String formatMultipleFailureMessage(List<GradleException> failures) {
    return StringUtils.join(CollectionUtils.collect(failures, new Transformer<String, GradleException>() {
        @Override
        public String transform(GradleException e) {
            return e.getMessage();
        }
    }), LINE_SEPARATOR + "AND" + LINE_SEPARATOR);
}
项目:Reer    文件:Transformers.java   
public static <T> Transformer<T, T> noOpTransformer() {
    return new Transformer<T, T>() {
        public T transform(T original) {
            return original;
        }
    };
}
项目:Reer    文件:TestDataGenerator.java   
void render(PerformanceTestHistory testHistory, Transformer<String, MeasuredOperationList> valueRenderer, PrintWriter out) {
    List<? extends PerformanceTestExecution> sortedResults = Lists.reverse(testHistory.getExecutions());
    out.println("  [");
    List<String> labels = testHistory.getScenarioLabels();
    for (int i = 0; i < labels.size(); i++) {
        if (i > 0) {
            out.println(",");
        }
        out.println("  {");
        out.println("    \"label\": \"" + labels.get(i) + "\",");
        out.print("\"data\": [");
        boolean empty = true;
        for (int j = 0; j < sortedResults.size(); j++) {
            PerformanceTestExecution results = sortedResults.get(j);
            MeasuredOperationList measuredOperations = results.getScenarios().get(i);
            if (!measuredOperations.isEmpty()) {
                if (!empty) {
                    out.print(", ");
                }
                out.print("[" + j + ", " + valueRenderer.transform(measuredOperations) + "]");
                empty = false;
            }
        }
        out.println("]");
        out.print("  }");
    }
    out.println();
    out.println("]");
}
项目:Reer    文件:NotifyingSettingsProcessor.java   
@Override
public SettingsInternal process(final GradleInternal gradle, final SettingsLocation settingsLocation, final ClassLoaderScope buildRootClassLoaderScope, final StartParameter startParameter) {
    BuildOperationDetails operationDetails = BuildOperationDetails.displayName("Configure settings").progressDisplayName("settings").build();
    return buildOperationExecutor.run(operationDetails, new Transformer<SettingsInternal, BuildOperationContext>() {
        @Override
        public SettingsInternal transform(BuildOperationContext buildOperationContext) {
            return settingsProcessor.process(gradle, settingsLocation, buildRootClassLoaderScope, startParameter);
        }
    });
}
项目:Reer    文件:Transformers.java   
/**
 * A getClass() transformer.
 *
 * @param <T> The type of the object
 * @return A getClass() transformer.
 */
public static <T> Transformer<Class<T>, T> type() {
    return new Transformer<Class<T>, T>() {
        public Class<T> transform(T original) {
            @SuppressWarnings("unchecked")
            Class<T> aClass = (Class<T>) original.getClass();
            return aClass;
        }
    };
}
项目:Reer    文件:DefaultPlayToolChain.java   
private Configuration resolveToolClasspath(Object... dependencyNotations) {
    List<Dependency> dependencies = CollectionUtils.collect(dependencyNotations, new Transformer<Dependency, Object>() {
        public Dependency transform(Object dependencyNotation) {
            return dependencyHandler.create(dependencyNotation);
        }
    });
    Dependency[] dependenciesArray = dependencies.toArray(new Dependency[0]);
    return configurationContainer.detachedConfiguration(dependenciesArray);
}
项目:Reer    文件:Transformers.java   
/**
 * Converts a URL to a URI
 */
public static Transformer<URL, URI> toURL() {
    return new Transformer<URL, URI>() {
        public URL transform(URI original) {
            try {
                return original.toURL();
            } catch (MalformedURLException e) {
                throw UncheckedException.throwAsUncheckedException(e);
            }
        }
    };
}
项目:Reer    文件:JsonProjectDependencyRenderer.java   
private List createModuleInsights(final Configuration configuration) {
    Iterable<ModuleIdentifier> modules = collectModules(configuration);
    return CollectionUtils.collect(modules, new Transformer<Object, ModuleIdentifier>() {
        @Override
        public Object transform(ModuleIdentifier moduleIdentifier) {
            return createModuleInsight(moduleIdentifier, configuration);
        }
    });
}
项目:Reer    文件:ArgWriter.java   
public static Transformer<ArgWriter, PrintWriter> unixStyleFactory() {
    return new Transformer<ArgWriter, PrintWriter>() {
        public ArgWriter transform(PrintWriter original) {
            return unixStyle(original);
        }
    };
}
项目:Reer    文件:IoUtils.java   
public static <T, C extends Closeable> T get(C resource, Transformer<T, ? super C> transformer) {
    try {
        return transformer.transform(resource);
    } finally {
        CompositeStoppable.stoppable(resource).stop();
    }
}
项目:Reer    文件:CollectionUtils.java   
public static <R, I> R[] collectArray(I[] list, R[] destination, Transformer<? extends R, ? super I> transformer) {
    assert list.length <= destination.length;
    for (int i = 0; i < list.length; ++i) {
        destination[i] = transformer.transform(list[i]);
    }
    return destination;
}
项目:Reer    文件:CollectionUtils.java   
public static <E> boolean replace(List<E> list, Spec<? super E> filter, Transformer<? extends E, ? super E> transformer) {
    boolean replaced = false;
    int i = 0;
    for (E it : list) {
        if (filter.isSatisfiedBy(it)) {
            list.set(i, transformer.transform(it));
            replaced = true;
        }
        ++i;
    }
    return replaced;
}
项目:Reer    文件:DependencyInsightReporter.java   
public Collection<RenderableDependency> prepare(Collection<DependencyResult> input, VersionSelectorScheme versionSelectorScheme, VersionComparator versionComparator) {
    LinkedList<RenderableDependency> out = new LinkedList<RenderableDependency>();
    List<DependencyEdge> dependencies = CollectionUtils.collect(input, new Transformer<DependencyEdge, DependencyResult>() {
        @Override
        public DependencyEdge transform(DependencyResult result) {
            if (result instanceof UnresolvedDependencyResult) {
                return new UnresolvedDependencyEdge((UnresolvedDependencyResult) result);
            } else {
                return new ResolvedDependencyEdge((ResolvedDependencyResult) result);
            }
        }
    });
    Collection<DependencyEdge> sorted = DependencyResultSorter.sort(dependencies, versionSelectorScheme, versionComparator);

    //remember if module id was annotated
    HashSet<ComponentIdentifier> annotated = new HashSet<ComponentIdentifier>();
    RequestedVersion current = null;

    for (DependencyEdge dependency : sorted) {
        //add description only to the first module
        if (annotated.add(dependency.getActual())) {
            //add a heading dependency with the annotation if the dependency does not exist in the graph
            if (!dependency.getRequested().matchesStrictly(dependency.getActual())) {
                out.add(new DependencyReportHeader(dependency));
                current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null);
                out.add(current);
            } else {
                current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), getReasonDescription(dependency.getReason()));
                out.add(current);
            }
        } else if (!current.getRequested().equals(dependency.getRequested())) {
            current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null);
            out.add(current);
        }

        current.addChild(dependency);
    }

    return out;
}
项目:Reer    文件:CollectionUtils.java   
public static <K, V> ImmutableListMultimap<K, V> groupBy(Iterable<? extends V> iterable, Transformer<? extends K, V> grouper) {
    ImmutableListMultimap.Builder<K, V> builder = ImmutableListMultimap.builder();

    for (V element : iterable) {
        K key = grouper.transform(element);
        builder.put(key, element);
    }

    return builder.build();
}
项目:Reer    文件:AbstractExternalResource.java   
public <T> T withContent(Transformer<? extends T, ? super InputStream> readAction) {
    InputStream input = openBuffered();
    try {
        return readAction.transform(input);
    } finally {
        close(input);
    }
}
项目:Reer    文件:ReleasedVersionDistributions.java   
public List<GradleDistribution> getAll() {
    if (distributions == null) {
        distributions = CollectionUtils.collect(getProperties().getProperty("versions").split("\\s+"), new Transformer<GradleDistribution, String>() {
            public GradleDistribution transform(String version) {
                return buildContext.distribution(version);
            }
        });
    }
    return distributions;
}
项目:Reer    文件:AbstractCompatibilityTestRunner.java   
private AbstractCompatibilityTestRunner(Class<?> target, String versionStr) {
    super(target);
    validateTestName(target);

    previous = new ArrayList<GradleDistribution>();
    final ReleasedVersionDistributions releasedVersions = new ReleasedVersionDistributions(buildContext);
    if (versionStr.equals("latest")) {
        implicitVersion = true;
        addVersionIfCompatibleWithJvmAndOs(releasedVersions.getMostRecentFinalRelease());
    } else if (versionStr.equals("all")) {
        implicitVersion = true;
        List<GradleDistribution> previousVersionsToTest = choosePreviousVersionsToTest(releasedVersions);
        for (GradleDistribution previousVersion : previousVersionsToTest) {
            addVersionIfCompatibleWithJvmAndOs(previousVersion);
        }
    } else if (versionStr.matches("^\\d.*$")) {
        implicitVersion = false;
        String[] versions = versionStr.split(",");
        List<GradleVersion> gradleVersions = CollectionUtils.sort(collect(Arrays.asList(versions), new Transformer<GradleVersion, String>() {
            public GradleVersion transform(String versionString) {
                return GradleVersion.version(versionString);
            }
        }), Collections.reverseOrder());

        inject(previous, gradleVersions, new Action<InjectionStep<List<GradleDistribution>, GradleVersion>>() {
            public void execute(InjectionStep<List<GradleDistribution>, GradleVersion> step) {
                GradleDistribution distribution = releasedVersions.getDistribution(step.getItem());
                if (distribution == null) {
                    throw new RuntimeException("Gradle version '" + step.getItem().getVersion() + "' is not a valid testable released version");
                }
                step.getTarget().add(distribution);
            }
        });
    } else {
        throw new RuntimeException("Invalid value for " + VERSIONS_SYSPROP_NAME + " system property: " + versionStr + "(valid values: 'all', 'latest' or comma separated list of versions)");
    }
}
项目:Reer    文件:DefaultTemplateBasedStartScriptGenerator.java   
private String generateStartScriptContentFromTemplate(final Map<String, String> binding) {
    return IoUtils.get(getTemplate().asReader(), new Transformer<String, Reader>() {
        @Override
        public String transform(Reader reader) {
            try {
                SimpleTemplateEngine engine = new SimpleTemplateEngine();
                Template template = engine.createTemplate(reader);
                String output = template.make(binding).toString();
                return TextUtil.convertLineSeparators(output, lineSeparator);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    });
}
项目:Reer    文件:MavenProjectsCreator.java   
private Set<MavenProject> createNow(Settings settings, File pomFile) throws PlexusContainerException, PlexusConfigurationException, ComponentLookupException, MavenExecutionRequestPopulationException, ProjectBuildingException {
    ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration()
            .setClassWorld(new ClassWorld("plexus.core", ClassWorld.class.getClassLoader()))
            .setName("mavenCore");

    DefaultPlexusContainer container = new DefaultPlexusContainer(containerConfiguration);
    ProjectBuilder builder = container.lookup(ProjectBuilder.class);
    MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
    final Properties properties = new Properties();
    properties.putAll(SystemProperties.getInstance().asMap());
    executionRequest.setSystemProperties(properties);
    MavenExecutionRequestPopulator populator = container.lookup(MavenExecutionRequestPopulator.class);
    populator.populateFromSettings(executionRequest, settings);
    populator.populateDefaults(executionRequest);
    ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
    buildingRequest.setProcessPlugins(false);
    MavenProject mavenProject = builder.build(pomFile, buildingRequest).getProject();
    Set<MavenProject> reactorProjects = new LinkedHashSet<MavenProject>();

    //TODO adding the parent project first because the converter needs it this way ATM. This is oversimplified.
    //the converter should not depend on the order of reactor projects.
    //we should add coverage for nested multi-project builds with multiple parents.
    reactorProjects.add(mavenProject);
    List<ProjectBuildingResult> allProjects = builder.build(ImmutableList.of(pomFile), true, buildingRequest);
    CollectionUtils.collect(allProjects, reactorProjects, new Transformer<MavenProject, ProjectBuildingResult>() {
        public MavenProject transform(ProjectBuildingResult original) {
            return original.getProject();
        }
    });

    MavenExecutionResult result = new DefaultMavenExecutionResult();
    result.setProject(mavenProject);
    RepositorySystemSession repoSession = new DefaultRepositorySystemSession();
    MavenSession session = new MavenSession(container, repoSession, executionRequest, result);
    session.setCurrentProject(mavenProject);

    return reactorProjects;
}
项目:Reer    文件:CoffeeScriptCompileDestinationCalculator.java   
public static Transformer<Transformer<File, RelativePath>, File> asFactory() {
    return new Transformer<Transformer<File, RelativePath>, File>() {
        public Transformer<File, RelativePath> transform(File original) {
            return new CoffeeScriptCompileDestinationCalculator(original);
        }
    };
}
项目:Reer    文件:DefaultIvyContextManager.java   
public <T> T withIvy(Transformer<? extends T, ? super Ivy> action) {
    Integer currentDepth = depth.get();

    if (currentDepth != null) {
        depth.set(currentDepth + 1);
        try {
            return action.transform(IvyContext.getContext().getIvy());
        } finally {
            depth.set(currentDepth);
        }
    }

    IvyContext.pushNewContext();
    try {
        depth.set(1);
        try {
            Ivy ivy = getIvy();
            try {
                IvyContext.getContext().setIvy(ivy);
                return action.transform(ivy);
            } finally {
                releaseIvy(ivy);
            }
        } finally {
            depth.set(null);
        }
    } finally {
        IvyContext.popContext();
    }
}