Giter Club home page Giter Club logo

flutter-maven-plugin's Introduction

Flutter maven plugin

develop

This plugin manages and executes flutter commands inside maven project. It handles the flutter installation, preinstalled flutter isn’t required to use.

Requirements

  • Maven 3.6 and Java 1.8

Installation

Include the plugin as a dependency in your Maven project. Change LATEST_VERSION to the latest tagged version.

<plugins>
    <plugin>
        <groupId>hu.blackbelt</groupId>
        <artifactId>flutter-maven-plugin</artifactId>
        <!-- Use the latest released version:
        https://repo1.maven.org/maven2/hu/blackbelt/flutter-maven-plugin/ -->
        <version>LATEST_VERSION</version>
        ...
    </plugin>
...

Usage

Installing flutter for the project.

The versions of flutter are downloaded from https://storage.googleapis.com/flutter_infra/releases/, extracted and put into a .flutter folder created in your installation directory, or checked out from git. Flutter will only be "installed" locally to your project. It will not be installed globally on the whole system (and it will not interfere with any flutter installations already present).

<execution>
    <id>install-flutter</id>
    <phase>generate-sources</phase>
    <goals>
        <goal>install-flutter</goal>
    </goals>
    <configuration>
        <flutterVersion>1.23</flutterVersion> <!--(1)-->
        <flutterChannel>stable</flutterChannel>   <!--(2)-->
        <workingDirectory>${basedir}</workingDirectory>   <!--(3)-->
        <flutterDownloadRoot>https://storage.googleapis.com/flutter_infra/releases/</flutterDownloadRoot> <!--(4)-->
        <flutterGitUrl>https://github.com/flutter/flutter.git</flutterGitUrl> <!--(5)-->

        <skip>false</skip> <!--(6)-->
        <installDirectory>${basedir}/.flutter</installDirectory>   <!--(7)-->
        <tempDirectory>${basedir}/target/temp</tempDirectory>   <!--(8)-->

        <environmentVariables> <!--(9)-->
            <TEST_VAR>${project.build.directory}</TEST_VAR>
        </environmentVariables>
    </configuration>
</execution>

