Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Re-packaging #143

Merged
merged 4 commits into from
Jun 7, 2024
Merged

refactor!: Re-packaging #143

merged 4 commits into from
Jun 7, 2024

Conversation

fabriziodemaria
Copy link
Member

No description provided.

@fabriziodemaria fabriziodemaria force-pushed the re-packaging branch 3 times, most recently from 06ff942 to 635f80c Compare June 4, 2024 13:22
import com.google.protobuf.Struct;
import com.google.protobuf.util.Values;
Copy link
Member Author

@fabriziodemaria fabriziodemaria Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is meant for test class only, makes maven dependency analyzer unhappy.
I just changed to using another proto API that doesn't upset the analyzer

import dev.openfeature.sdk.EvaluationContext;
import dev.openfeature.sdk.Structure;
import dev.openfeature.sdk.Value;
import dev.openfeature.sdk.exceptions.TypeMismatchError;
import io.grpc.netty.shaded.io.netty.util.internal.StringUtil;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to remove this dependency for String checks

@@ -0,0 +1,48 @@
package com.spotify.confidence;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just copied as is

import java.util.Map;
import java.util.concurrent.CompletableFuture;

public class ResolverClientTestUtils {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied as is


import java.time.Instant;

public class FakeClock implements Clock {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied as is

import java.util.List;
import java.util.Optional;

public class FakeEventSenderEngine implements EventSenderEngine {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied as is

@fabriziodemaria fabriziodemaria force-pushed the re-packaging branch 3 times, most recently from a755de6 to cd479c9 Compare June 4, 2024 13:48
Comment on lines +25 to +30
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
Copy link
Member Author

@fabriziodemaria fabriziodemaria Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this transitional dependency is even used by us, but it's marked as vulnerable when a user imports our library. This change removes that warning for our user

@fabriziodemaria
Copy link
Member Author

Now tested that both the JARs (OF and native) work on a sample Java executable.
To test this locally, you can install to Maven local via:

mvn clean install -pl openfeature-provider -am -Dgpg.skip=true
mvn clean install -pl java-sdk -am -Dgpg.skip=true

<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
<failOnWarning>false</failOnWarning>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate, but the more specific <ignoredNonTestScopedDependencies> added below didn't work for me to make Maven Analyzer succeed.

The root problem seems to be that io.grpc:grpc-stub is used in compile source code, but it's "meant to be used in tests".

@vahidlazio
Copy link
Contributor

tested the modules with local jar installed with mvn install and it works.

@@ -2,7 +2,7 @@
"bootstrap-sha": "188faf7e47b03bde3bf02c3521771301c77580d6",
"packages": {
".": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This . signals that we release (with release please) the whole repo as one release (which means the SDK will bump its number even if we only have changes in the open feature provider).

I guess it would be the easiest approach and maybe we could improve on it later.

release-please-config.json Outdated Show resolved Hide resolved
Comment on lines -414 to -460
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>.proto</resource>
<resource>checkstyle.xml</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
<addHeader>true</addHeader>
</transformer>
</transformers>
<relocations>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.spotify.confidence.shaded.com.google</shadedPattern>
</relocation>
<relocation>
<pattern>io.grpc</pattern>
<shadedPattern>com.spotify.confidence.shaded.io.grpc</shadedPattern>
</relocation>
</relocations>
<artifactSet>
<excludes>
<exclude>dev.openfeature:sdk</exclude>
<exclude>org.slf4j:slf4j-api</exclude>
<exclude>javax.annotation:javax.annotation-api</exclude>
<exclude>org.checkerframework:checker-qual</exclude>
<exclude>com.google.code.findbugs:jsr305</exclude>
<exclude>com.google.android:annotations</exclude>
<exclude>org.codehaus.mojo:animal-sniffer-annotations</exclude>
<exclude>io.perfmark:perfmark-api</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These needs to be moved to the confidence pom.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shading grpc classes from Confidence currently breaks the OpenFeature part, since the latter now doesn't use shaded grpc dependencies. Since the shading is confusing, I wonder if we could remove it until it's clear that we actually need it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why would openfeature need to know about grpc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This constructor accepting a ManagedChannel from the application and passing it to the Confidence object: link

My understanding is that if we accept the shaded ManagedChannel, the same one should be used in that method's signature, but the shaded version is not visible in the ConfidenceFeatureProvider

@fabriziodemaria fabriziodemaria merged commit 645e677 into main Jun 7, 2024
3 checks passed
@fabriziodemaria fabriziodemaria deleted the re-packaging branch June 7, 2024 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants