diff options
Diffstat (limited to 'buildSrc')
-rw-r--r-- | buildSrc/src/main/kotlin/tools/refinery/gradle/internal/java-conventions.gradle.kts | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/buildSrc/src/main/kotlin/tools/refinery/gradle/internal/java-conventions.gradle.kts b/buildSrc/src/main/kotlin/tools/refinery/gradle/internal/java-conventions.gradle.kts index a370d6b7..bed2bfdc 100644 --- a/buildSrc/src/main/kotlin/tools/refinery/gradle/internal/java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/tools/refinery/gradle/internal/java-conventions.gradle.kts | |||
@@ -7,7 +7,6 @@ package tools.refinery.gradle.internal | |||
7 | 7 | ||
8 | import org.gradle.accessors.dm.LibrariesForLibs | 8 | import org.gradle.accessors.dm.LibrariesForLibs |
9 | import org.gradle.configurationcache.extensions.capitalized | 9 | import org.gradle.configurationcache.extensions.capitalized |
10 | import org.gradle.plugins.ide.eclipse.model.ProjectDependency | ||
11 | import tools.refinery.gradle.utils.EclipseUtils | 10 | import tools.refinery.gradle.utils.EclipseUtils |
12 | 11 | ||
13 | plugins { | 12 | plugins { |
@@ -156,6 +155,43 @@ tasks { | |||
156 | } | 155 | } |
157 | } | 156 | } |
158 | 157 | ||
158 | fun collectDependentProjects(configuration: Configuration, dependentProjects: MutableCollection<Project>) { | ||
159 | for (dependency in configuration.dependencies) { | ||
160 | if (dependency is ProjectDependency) { | ||
161 | val dependentProject = dependency.dependencyProject | ||
162 | if (dependentProject.plugins.hasPlugin(JavaPlugin::class) && dependentProjects.add(dependentProject)) { | ||
163 | collectDependentProjectsTransitively(dependentProject, dependentProjects) | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | } | ||
168 | |||
169 | fun collectDependentProjectsTransitively(dependentProject: Project, dependentProjects: MutableCollection<Project>) { | ||
170 | val apiConfiguration = dependentProject.configurations.findByName("api") | ||
171 | if (apiConfiguration != null) { | ||
172 | collectDependentProjects(apiConfiguration, dependentProjects) | ||
173 | } | ||
174 | collectDependentProjects(configurations.implementation.get(), dependentProjects) | ||
175 | } | ||
176 | |||
177 | gradle.projectsEvaluated { | ||
178 | tasks.javadoc { | ||
179 | val dependentProjects = HashSet<Project>() | ||
180 | collectDependentProjectsTransitively(project, dependentProjects) | ||
181 | val links = ArrayList<JavadocOfflineLink>() | ||
182 | for (dependentProject in dependentProjects) { | ||
183 | dependsOn(dependentProject.tasks.javadoc) | ||
184 | val javadocDir = dependentProject.layout.buildDirectory.map { it.dir("docs/javadoc") } | ||
185 | inputs.dir(javadocDir) | ||
186 | links += JavadocOfflineLink("../${dependentProject.name}", javadocDir.get().asFile.path) | ||
187 | } | ||
188 | options { | ||
189 | this as StandardJavadocDocletOptions | ||
190 | linksOffline = (linksOffline ?: listOf()) + links | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | |||
159 | signing { | 195 | signing { |
160 | // The underlying property cannot be set publicly. | 196 | // The underlying property cannot be set publicly. |
161 | @Suppress("UsePropertyAccessSyntax") | 197 | @Suppress("UsePropertyAccessSyntax") |
@@ -175,7 +211,7 @@ eclipse { | |||
175 | // If a project has a main dependency on a project and a test dependency on the testFixtures of a project, | 211 | // If a project has a main dependency on a project and a test dependency on the testFixtures of a project, |
176 | // it will be erroneously added as a test-only dependency to Eclipse. As a workaround, we add all project | 212 | // it will be erroneously added as a test-only dependency to Eclipse. As a workaround, we add all project |
177 | // dependencies as main dependencies (we do not deliberately use test-only project dependencies). | 213 | // dependencies as main dependencies (we do not deliberately use test-only project dependencies). |
178 | if (entry is ProjectDependency) { | 214 | if (entry is org.gradle.plugins.ide.eclipse.model.ProjectDependency) { |
179 | entry.entryAttributes.remove("test") | 215 | entry.entryAttributes.remove("test") |
180 | } | 216 | } |
181 | } | 217 | } |