All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openrewrite.gradle.toolingapi.GradleDependencyConfiguration Maven / Gradle / Ivy

/*
 * Copyright 2022 the original author or authors.
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *

* https://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.openrewrite.gradle.toolingapi; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; import static java.util.Collections.emptyList; public interface GradleDependencyConfiguration { String getName(); String getDescription(); boolean isTransitive(); boolean isCanBeConsumed(); boolean isCanBeResolved(); List getExtendsFrom(); List getRequested(); List getResolved(); static Map toMarkers(Collection configurations) { Map results = new HashMap<>(); for (org.openrewrite.gradle.toolingapi.GradleDependencyConfiguration config : configurations) { results.put(config.getName(), new org.openrewrite.gradle.marker.GradleDependencyConfiguration( config.getName(), config.getDescription(), config.isTransitive(), config.isCanBeResolved(), config.isCanBeConsumed(), emptyList(), config.getRequested().stream().map(org.openrewrite.gradle.toolingapi.Dependency::toMarkers) .collect(Collectors.toList()), org.openrewrite.gradle.toolingapi.ResolvedDependency.toMarker(config.getResolved()), null, null )); } // Record the relationships between dependency configurations for (org.openrewrite.gradle.toolingapi.GradleDependencyConfiguration conf : configurations) { if (conf.getExtendsFrom().isEmpty()) { continue; } org.openrewrite.gradle.marker.GradleDependencyConfiguration dc = results.get(conf.getName()); if (dc != null) { List extendsFrom = conf.getExtendsFrom().stream() .map(it -> results.get(it.getName())) .collect(Collectors.toList()); dc.unsafeSetExtendsFrom(extendsFrom); } } return results; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy