Skip to content

Commit

Permalink
Create a friends configuration to use internals.
Browse files Browse the repository at this point in the history
From https://www.liutikas.net/2025/01/12/Kotlin-Library-Friends.html we should avoid using

@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

So instead lets just be friends.
  • Loading branch information
yschimke committed Jan 17, 2025
1 parent 9c653c7 commit 0e87181
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp.android.test

Expand Down
21 changes: 21 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
import java.net.URI

Expand Down Expand Up @@ -279,6 +280,26 @@ subprojects {
languageSettings.optIn("okhttp3.ExperimentalOkHttpApi")
}
}

// From https://www.liutikas.net/2025/01/12/Kotlin-Library-Friends.html

// Create a configuration we can use to track friend libraries
val friends = configurations.create("friends") {
isCanBeResolved = true
isCanBeConsumed = false
isTransitive = false
}

// Make sure friends libraries are on the classpath
configurations.findByName("implementation")?.extendsFrom(friends)

// Make these libraries friends :)
tasks.withType<KotlinJvmCompile>().configureEach {
val friendCollection = friends.incoming.artifactView { }.files
compilerOptions.freeCompilerArgs.add(
provider { "-Xfriend-paths=${friendCollection.joinToString(",")}"}
)
}
}

/** Configure publishing and signing for published Java and JavaPlatform subprojects. */
Expand Down
2 changes: 1 addition & 1 deletion mockwebserver-deprecated/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks.jar {
}

dependencies {
api(projects.okhttp)
"friends"(projects.okhttp)
api(projects.mockwebserver3)
api(libs.junit)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.mockwebserver

Expand Down
1 change: 1 addition & 0 deletions mockwebserver-junit5/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ tasks {
}

dependencies {
api(projects.okhttp)
api(projects.mockwebserver3)
api(libs.junit.jupiter.api)
compileOnly(libs.animalsniffer.annotations)
Expand Down
2 changes: 1 addition & 1 deletion mockwebserver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks.jar {
}

dependencies {
api(projects.okhttp)
"friends"(projects.okhttp)

testImplementation(projects.okhttpTestingSupport)
testImplementation(projects.okhttpTls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package mockwebserver3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package mockwebserver3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package mockwebserver3

Expand Down
2 changes: 1 addition & 1 deletion okhttp-dnsoverhttps/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friends"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)

testImplementation(projects.okhttpTestingSupport)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.dnsoverhttps

Expand Down
2 changes: 1 addition & 1 deletion okhttp-java-net-cookiejar/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friends"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.animalsniffer.annotations)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.java.net.cookiejar

Expand Down
2 changes: 1 addition & 1 deletion okhttp-logging-interceptor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friends"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)

testCompileOnly(libs.findbugs.jsr305)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.logging

Expand Down
2 changes: 1 addition & 1 deletion okhttp-testing-support/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {

dependencies {
api(libs.squareup.okio)
api(projects.okhttp)
"friends"(projects.okhttp)
api(projects.okhttpTls)
api(libs.assertk)
api(libs.bouncycastle.bcprov)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.internal.concurrent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.internal.http

Expand Down
2 changes: 1 addition & 1 deletion okhttp-tls/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ project.applyOsgi(

dependencies {
api(libs.squareup.okio)
implementation(projects.okhttp)
"friends"(projects.okhttp)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.animalsniffer.annotations)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.tls

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3.tls.internal

Expand Down
2 changes: 1 addition & 1 deletion okhttp-urlconnection/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project.applyOsgi(
)

dependencies {
api(projects.okhttp)
"friends"(projects.okhttp)
api(projects.okhttpJavaNetCookiejar)
compileOnly(libs.findbugs.jsr305)
compileOnly(libs.animalsniffer.annotations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

package okhttp3

Expand Down

0 comments on commit 0e87181

Please sign in to comment.