google-sheets-import-plugin Maven Mojo

Maven plugin to import data from Google Sheets into JSON files

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.paf.maven
ArtifactId

ArtifactId

google-sheets-import-plugin
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

google-sheets-import-plugin Maven Mojo
Maven plugin to import data from Google Sheets into JSON files
Project URL

Project URL

https://github.com/pafoss/google-sheets-import-plugin
Source Code Management

Source Code Management

https://github.com/pafoss/google-sheets-import-plugin

Download google-sheets-import-plugin

How to add to project

<plugin>
    <groupId>com.paf.maven</groupId>
    <artifactId>google-sheets-import-plugin</artifactId>
    <version>1.1.0</version>
</plugin>

Dependencies

compile (8)

Group / Artifact Type Version
org.apache.maven : maven-core jar 3.6.0
org.apache.maven : maven-plugin-api jar 3.6.0
com.google.api-client : google-api-client jar 1.30.9
com.google.auth : google-auth-library-oauth2-http jar 0.20.0
com.google.apis : google-api-services-sheets jar v4-rev612-1.25.0
com.fasterxml.jackson.module : jackson-module-kotlin jar 2.10.3
org.jetbrains.kotlin : kotlin-reflect jar 1.3.72
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.72

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.6.0

test (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-test-junit jar 1.3.72

Project Modules

There are no modules declared in this project.

google-sheets-import-plugin

Maven plugin that automatically imports data from Google Sheets into the project.

Given a Google Spreadsheet ID, it will create one JSON file for each sheet of the document on the specified output path. This plugin assumes that the spreadsheets are data grids where the first row are the column headers.

Configuration

Google API service account

In order to be able to access your spreadsheet, you need to create a Google APIs service account.

  • Create a project at https://console.developers.google.com/apis/dashboard
  • Make sure that the Google Sheets API is enabled by clicking on "Enable APIs and services"
  • Go to Credentials -> Create credentials -> Service Account and create a new one.
  • Once the service account has been created, create a new key and download the JSON file. You can use this JSON file to configure the googleApiCredentialsFile configuration property of this plugin.

Plugin setup

Include the following configuration into your pom.xml file:

<build>
    <plugins>
        <plugin>
            <groupId>com.paf.maven</groupId>
            <artifactId>google-sheets-import-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>import-sheets</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outputDirectory>${project.build.directory}/resources</outputDirectory>
                <googleSheetId>${your_google_sheet_id}</googleSheetId>
                <googleApiCredentialsFile>${project.basedir}/credentials.json</googleApiCredentialsFile>
                <prettyPrint>true</prettyPrint>
            </configuration>
        </plugin>
    </plugins>
</build>

Granting access to your spreadsheet

Make sure that your spreadsheet is either publicly visible or your service account has access to it. The Google APIs service accounts are created with an email address associated to it in the format [email protected]. Sharing the document with that address with read-only permissions will suffice.

com.paf.maven

Paf Open Source

Versions

Version
1.1.0
1.0.0
0.0.5