It can be executed (when pom.xml defines as plugin, full groupId / artifactId / version definition is not required.

mvn flutter:install-flutter -Dflutter-channel="beta"

All parameters are optional.

  1. The installed flutter version. When version is defined channel is not used. In this case the flutter is installed from download site. This property can be defined in command line with -Dflutter-version

  2. The flutter channel is used. When channel is used version can be removed. In this case the git based installation is used. This property can be defined in command line with -Dflutter-channel Default to stable

  3. The base directory for running all Flutter commands. (Usually the directory that contains pubspec.yaml) This property can be defined in command line with -Dflutter-working-directory. Default to ${basedir}

  4. Flutter binary base download URL. This property can be defined in command line with -Dflutter-download-root Default to https://storage.googleapis.com/flutter_infra/releases/

  5. Flutter git URL. This property can be defined in command line with -Dflutter-git-url Default to https://github.com/flutter/flutter.git

  6. Skip install. This property can be defined in command line with -Dflutter-install-skip=true

  7. The base directory for installing flutter This property can be defined in command line with -Dflutter-install-directory Default to: ${basedir}/.flutter

  8. The temp directory for installing flutter. This property can be defined in command line with -Dflutter-temp-directory Default to: ${basedir}/target/temp

  9. Environment variables added to the execution of flutter.

Running flutter

<execution>
    <id>flutter</id>
    <phase>compile</phase>
    <goals>
        <goal>flutter</goal>
    </goals>
    <configuration>
        <arguments></arguments> <!--(1)-->
        <workingDirectory>${basedir}</workingDirectory>   <!--(2)-->
        <skip>false</skip> <!--(3)-->
        <installDirectory>${basedir}/.flutter</installDirectory>   <!--(4)-->
        <environmentVariables> <!--(5)-->
            <TEST_VAR>${project.build.directory}</TEST_VAR>
        </environmentVariables>
        <parallel>false</parallel> <!--(6)-->
    </configuration>
</execution>

It can be executed (when pom.xml defines as plug. If doesn’t full groupId / artifactId / version required.

mvn flutter:flutter -Dflutter-arguments="doctor"

All parameters are optional.

  1. Arguments to flutter. This property can be defined in command line with -Dflutter-arguments. Default to pub get

  2. The base directory for running all Flutter commands. (Usually the directory that contains pubspec.yaml) This property can be defined in command line with -Dflutter-working-directory. Default to ${basedir}

  3. Skip execution. This property can be defined in command line with -Dflutter-skip=true

  4. The base directory of flutter installation This property can be defined in command line with -Dflutter-install-directory Default to: ${basedir}/.flutter

  5. Environment variables added to the execution of flutter.

  6. Parallel build enabled in maven. Maven supports parallel build with -T option. The plugin supports parallel build with limitations. When several flutter projects are built in parallel pub get pub clean and some other commands which are related directly to flutter itself can cause harm. To avoid this situation the plugin execution is synchronized by default. There are some project specific build steps whivh can be run parallel, for example compile, build runner.

This property can be defined in command line with -Dflutter-parallel=false

Example to compile and run in chrome:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>hu.blackbelt</groupId>
    <version>LATEST_VERSION</version>
    <artifactId>flutter-maven-plugin-test</artifactId>

    <build>
        <plugins>
            <plugin>
                <groupId>hu.blackbelt</groupId>
                <artifactId>flutter-maven-plugin</artifactId>
                <version>1.0.0-SNAPSHOT</version>
                <executions>
                    <execution>
                        <id>install-flutter</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>install-flutter</goal>
                        </goals>
                        <configuration>
                            <flutterChannel>beta</flutterChannel>
                        </configuration>
                    </execution>

                    <execution>
                        <id>flutter-config-enable-web</id>
                        <phase>compile</phase>
                        <goals><goal>flutter</goal></goals>
                        <configuration>
                            <arguments>config --enable-web</arguments>
                            <parallel>false</parallel>
                        </configuration>
                    </execution>

                    <execution>
                        <id>flutter-pub-get</id>
                        <phase>compile</phase>
                        <goals><goal>flutter</goal></goals>
                        <configuration>
                            <parallel>false</parallel>
                        </configuration>
                    </execution>

                    <execution>
                        <id>run-chrome-get</id>
                        <phase>compile</phase>
                        <goals><goal>flutter</goal></goals>
                        <configuration>
                            <arguments>run -d chrome</arguments>
                        </configuration>
                    </execution>

                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Proxy settings

If you have configured proxy settings for Maven in your settings.xml file, the plugin will automatically use the proxy for downloading flutter, as well as passing the proxy to flutter commands.

To build this project

mvn clean install

Issues, Contributing

Please post any issues on the Github’s Issue tracker. Pull requests are welcome! You can find a full list of contributors here.

Credit

This project heavly insipred by Frontend maven plugin.

License

flutter-maven-plugin's People

Contributors

robertcsakany avatar blackbelt-oss avatar gaborflorian avatar kristofkakuszi avatar

Stargazers

Ilya Nikitenkov avatar qiutian00 avatar iroïd avatar  avatar Eugene Kuleshov avatar  avatar  avatar Adrien Bonnin avatar

Watchers

 avatar James Cloos avatar Norbert Csaba Herczeg avatar Tibor Botos avatar attila kocsis avatar Gábor Privitzky avatar Szőcs Hunor avatar  avatar Zoltán Baji avatar  avatar  avatar

Forkers

jhonn874

flutter-maven-plugin's Issues

add support to run dart commands

If it helps I can try to contribute implementation

Description

Motivation

Several commands aren't available, unsupported or about to be deprecated for the flutter command.
For example, the flutter format is being replaced with dart format in one of the upcoming Flutter releases.
Once that happen we won't be able to use flutter format to enforce the Dart code formatting in our build.

Suggested Implementation

The idea is to add support for the dart-run goal, similar to flutter-run

Alternate Implementations

N/A

plugin is downloading wrong Flutter package on MacOS with Apple silicon

Bug Scope

On MacOS running on Apple silicon the plugin is downloading x86 version of Flutter distribution, it should download the arm64 one.

Current Behavior

You can see in the execution logs that x86 distribution is being downloaded:

https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.7.7-stable.zip

Expected Behavior

When MacOS arch is arm64 it should be using the following package:

https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_arm64_3.7.8-stable.zip

Steps to Reproduce

Any execution of the flutter goal on MacOS arm is affected.

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs / Configuration

[INFO] Downloading https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.7.7-stable.zip

Environment

N/A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.