Skip to content

Commit

Permalink
Reorganizing dirs (#391)
Browse files Browse the repository at this point in the history
* Renaming test-tools dir

* Moving animalsniffer signature project to internal tools

* Clean up

* Renaming android-plugin

* Renaming android-sdk

* Renaming android-api

* Renaming android-common

* Renaming android-test

* Renaming android-test

* Renaming root module

* Updated tests

* Running debug variant tests

* Uploading test failed reports

* Uploading test failed reports
  • Loading branch information
LikeTheSalad authored Feb 17, 2025
1 parent d3a7c8e commit b297c6a
Show file tree
Hide file tree
Showing 201 changed files with 55 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
with:
name: test-results
path: |
**/build/test-results/testRelease*/TEST-*.xml
**/build/reports/tests/testDebugUnitTest/**/*
**/build/test-results/testDebug*/TEST-*.xml
**/build/test-results/test/TEST-*.xml
**/build/outputs/androidTest-results/**/TEST-*.xml
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ plugins {
}

dependencies {
api(project(":android-common"))
api(project(":agent-common"))
implementation(libs.byteBuddy)
implementation(libs.byteBuddy.plugin)
compileOnly(libs.android.plugin)
}

buildConfig {
packageName("${group}.generated")
buildConfigField("String", "SDK_DEPENDENCY_URI", "\"$group:android-sdk:$version\"")
buildConfigField("String", "SDK_DEPENDENCY_URI", "\"$group:agent-sdk:$version\"")
}

gradlePlugin {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions android-sdk/build.gradle.kts → agent-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ android {
}

dependencies {
api(project(":android-api"))
api(project(":agent-api"))
api(project(":instrumentation:api"))
implementation(libs.stagemonitor.configuration)
implementation(project(":android-common"))
implementation(project(":agent-common"))
implementation(libs.opentelemetry.exporter.otlp)
implementation(libs.bundles.opentelemetry.semconv)
implementation(libs.opentelemetry.diskBuffering)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,42 @@ import io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat
import java.time.Duration
import java.util.UUID
import org.awaitility.kotlin.await
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
import org.junit.rules.ExternalResource

class WireMockRule : TestRule {
private var wireMock: WireMockServer? = null
private var allResponsesStubId: UUID? = null
class WireMockRule : ExternalResource() {
private val wireMock = WireMockServer()
private var allResponsesStubId = UUID.randomUUID()

override fun apply(base: Statement, description: Description): Statement {
try {
return object : Statement() {
override fun evaluate() {
base.evaluate()
wireMock?.stop()
}
}
} finally {
wireMock = null
allResponsesStubId = null
}
override fun before() {
wireMock.start()
}

override fun after() {
wireMock.stop()
}

fun url(path: String): String {
ensureStarted()
return wireMock!!.url(path)
return wireMock.url(path)
}

fun stubAllHttpResponses(
responseVisitor: ResponseDefinitionBuilder.() -> Unit = {}
) {
ensureStarted()
wireMock!!.removeStub(allResponsesStubId)
wireMock.removeStub(allResponsesStubId)
val mappingBuilder = any(anyUrl()).withId(allResponsesStubId)
val response = aResponse()
responseVisitor(response)
mappingBuilder.willReturn(response)
wireMock!!.stubFor(mappingBuilder)
}

private fun ensureStarted() {
if (wireMock == null) {
allResponsesStubId = UUID.randomUUID()
wireMock = WireMockServer()
wireMock?.start()
}
wireMock.stubFor(mappingBuilder)
}

fun takeRequest(awaitSeconds: Int = 2): LoggedRequest {
await.atMost(Duration.ofSeconds(awaitSeconds.toLong()))
.until { wireMock?.allServeEvents?.isNotEmpty() }
val allServeEvents = wireMock?.allServeEvents
.until { wireMock.allServeEvents?.isNotEmpty() }
val allServeEvents = wireMock.allServeEvents
assertThat(allServeEvents).hasSize(1)
val serveEvent = allServeEvents?.first()
wireMock?.removeServeEvent(serveEvent?.id)
wireMock.removeServeEvent(serveEvent?.id)
return serveEvent!!.request
}
}
2 changes: 1 addition & 1 deletion android_tests.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./gradlew -p "android-test" connectedCheck
./gradlew -p "instrumentation-test" connectedCheck
1 change: 0 additions & 1 deletion animalsniffer-signature/metadata/notice.properties

This file was deleted.

2 changes: 0 additions & 2 deletions animalsniffer-signature/src/main/resources/META-INF/NOTICE

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void apply(Project project) {
addPostDeployTask(project);
configureMavenCentral(project);
project.subprojects(subproject -> {
if (!subproject.getPath().contains("test-tools")) {
if (!subproject.getPath().startsWith(":internal-tools")) {
Matcher instrumentationMatcher = INSTRUMENTATION_PROJECT_PATTERN.matcher(subproject.getPath());
if (instrumentationMatcher.matches()) {
setGroupId(subproject, subproject.getGroup() + ".instrumentation");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void updateSetupDoc(String currentVersion) {
log("Updating setup doc to show version: " + currentVersion);
Path setupDocPath = getProjectPath("docs/setup.asciidoc");
String contents = getContents(setupDocPath);
Pattern versionMentionsPattern = Pattern.compile("(?<=co\\.elastic\\.apm\\.android/)\\d+\\.\\d+\\.\\d+|(?<=co\\.elastic\\.apm:android-sdk:)\\d+\\.\\d+\\.\\d+|(?<=id\\s\"co\\.elastic\\.apm\\.android\"\\sversion\\s\")\\d+\\.\\d+\\.\\d+");
Pattern versionMentionsPattern = Pattern.compile("(?<=co\\.elastic\\.apm\\.android/)\\d+\\.\\d+\\.\\d+|(?<=co\\.elastic\\.apm:agent-sdk:)\\d+\\.\\d+\\.\\d+|(?<=id\\s\"co\\.elastic\\.apm\\.android\"\\sversion\\s\")\\d+\\.\\d+\\.\\d+");
Matcher versionMentionMatcher = versionMentionsPattern.matcher(contents);

String setupDocWithNewVersion = versionMentionMatcher.replaceAll(currentVersion);
Expand Down
11 changes: 10 additions & 1 deletion build-tools/src/main/kotlin/elastic.android-library.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.android.build.api.variant.HasHostTestsBuilder
import com.android.build.api.variant.HostTestBuilder

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
Expand Down Expand Up @@ -27,6 +30,12 @@ android {
}
}

androidComponents.beforeVariants {
if (it.buildType?.equals("debug") == false) {
(it as HasHostTestsBuilder).hostTests.get(HostTestBuilder.UNIT_TEST_TYPE)?.enable = false
}
}

tasks.withType(Test::class).configureEach {
useJUnitPlatform()
}
Expand All @@ -36,6 +45,6 @@ dependencies {
testImplementation(libs.findBundle("mocking").get())
testImplementation(libs.findBundle("junit").get())
testImplementation(libs.findLibrary("assertj").get())
testImplementation(project(":test-tools:test-common"))
testImplementation(project(":internal-tools:test-common"))
testRuntimeOnly(libs.findLibrary("junit5-vintage").get())
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ plugins {
}

dependencies {
signature(project(path = ":animalsniffer-signature", configuration = "generatedSignature"))
signature(
project(
path = ":internal-tools:animalsniffer-signature",
configuration = "generatedSignature"
)
)
}

val capitalizedVariantNames = mutableListOf<String>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ project.extensions.create(
)

dependencies {
implementation(project(":android-plugin"))
implementation(project(":android-api"))
implementation(project(":agent-plugin"))
implementation(project(":agent-api"))
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion instrumentation/api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ android {
}

dependencies {
api(project(":android-api"))
api(project(":agent-api"))
}
2 changes: 1 addition & 1 deletion instrumentation/crash/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ dependencies {
implementation(instrumentation.opentelemetry.api.incubator)
testImplementation(libs.robolectric)
testImplementation(libs.opentelemetry.testing)
testImplementation(project(":test-tools:robolectric-agent-rule"))
testImplementation(project(":internal-tools:robolectric-agent-rule"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
implementation(project(":android-sdk"))
implementation(project(":test-tools:test-common"))
implementation(project(":agent-sdk"))
implementation(project(":internal-tools:test-common"))
implementation(libs.opentelemetry.testing)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
api(project(":test-tools:agent-rule"))
api(project(":internal-tools:agent-rule"))
api(instrumentation.bundles.androidTest)
api(libs.opentelemetry.testing)
api(libs.assertj)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ plugins {
}

dependencies {
api(project(":test-tools:agent-rule"))
api(project(":internal-tools:agent-rule"))
implementation(libs.robolectric)
}
File renamed without changes.
13 changes: 6 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ dependencyResolutionManagement {
google()
}
}
rootProject.name = "APM Android Agent"
rootProject.name = "elastic-otel-android"
includeBuild("build-tools")
include(":android-api")
include(":android-sdk")
include(":android-plugin")
include(":android-common")
include(":animalsniffer-signature")
include(":agent-api")
include(":agent-sdk")
include(":agent-plugin")
include(":agent-common")
includeFromDir("instrumentation")
includeFromDir("test-tools", 2)
includeFromDir("internal-tools", 2)

fun includeFromDir(dirName: String, maxDepth: Int = 3) {
val instrumentationDir = File(rootDir, dirName)
Expand Down

0 comments on commit b297c6a

Please sign in to comment.