Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[firebase_core] Automate version retrieval #1733

Merged
merged 5 commits into from
Jun 13, 2019

Conversation

kroikie
Copy link
Contributor

@kroikie kroikie commented Jun 12, 2019

Description

  • Automate the retrieval of the plugin's version for user agent reporting to Firebase.

Copy link
Contributor

@collinjackson collinjackson left a comment

Choose a reason for hiding this comment

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

Looks good for the Android side; a few nits

@@ -8,7 +8,7 @@

public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
private static final String LIBRARY_NAME = "flutter-fire-core";
private static final String LIBRARY_VERSION = "0.4.0+3";
private static final String LIBRARY_VERSION = BuildConfig.FLUTTER_FIRE_VERSION;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to declare it here; you can just use BuildConfig.VERSION_NAME below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

android {
compileSdkVersion 28

defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "FLUTTER_FIRE_VERSION", "\"${flutterFireVersion()}\""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would call this VERSION_NAME; FLUTTER_FIRE is a bit non standard compared to what other SDKs are doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@collinjackson collinjackson force-pushed the auto-user-agent-version branch from 489879d to 604ef79 Compare June 12, 2019 22:47
@kroikie kroikie merged commit 1e01c9e into flutter:master Jun 13, 2019
* @return String representing version of the plugin.
*/
def flutterFireVersion() {
File pubspec = new File('../../pubspec.yaml')
Copy link
Member

Choose a reason for hiding this comment

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

This may be cleaner:

File pubspec = new File(project.projectDir.parentFile,  'pubspec.yaml')

project.projectDir = <pluginRoot>/android
parentFile = <pluginRoot>


Otherwise should probably use File.separator for Windows support instead of /

@Override
public List<Component<?>> getComponents() {
return Collections.<Component<?>>singletonList(
LibraryVersionComponent.create(LIBRARY_NAME, LIBRARY_VERSION));
LibraryVersionComponent.create(
"flutter-fire-core", BuildConfig.VERSION_NAME.replaceAll("\\+", "-")));
Copy link
Member

Choose a reason for hiding this comment

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

Does this replace all need to be done at runtime - can we move the logic to build time inside of the flutterFireVersion() method?

@@ -18,4 +18,11 @@ A new flutter plugin project.
s.dependency 'Firebase/Core'
s.ios.deployment_target = '8.0'
s.static_framework = true

s.prepare_command = <<-CMD
Copy link
Member

@Salakar Salakar Jun 13, 2019

Choose a reason for hiding this comment

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

CocoaPods already provides the versions via an NSBundle for each podspec, as shown in my other PR - not sure if code-gen is needed if we already have the version at runtime

@@ -18,4 +18,11 @@ A new flutter plugin project.
s.dependency 'Firebase/Core'
s.ios.deployment_target = '8.0'
s.static_framework = true

s.prepare_command = <<-CMD
PUBSPEC_VERSION=`cat ../pubspec.yaml | grep version: | sed 's/version: //g'`
Copy link
Member

Choose a reason for hiding this comment

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

It's possible to read the yaml file via the default Ruby yaml library that comes with OSX

require 'yaml'
pubspec = YAML.load_file(File.join('..', 'pubspec.yaml'))

# ...

Pod::UI.puts "This plugin version is '#{pubspec['version']}'"

@kroikie kroikie deleted the auto-user-agent-version branch June 13, 2019 15:09
@ened
Copy link
Contributor

ened commented Jun 13, 2019

This PR currently breaks plugin integrations as shown in #34385.

collinjackson added a commit to collinjackson/plugins that referenced this pull request Jun 13, 2019
collinjackson added a commit that referenced this pull request Jun 13, 2019
* Revert "[firebase_core] Automate version retrieval (#1733)"

This reverts commit 1e01c9e.

* Update versions and CHANGELOG to call this version 0.4.0+5
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
* Revert "[firebase_core] Automate version retrieval (flutter#1733)"

This reverts commit 1e01c9e.

* Update versions and CHANGELOG to call this version 0.4.0+5
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants