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>
...
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.
-
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
-
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 tostable
-
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}
-
Flutter binary base download URL. This property can be defined in command line with
-Dflutter-download-root
Default tohttps://storage.googleapis.com/flutter_infra/releases/
-
Flutter git URL. This property can be defined in command line with
-Dflutter-git-url
Default tohttps://github.com/flutter/flutter.git
-
Skip install. This property can be defined in command line with
-Dflutter-install-skip=true
-
The base directory for installing flutter This property can be defined in command line with
-Dflutter-install-directory
Default to:${basedir}/.flutter
-
The temp directory for installing flutter. This property can be defined in command line with
-Dflutter-temp-directory
Default to:${basedir}/target/temp
-
Environment variables added to the execution of
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.
-
Arguments to flutter. This property can be defined in command line with
-Dflutter-arguments
. Default topub get
-
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}
-
Skip execution. This property can be defined in command line with
-Dflutter-skip=true
-
The base directory of flutter installation This property can be defined in command line with
-Dflutter-install-directory
Default to:${basedir}/.flutter
-
Environment variables added to the execution of
flutter
. -
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 parallelpub 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>
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.
Please post any issues on the Github’s Issue tracker. Pull requests are welcome! You can find a full list of contributors here.
This project heavly insipred by Frontend maven plugin.