From eed81ae19e8ebef266a418eb3e65c9c6c157f42d Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Mon, 7 Aug 2023 14:09:29 +0100 Subject: [PATCH 1/8] Add a sub-project for the common sources. Puts the common sources in an explicit Gradle sub-project rather than just referring to them from multiple sourceSets. Pro: Project now loads cleanly in Studio with no duplicate source root warnings and Studio can follow cross-refs between all sub-projects. Pro: Also tidied up the dependencies to the constants build. Hopefully we can now tidy that build up further. Con: Had to add a whole new set of stubs (platform-stub) for Platform.java due to circular dependency... All of the code in common/ expects to be compiled against the current platform's Platform.java but all of the Platform.java's also expect to be compiled against the common code. Pro: Adding platform-stub allows us to remove the platformJar stuff from the OpenJDK build. Turns out this was just a hack to allow android-platform to build on OpenJDK so compiling against a stub is cleaner. Con: the common build's processTestResources task seems to try and copy all the resources twice causing an error. Added a hacky workaround for now. Major con: The AARs built by the Android build do not contain classes from the common sources. I've tried multiple ways of expressing the dependency and got nowhere so advice would be appreciated. --- android/build.gradle | 19 +- build.gradle | 1 - common/build.gradle | 41 ++ .../conscrypt/VeryBasicHttpServerTest.java | 0 openjdk/build.gradle | 34 +- platform-stub/build.gradle | 9 + .../conscrypt/AbstractConscryptSocket.java | 36 ++ .../java/org/conscrypt/CertBlocklist.java | 36 ++ .../org/conscrypt/ConscryptCertStore.java | 36 ++ .../java/org/conscrypt/ConscryptEngine.java | 36 ++ .../org/conscrypt/ConscryptEngineSocket.java | 36 ++ .../ConscryptFileDescriptorSocket.java | 36 ++ .../conscrypt/ConscryptHostnameVerifier.java | 36 ++ .../java/org/conscrypt/ExternalSession.java | 36 ++ .../java/org/conscrypt/GCMParameters.java | 36 ++ .../java/org/conscrypt/NativeCryptoJni.java | 39 ++ .../main/java/org/conscrypt/OpenSSLKey.java | 36 ++ .../conscrypt/OpenSSLSocketFactoryImpl.java | 36 ++ .../src/main/java/org/conscrypt/Platform.java | 370 ++++++++++++++++++ .../java/org/conscrypt/SSLParametersImpl.java | 36 ++ .../java/org/conscrypt/ct/CTLogStore.java | 36 ++ .../main/java/org/conscrypt/ct/CTPolicy.java | 36 ++ platform/build.gradle | 7 +- settings.gradle | 4 + 24 files changed, 982 insertions(+), 46 deletions(-) create mode 100644 common/build.gradle rename {openjdk => common}/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java (100%) create mode 100644 platform-stub/build.gradle create mode 100644 platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java create mode 100644 platform-stub/src/main/java/org/conscrypt/CertBlocklist.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ExternalSession.java create mode 100644 platform-stub/src/main/java/org/conscrypt/GCMParameters.java create mode 100644 platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java create mode 100644 platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java create mode 100644 platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java create mode 100644 platform-stub/src/main/java/org/conscrypt/Platform.java create mode 100644 platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java create mode 100644 platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java diff --git a/android/build.gradle b/android/build.gradle index e02dcfa32..8ffce8623 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -28,10 +28,6 @@ ext { if (androidSdkInstalled) { apply plugin: 'com.android.library' - // Since we're not taking a direct dependency on the constants module, we need to add an - // explicit task dependency to make sure the code is generated. - evaluationDependsOn(':conscrypt-constants') - android { namespace "org.conscrypt" @@ -81,12 +77,7 @@ if (androidSdkInstalled) { } sourceSets.main { java { - srcDirs = [ - "${rootDir}/common/src/main/java", - "src/main/java" - ] - // Requires evaluationDependsOn(':conscrypt-constants') above. - srcDirs += project(':conscrypt-constants').sourceSets.main.java.srcDirs + srcDirs = [ "src/main/java" ] } resources { srcDirs += "build/generated/resources" @@ -112,7 +103,10 @@ if (androidSdkInstalled) { } dependencies { + api project(path: ':conscrypt-common', configuration: 'runtimeElements') + publicApiDocs project(':conscrypt-api-doclet') + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', { exclude module: 'support-annotations' exclude module: 'support-v4' @@ -121,10 +115,9 @@ if (androidSdkInstalled) { exclude module: 'appcompat-v7' exclude module: 'design' }) - compileOnly project(':conscrypt-android-stub') - // Adds the constants module as a dependency so that we can include its generated source - compileOnly project(':conscrypt-constants') + compileOnly project(':conscrypt-android-stub'), + project(':conscrypt-constants') } def configureJavaDocs = tasks.register("configureJavadocs") { diff --git a/build.gradle b/build.gradle index 9d90d6a51..640e58c55 100644 --- a/build.gradle +++ b/build.gradle @@ -66,7 +66,6 @@ subprojects { } } } - apply plugin: "idea" apply plugin: "jacoco" apply plugin: "net.ltgt.errorprone" diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 000000000..e7bffffc4 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,41 @@ +sourceSets { + main { + java { + srcDirs = [ + "src/main/java", + ] + } + } + test { + java { + srcDirs = [ + "src/test/java", + ] + } + resources { + srcDirs [ + "src/test/resources", + ] + } + } +} + +dependencies { + compileOnly project(':conscrypt-constants'), + project(':conscrypt-platform-stub') + + testImplementation project(path: ':conscrypt-testing', configuration: 'shadow'), + libraries.junit, + libraries.mockito +} + +// Always tested from one of the other subprojects. +tasks.withType(Test).configureEach { + enabled = false +} + +// Whhyyyyyyyyyyyyyyyyyyyyyyyy! +// For some reason Gradle seems to be copying all the resources twice, so errors without this. +tasks.named("processTestResources") { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} diff --git a/openjdk/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java b/common/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java similarity index 100% rename from openjdk/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java rename to common/src/test/java/org/conscrypt/VeryBasicHttpServerTest.java diff --git a/openjdk/build.gradle b/openjdk/build.gradle index cda93c34d..c26de0191 100644 --- a/openjdk/build.gradle +++ b/openjdk/build.gradle @@ -129,33 +129,21 @@ ext { } sourceSets { - main { java { - srcDirs += "${rootDir}/common/src/main/java" - srcDirs += project(':conscrypt-constants').sourceSets.main.java.srcDirs + srcDirs = [ "src/main/java" ] } resources { srcDirs += "build/generated/resources" } } - platform { - java { - srcDirs = [ "src/main/java" ] - includes = [ "org/conscrypt/Platform.java" ] - } - } - test { java { - srcDirs += "${rootDir}/common/src/test/java" + srcDirs = [ "src/test/java" ] } resources { - srcDirs += "${rootDir}/common/src/test/resources" - // This shouldn't be needed but seems to help IntelliJ locate the native artifact. - // srcDirs += preferredNativeFileDir - srcDirs += buildToTest.nativeResourcesDir() + srcDirs = [ "src/test/resources" ] } } @@ -179,10 +167,6 @@ processResources { dependsOn generateProperties } -tasks.register("platformJar", Jar) { - from sourceSets.platform.output -} - tasks.register("testJar", ShadowJar) { classifier = 'tests' configurations = [project.configurations.testRuntimeClasspath] @@ -244,11 +228,6 @@ if (isExecutableOnPath('cpplint')) { configurations { publicApiDocs - platform -} - -artifacts { - platform platformJar } apply from: "$rootDir/gradle/publishing.gradle" @@ -268,17 +247,18 @@ dependencies { // This is used for the @Internal annotation processing in JavaDoc publicApiDocs project(':conscrypt-api-doclet') + api project(':conscrypt-common') + // This is listed as compile-only, but we absorb its contents. compileOnly project(':conscrypt-constants') + testCompileOnly project(':conscrypt-constants') - testImplementation project(':conscrypt-constants'), + testImplementation project(':conscrypt-common').sourceSets.test.output, project(path: ':conscrypt-testing', configuration: 'shadow'), libraries.junit, libraries.mockito testRuntimeOnly sourceSets["$preferredSourceSet"].output - - platformCompileOnly sourceSets.main.output } nativeBuilds.each { nativeBuild -> diff --git a/platform-stub/build.gradle b/platform-stub/build.gradle new file mode 100644 index 000000000..953584098 --- /dev/null +++ b/platform-stub/build.gradle @@ -0,0 +1,9 @@ +sourceSets { + main { + java { + srcDirs = [ + "src/main/java", + ] + } + } +} diff --git a/platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java b/platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java new file mode 100644 index 000000000..ee55df508 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/AbstractConscryptSocket.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class AbstractConscryptSocket { +} diff --git a/platform-stub/src/main/java/org/conscrypt/CertBlocklist.java b/platform-stub/src/main/java/org/conscrypt/CertBlocklist.java new file mode 100644 index 000000000..5e61e4edf --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/CertBlocklist.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class CertBlocklist { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java b/platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java new file mode 100644 index 000000000..2e02a3480 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptCertStore.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class ConscryptCertStore { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java b/platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java new file mode 100644 index 000000000..a193064de --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptEngine.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class ConscryptEngine { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java b/platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java new file mode 100644 index 000000000..8e0cf1924 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptEngineSocket.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class ConscryptEngineSocket { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java b/platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java new file mode 100644 index 000000000..66f694c70 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class ConscryptFileDescriptorSocket { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java b/platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java new file mode 100644 index 000000000..3b862d51f --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ConscryptHostnameVerifier.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class ConscryptHostnameVerifier { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ExternalSession.java b/platform-stub/src/main/java/org/conscrypt/ExternalSession.java new file mode 100644 index 000000000..04274443f --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ExternalSession.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class ExternalSession { +} diff --git a/platform-stub/src/main/java/org/conscrypt/GCMParameters.java b/platform-stub/src/main/java/org/conscrypt/GCMParameters.java new file mode 100644 index 000000000..fa52c958c --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/GCMParameters.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class GCMParameters { +} diff --git a/platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java b/platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java new file mode 100644 index 000000000..36261ce35 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/NativeCryptoJni.java @@ -0,0 +1,39 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class NativeCryptoJni { + static void init() { + throw new RuntimeException("Stub!"); + } +} diff --git a/platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java b/platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java new file mode 100644 index 000000000..3e83e6eda --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/OpenSSLKey.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class OpenSSLKey { +} diff --git a/platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java b/platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java new file mode 100644 index 000000000..ffcf64dee --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/OpenSSLSocketFactoryImpl.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class OpenSSLSocketFactoryImpl { +} diff --git a/platform-stub/src/main/java/org/conscrypt/Platform.java b/platform-stub/src/main/java/org/conscrypt/Platform.java new file mode 100644 index 000000000..8df5f351c --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/Platform.java @@ -0,0 +1,370 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +import org.conscrypt.ct.CTLogStore; +import org.conscrypt.ct.CTPolicy; + +import java.io.File; +import java.io.FileDescriptor; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.net.SocketException; +import java.security.AlgorithmParameters; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.PrivateKey; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.security.spec.AlgorithmParameterSpec; +import java.security.spec.ECParameterSpec; + +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.X509TrustManager; + +final class Platform { + private Platform() {} + + static void setup() { + throw new RuntimeException("Stub!"); + } + + static File createTempFile(String prefix, String suffix, File directory) { + throw new RuntimeException("Stub!"); + } + + static String getDefaultProviderName() { + throw new RuntimeException("Stub!"); + } + + static boolean provideTrustManagerByDefault() { + throw new RuntimeException("Stub!"); + } + + static boolean canExecuteExecutable(File file) throws IOException { + throw new RuntimeException("Stub!"); + } + + static FileDescriptor getFileDescriptor(Socket s) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static FileDescriptor getFileDescriptorFromSSLSocket(AbstractConscryptSocket socket) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String getCurveName(ECParameterSpec spec) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void setCurveName(@SuppressWarnings("unused") ECParameterSpec spec, + @SuppressWarnings("unused") String curveName) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void setSocketWriteTimeout(@SuppressWarnings("unused") Socket s, + @SuppressWarnings("unused") long timeoutMillis) throws SocketException { + throw new RuntimeException("Stub!"); + } + + static void setSSLParameters( + SSLParameters params, SSLParametersImpl impl, AbstractConscryptSocket socket) { + throw new RuntimeException("Stub!"); + } + + static void getSSLParameters( + SSLParameters params, SSLParametersImpl impl, AbstractConscryptSocket socket) { + throw new RuntimeException("Stub!"); + } + + static void setSSLParameters( + SSLParameters params, SSLParametersImpl impl, ConscryptEngine engine) { + throw new RuntimeException("Stub!"); + } + + static void getSSLParameters( + SSLParameters params, SSLParametersImpl impl, ConscryptEngine engine) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void setEndpointIdentificationAlgorithm( + SSLParameters params, String endpointIdentificationAlgorithm) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String getEndpointIdentificationAlgorithm(SSLParameters params) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkClientTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + AbstractConscryptSocket socket) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkServerTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + AbstractConscryptSocket socket) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkClientTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + ConscryptEngine engine) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void checkServerTrusted(X509TrustManager tm, X509Certificate[] chain, String authType, + ConscryptEngine engine) throws CertificateException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static OpenSSLKey wrapRsaKey(@SuppressWarnings("unused") PrivateKey javaKey) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void logEvent(@SuppressWarnings("unused") String message) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static boolean isSniEnabledByDefault() { + throw new RuntimeException("Stub!"); + } + + static SSLEngine wrapEngine(ConscryptEngine engine) { + throw new RuntimeException("Stub!"); + } + + static SSLEngine unwrapEngine(SSLEngine engine) { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(String hostname, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(InetAddress address, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(String hostname, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(InetAddress address, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptEngineSocket createEngineSocket(Socket socket, String hostname, int port, + boolean autoClose, SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(String hostname, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(InetAddress address, int port, + SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(String hostname, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(InetAddress address, int port, + InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters) + throws IOException { + throw new RuntimeException("Stub!"); + } + + static ConscryptFileDescriptorSocket createFileDescriptorSocket(Socket socket, String hostname, + int port, boolean autoClose, SSLParametersImpl sslParameters) throws IOException { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static SSLSocketFactory wrapSocketFactoryIfNeeded(OpenSSLSocketFactoryImpl factory) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static GCMParameters fromGCMParameterSpec(AlgorithmParameterSpec params) { + throw new RuntimeException("Stub!"); + } + + static AlgorithmParameterSpec fromGCMParameters(AlgorithmParameters params) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static AlgorithmParameterSpec toGCMParameterSpec(int tagLenInBits, byte[] iv) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static Object closeGuardGet() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void closeGuardOpen(@SuppressWarnings("unused") Object guardObj, + @SuppressWarnings("unused") String message) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void closeGuardClose(@SuppressWarnings("unused") Object guardObj) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void closeGuardWarnIfOpen(@SuppressWarnings("unused") Object guardObj) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void blockGuardOnNetwork() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String oidToAlgorithmName(String oid) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static SSLSession wrapSSLSession(ExternalSession sslSession) { + throw new RuntimeException("Stub!"); + } + + public static String getOriginalHostNameFromInetAddress(InetAddress addr) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static String getHostStringFromInetSocketAddress(InetSocketAddress addr) { + throw new RuntimeException("Stub!"); + } + + static boolean supportsX509ExtendedTrustManager() { + throw new RuntimeException("Stub!"); + } + + static boolean isCTVerificationRequired(String hostname) { + throw new RuntimeException("Stub!"); + } + + static boolean supportsConscryptCertStore() { + throw new RuntimeException("Stub!"); + } + + static KeyStore getDefaultCertKeyStore() throws KeyStoreException { + throw new RuntimeException("Stub!"); + } + + static ConscryptCertStore newDefaultCertStore() { + throw new RuntimeException("Stub!"); + } + + static CertBlocklist newDefaultBlocklist() { + throw new RuntimeException("Stub!"); + } + + static CTLogStore newDefaultLogStore() { + throw new RuntimeException("Stub!"); + } + + static CTPolicy newDefaultPolicy(CTLogStore logStore) { + throw new RuntimeException("Stub!"); + } + + static boolean serverNamePermitted(SSLParametersImpl parameters, String serverName) { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + public static ConscryptHostnameVerifier getDefaultHostnameVerifier() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static long getMillisSinceBoot() { + throw new RuntimeException("Stub!"); + } + + @SuppressWarnings("unused") + static void countTlsHandshake( + boolean success, String protocol, String cipherSuite, long duration) { + throw new RuntimeException("Stub!"); + } + + public static boolean isJavaxCertificateSupported() { + throw new RuntimeException("Stub!"); + } +} diff --git a/platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java b/platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java new file mode 100644 index 000000000..f2db0ce26 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/SSLParametersImpl.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt; + +public class SSLParametersImpl { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java b/platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java new file mode 100644 index 000000000..4d7ffa2d9 --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ct/CTLogStore.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt.ct; + +public class CTLogStore { +} diff --git a/platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java b/platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java new file mode 100644 index 000000000..131a5f4eb --- /dev/null +++ b/platform-stub/src/main/java/org/conscrypt/ct/CTPolicy.java @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Android Open Source Project + * + * 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 + * + * http://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. + */ + +/* + * Copyright 2013 The Netty Project + * + * The Netty Project licenses this file to you 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: + * + * http://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.conscrypt.ct; + +public class CTPolicy { +} diff --git a/platform/build.gradle b/platform/build.gradle index e2da924b9..42da3988a 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -68,10 +68,7 @@ if (androidSdkInstalled) { sourceSets { main { java { - srcDirs = [ - "${rootDir}/common/src/main/java", - "src/main/java", - ] + srcDirs = [ "src/main/java" ] excludes = [ 'org/conscrypt/Platform.java' ] } } @@ -86,7 +83,7 @@ if (androidSdkInstalled) { } dependencies { - implementation project(path: ':conscrypt-openjdk', configuration: 'platform') + implementation project(':conscrypt-common') publicApiDocs project(':conscrypt-api-doclet') androidTestImplementation('androidx.test.espresso:espresso-core:3.1.1', { exclude module: 'support-annotations' diff --git a/settings.gradle b/settings.gradle index 2eefbc7a4..6f39af8cd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,10 +7,12 @@ include ":conscrypt-benchmark-android" include ":conscrypt-benchmark-base" include ":conscrypt-benchmark-graphs" include ":conscrypt-benchmark-jmh" +include ":conscrypt-common" include ":conscrypt-constants" include ":conscrypt-libcore-stub" include ":conscrypt-openjdk" include ":conscrypt-openjdk-uber" +include ":conscrypt-platform-stub" include ":conscrypt-testing" project(':conscrypt-android').projectDir = "$rootDir/android" as File @@ -21,8 +23,10 @@ project(':conscrypt-benchmark-android').projectDir = "$rootDir/benchmark-android project(':conscrypt-benchmark-base').projectDir = "$rootDir/benchmark-base" as File project(':conscrypt-benchmark-graphs').projectDir = "$rootDir/benchmark-graphs" as File project(':conscrypt-benchmark-jmh').projectDir = "$rootDir/benchmark-jmh" as File +project(':conscrypt-common').projectDir = "$rootDir/common" as File project(':conscrypt-constants').projectDir = "$rootDir/constants" as File project(':conscrypt-libcore-stub').projectDir = "$rootDir/libcore-stub" as File project(':conscrypt-openjdk').projectDir = "$rootDir/openjdk" as File project(':conscrypt-openjdk-uber').projectDir = "$rootDir/openjdk-uber" as File +project(':conscrypt-platform-stub').projectDir = "$rootDir/platform-stub" as File project(':conscrypt-testing').projectDir = "$rootDir/testing" as File From ffd0d0c4c77267bde0f492058dea395bd3c13c28 Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Wed, 9 Aug 2023 17:38:50 +0100 Subject: [PATCH 2/8] Lint fixes --- android/build.gradle | 4 ++-- build.gradle | 4 ++-- openjdk/build.gradle | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 8ffce8623..37f6a329e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -143,14 +143,14 @@ if (androidSdkInstalled) { def javadocsJar = tasks.register("javadocsJar", Jar) { dependsOn javadocs - classifier = 'javadoc' + archiveClassifier = 'javadoc' from { javadocs.get().destinationDir } } def sourcesJar = tasks.register("sourcesJar", Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from android.sourceSets.main.java.srcDirs } diff --git a/build.gradle b/build.gradle index 640e58c55..2189e400b 100644 --- a/build.gradle +++ b/build.gradle @@ -200,12 +200,12 @@ subprojects { } tasks.register("javadocJar", Jar) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from javadoc } tasks.register("sourcesJar", Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from sourceSets.main.allSource } diff --git a/openjdk/build.gradle b/openjdk/build.gradle index c26de0191..ba0d032ce 100644 --- a/openjdk/build.gradle +++ b/openjdk/build.gradle @@ -168,11 +168,15 @@ processResources { } tasks.register("testJar", ShadowJar) { - classifier = 'tests' + archiveClassifier = 'tests' configurations = [project.configurations.testRuntimeClasspath] from sourceSets.test.output } +tasks.named("sourcesJar") { + dependsOn generateProperties +} + if (isExecutableOnPath('cpplint')) { def cpplint = tasks.register("cpplint", Exec) { executable = 'cpplint' From 1546bd0d46abb5c5b6a3fd67e544025a55d3978c Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Sun, 13 Aug 2023 20:45:02 +0100 Subject: [PATCH 3/8] Fix javadoc sources. Still various Javadoc issues remain but they existed before this PR. --- android/build.gradle | 15 +++++++++++---- openjdk/build.gradle | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 37f6a329e..4970a2a9f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -82,6 +82,7 @@ if (androidSdkInstalled) { resources { srcDirs += "build/generated/resources" } + project(':conscrypt-common').sourceSets.main } externalNativeBuild { cmake { @@ -103,7 +104,7 @@ if (androidSdkInstalled) { } dependencies { - api project(path: ':conscrypt-common', configuration: 'runtimeElements') + api project(':conscrypt-common') publicApiDocs project(':conscrypt-api-doclet') @@ -129,13 +130,19 @@ if (androidSdkInstalled) { def javadocs = tasks.register("javadocs", Javadoc) { dependsOn configureJavadocs - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + project(':conscrypt-android-stub').sourceSets.main.output + dependsOn generateProperties + source = project(':conscrypt-common').sourceSets.main.java + + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + classpath += project(':conscrypt-android-stub').sourceSets.main.output + classpath += project(':conscrypt-constants').sourceSets.main.output + classpath += project(':conscrypt-platform-stub').sourceSets.main.output + // TODO(nmittler): Fix the javadoc errors. failOnError false options { encoding = 'UTF-8' - links "https://docs.oracle.com/javase/7/docs/api/" + links "https://docs.oracle.com/javase/8/docs/api/" // TODO(prb): Update doclet to Java 11. // doclet = "org.conscrypt.doclet.FilterDoclet" } diff --git a/openjdk/build.gradle b/openjdk/build.gradle index ba0d032ce..9933c3028 100644 --- a/openjdk/build.gradle +++ b/openjdk/build.gradle @@ -136,7 +136,8 @@ sourceSets { resources { srcDirs += "build/generated/resources" } - } + project(':conscrypt-common').sourceSets.main + } test { java { @@ -145,6 +146,7 @@ sourceSets { resources { srcDirs = [ "src/test/resources" ] } + project(':conscrypt-common').sourceSets.test } // Add the source sets for each of the native builds @@ -329,7 +331,16 @@ jacocoTestReport { } javadoc { - dependsOn(configurations.publicApiDocs) + dependsOn configurations.publicApiDocs + dependsOn generateProperties + source = project(':conscrypt-common').sourceSets.main.java + + failOnError false + options { + encoding = 'UTF-8' + links "https://docs.oracle.com/javase/8/docs/api/" + } + // TODO(prb): Update doclet to Java 11. // options.doclet = "org.conscrypt.doclet.FilterDoclet" // options.docletpath = configurations.publicApiDocs.files as List From b01d229dae99c0795317ccf0dc9c49c197cfa4fb Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Mon, 14 Aug 2023 17:35:26 +0100 Subject: [PATCH 4/8] Fix sourcesJar generation. --- android/build.gradle | 1 + build.gradle | 2 ++ common/build.gradle | 5 +++++ platform-stub/build.gradle | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index 4970a2a9f..8222526b0 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -159,6 +159,7 @@ if (androidSdkInstalled) { def sourcesJar = tasks.register("sourcesJar", Jar) { archiveClassifier = 'sources' from android.sourceSets.main.java.srcDirs + from project(":conscrypt-common").sourceSets.main.java.srcDirs } apply from: "$rootDir/gradle/publishing.gradle" diff --git a/build.gradle b/build.gradle index 2189e400b..e7f603370 100644 --- a/build.gradle +++ b/build.gradle @@ -207,6 +207,8 @@ subprojects { tasks.register("sourcesJar", Jar) { archiveClassifier = 'sources' from sourceSets.main.allSource + from project(":conscrypt-common").sourceSets.main.java.srcDirs + } // At a test failure, log the stack trace to the console so that we don't diff --git a/common/build.gradle b/common/build.gradle index e7bffffc4..c4a66559f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -34,6 +34,11 @@ tasks.withType(Test).configureEach { enabled = false } +// Only export source as part of other sub-projects' source jars. +tasks.named("sourcesJar") { + enabled = false +} + // Whhyyyyyyyyyyyyyyyyyyyyyyyy! // For some reason Gradle seems to be copying all the resources twice, so errors without this. tasks.named("processTestResources") { diff --git a/platform-stub/build.gradle b/platform-stub/build.gradle index 953584098..f32a429c2 100644 --- a/platform-stub/build.gradle +++ b/platform-stub/build.gradle @@ -7,3 +7,8 @@ sourceSets { } } } + +// Nope. +tasks.named("sourcesJar") { + enabled = false +} From c9e103953d259dc340d57a0ff0db4db06ca6391e Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Sun, 3 Sep 2023 14:58:16 +0100 Subject: [PATCH 5/8] Remove extraneous cmake version. When specified in a defaultConfig block it ends up setting the module version too..... --- android/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 8222526b0..cf1b8f873 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -62,7 +62,6 @@ if (androidSdkInstalled) { '-D_XOPEN_SOURCE=700', '-Wno-unused-parameter' targets 'conscrypt_jni' - version androidCmakeVersion } } ndk { From fd35a0ed3b2d9010dcac6c2fdc6833ad8d99f604 Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Mon, 4 Sep 2023 10:15:08 +0100 Subject: [PATCH 6/8] Dependency fix. --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index cf1b8f873..a1ac04bc8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -103,7 +103,7 @@ if (androidSdkInstalled) { } dependencies { - api project(':conscrypt-common') + implementation project(':conscrypt-common') publicApiDocs project(':conscrypt-api-doclet') From de6a78dc5ce5446947c2a26550fa632369683518 Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Tue, 9 Jan 2024 11:25:42 +0000 Subject: [PATCH 7/8] Fix Android publishing. Was using a no-longer-needed 3P plugin which doesn't work correctly with the latest AGP. Now is at least publishing an AAR even though it doesn't contain the common classes. --- android/build.gradle | 16 +++++++--------- .../src/main/java/org/conscrypt/Platform.java | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index a1ac04bc8..2dde12e2b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,10 +8,6 @@ buildscript { } } -plugins { - id 'digital.wup.android-maven-publish' version '3.6.2' -} - description = 'Conscrypt: Android' ext { @@ -161,11 +157,13 @@ if (androidSdkInstalled) { from project(":conscrypt-common").sourceSets.main.java.srcDirs } - apply from: "$rootDir/gradle/publishing.gradle" - publishing.publications.maven { - from components.android - artifact sourcesJar.get() - artifact javadocsJar.get() + afterEvaluate { + apply from: "$rootDir/gradle/publishing.gradle" + publishing.publications.maven { + from components.release + artifact sourcesJar.get() + artifact javadocsJar.get() + } } } else { logger.warn('Android SDK has not been detected. The Android module will not be built.') diff --git a/platform-stub/src/main/java/org/conscrypt/Platform.java b/platform-stub/src/main/java/org/conscrypt/Platform.java index 8df5f351c..c1607959a 100644 --- a/platform-stub/src/main/java/org/conscrypt/Platform.java +++ b/platform-stub/src/main/java/org/conscrypt/Platform.java @@ -367,4 +367,8 @@ static void countTlsHandshake( public static boolean isJavaxCertificateSupported() { throw new RuntimeException("Stub!"); } + + public static boolean isTlsV1Deprecated() { + throw new RuntimeException("Stub!"); + } } From c9ed33e2523c55895a062e4fbf28798821c56479 Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Tue, 9 Jan 2024 16:34:51 +0000 Subject: [PATCH 8/8] Publish all classes for Android builds. 1. Remove the implementation dependency from :conscrypt-android to :conscrypt-common as that ends up exposing conscrypt-common as a dependency in the POM file. 2. Just copy the actual class files from the :conscrypt-common output into the :conscrypt-android build directory before the AAR is built. --- android/build.gradle | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 2dde12e2b..df7e11a75 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -99,7 +99,7 @@ if (androidSdkInstalled) { } dependencies { - implementation project(':conscrypt-common') + compileOnly project(':conscrypt-common') publicApiDocs project(':conscrypt-api-doclet') @@ -157,7 +157,28 @@ if (androidSdkInstalled) { from project(":conscrypt-common").sourceSets.main.java.srcDirs } + // This is ugly but works: For both release and debug builds copy the classes from the + // common compilation before the final AAR is built. + def copyDebugCommon = tasks.register('copyDebugCommon', Copy) { + from project(':conscrypt-common').sourceSets.main.output + into buildDir.absolutePath + '/intermediates/javac/debug/classes' + dependsOn ':conscrypt-common:compileJava' + } + + def copyReleaseCommon = tasks.register('copyReleaseCommon', Copy) { + from project(':conscrypt-common').sourceSets.main.output + into buildDir.absolutePath + '/intermediates/javac/release/classes' + dependsOn ':conscrypt-common:compileJava' + } + afterEvaluate { + tasks.named('javaPreCompileDebug') { + dependsOn copyDebugCommon + } + tasks.named('javaPreCompileRelease') { + dependsOn copyReleaseCommon + } + apply from: "$rootDir/gradle/publishing.gradle" publishing.publications.maven { from components.release