Giter Site home page Giter Site logo

dart-maven-plugin's Introduction

#Maven Dart Plugin

Bitdeli Badge

The Dart Maven Plugin provides integration for Google Dart into a maven build process. It looks for folders with dart package layout

#Changenotes

###3.0.0

  • dart:dart2js Has now the possibility to span mutliple compiler sessions in parallel with threadCount
  • dart:pub Is now full flexible by providing pubCommand e.g. get and a list of pubOptions e.g. --no-offline

#Setup

The plugin needs a dart-sdk installed on the system it should be executed. By default it will look for the environment variable DART_SDK. So please set this variable. It is possible to overwrite this in the plugin configuration section.

#Artifact coordinates

The plugin is released as com.github.dzwicker.dart:dart-maven-plugin

#Requirements

The Dart Maven Plugin needs maven 3.0+ and JDK 7.

#Goals Overview

The Dart Plugin has one goal (besides the help goal). It is already bound to his proper phase within the Maven Lifecycle (compile) and is therefore, automatically executed during his respective phase.

  • dart:dart Goal to invoke the dart scripts.
  • dart:pub Goal to invoke pub the dart package manager.
  • dart:dart2js Goal to compile dart files to javascript.
  • dart:dwc Goal to invoke the dart web compiler.
  • dart:test Goal to invoke the dart scripts.
  • dart:help Display help information on dart-maven-plugin. Call mvn dart:help -Ddetail=true -Dgoal= to display parameter details.

#Usage

The dart2js goal uses the dart2js compiler from the dart project to compile any dart file to javascript (js file) and a map.js file. It will download the latest dart SDK into the dartOutputDirectory [${project.build.directory}/dependency/dart] for the used OS and architecture. By default it will look for dart files in src/main/dart and will place the javascript files under ${project.build.directory}/dart.

More configuration details:

Please use mvn dart:help for more information.

#Example

An example can be found in the dart-maven-plugin-example folder inside the git repository.

#Maven repository

The Dart Maven Plugin is deployed to the central repository.

Authors and Contributors

Daniel Zwicker founded the project on GitHub.

Committer

dart-maven-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dart-maven-plugin's Issues

strange behaviour while running tests

When set the goal to test (mvn dart:test)
All my tests do pass:

unittest-suite-wait-for-done
PASS: bla bla
PASS: bla bla bla
All 2 tests passed.
unittest-suite-success

But then it fails with this strange message:

[ERROR] Failed to execute goal com.github.dzwicker.dart:dart-maven-plugin:2.1.1:test (default-cli) on project bla-bla-bla
: There are test failures.

Maybe the following debug-message helps:

[DEBUG] test return code: 0

I think this comes from the following line in the code: TestMojo.java - line 127

} else if (returnValue != 255) {
    fail = true;
}

Dart test runner

Be great to run unittest.
We can imagine defining one (or many) a test suite to run in configuration. It just call the main() methode of the test libs

Another Path Separator Problem - dartOutputFileRelativeToBasedir

In Dart2JSMojo.createOutputFileArgument(), if a custom compileSourceRoot has been provided, it is possible for dartOutputFileRelativeToBasedir to evaluate to null as a result of startsWith not matching anything due to an assumption about path separators.

  • I find these path issues because I develop on Win7 but we also have an integration build on Linux. So whenever I configure something with a path I use forward slashes. For compileSourceRoot that causes the build to fail on Windows.
  • Using the maven property ${file.separator} in the pom for the compileSourceRoot provides a workaround.
  • Since a source file should always be on one of the source roots, if dartOutputFileRelativeToBasedir evaluates to null for some reason I think the plugin should abort the compilation and throw an error, rather than continue on and produce javascript files whose name ends with null and are in the wrong place.

Pub, Symbolic Links and Missing Package Folders

Here's the problem in a nutshell:

  • pub creates the packages folder, as expected, at the compilation source root (where the yaml file is)
  • pub does not create a symbolic link to the packages folder in the lib folder
  • compilation of the library fails because dart2js looks for a packages folder in the lib folder and doesn't find it (unless a symbolic link is available, perhaps having been saved with the project as in the examples) and so it can't resolve external dependencies (to the js library in my case).

I think the plugin would be improved if it:
(1) refused to accept no for an answer... if it can't find the packages directory where it thought it would be, walk up the project tree until it finds the actual packages folder and use that. I suppose this packages folder might be different for different compilationSourceRoots so the code may need to be refactored to build one source root at a time.
(2) accepted and honored a configuration argument for -p (or --package-root=) as documented by dart2js -h -v. This would allow plugin users a way at least to try and troubleshoot missing dependency problems.

Auxiliary Info:

  • attempts to add a symbolic link using the maven-junction-plugin wound up creating an infinite loop of links and had to be aborted
  • current workaround is to use the maven-resource-plugin to copy over the packages folder to the lib folder (between execution of pub and dart2js)... obviously this is not ideal, but it's a way to get dart2js to find the packages it needs.
  • it might be nice too if the plugin could accept generic arguments to append to the dart2js and the other commands... dart2js has some additional options (at least for now) that some might find useful.

dart2js goal attempts to upload on install

In both the Examples and my own test project, the dart:dart2js goal downloads the sdk, then attempts to upload to the releases repository.

The examples project fails since I do not have permission to deploy to the in2ex-releases repository.

Maven should not deploy to the distribution management when installing. The deploy lifecycle phase should be used for that purpose.

Since the dart-sdk has already been installed in a repository, uploading should not be necessary.

Pub dependencies

The idea is import the dart dependencies define in pubspec.yaml.

Building dart-maven-plugin-example fails

[INFO] dart2js for 'src/main/dart/rom/web/map/mapPage.dart'
Using snapshot /Applications/dart/dart-sdk/lib/_internal/compiler/implementation/dart2js.dart.snapshot
src/main/dart/rom/web/map/mapPage.dart:6:8: Error: Cannot read "src/main/dart/rom/web/map/packages/rom/components.dart" (OS Error: No such file or directory, errno = 2).
import 'package:rom/components.dart';

-<1:%>- mvn -debug
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: /usr/share/maven
Java version: 1.7.0_15, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_15.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.2", arch: "x86_64", family: "mac"

DartMojo.getDartExecutable fails on Windows

There is no dart.bat in the sdk. It's dart.exe. This problem shows up when using DartWebMojo.

This:
//return new File(getDartSdk(), "bin/dart" + (OsUtil.isWindows() ? ".bat" : ""));

should be:
return new File(getDartSdk(), "bin/dart" + (OsUtil.isWindows() ? ".exe" : ""));

Path Separator Problem

AbstractDartMojo assumes forward slashes in the path, which causes problems on Windows. I fixed it locally like so:

protected List<String> getCompileSourceRoots() {
    if (compileSourceRoots.isEmpty()) {
        // Create interim file to ensure path separators are right kind for system
        return Collections.singletonList(new File(getBasedir(),"/src/main/dart").getAbsolutePath());
        //return Collections.singletonList(getBasedir() + "/src/main/dart");
    }
    return compileSourceRoots;
}

Ability to skip module if src/main/dart doesn't exist

If you place dart-maven-plugin configuration on a pom project so its dart-maven-plugin configuration are inherited by it's sub-modules dart-maven-plugin fails when you try to build the pom project with the following message:

Compiler-source-root "src/main/dart" does not exist.

In general, dart-maven-plugin should provide the option to implicitly skip modules that don't have "src/main/dart" folder. Simply print out a message that there is nothing to compile.

uploading dartSDK miss first time

If a new version of dart SDK is downloaded it will be uploaded to the repository. But the mojo fails. If you run again everything is fine.

How to run "pub build"?

Hi I'm resolving all dependencies with command - "mvn dart:pub". Default command is get. It works fine.
But I need build not get. So I'm writing "mvn dart:pub -DpubCommand=build"
But it still resolving dependencies. There is output:
"Run pub for package root: f:\Maven\dart-maven-plugin-example\src\main\dart\range Resolving dependencies... Got dependencies!"
How can I build my project?

Support for pub deploy (Polymer)

For those of us preparing to migrate our projects from Web_UI to Polymer, it looks like we'll need the dart-maven-plugin to run pub deploy as the pre-compilation step (rather than dwc).

The Dart folks are still in the process of making pub deploy work with Polymer, but my guess is that it'll land in the next couple of weeks.

Any chance we could get pub deploy added to the Pub Mojo?

unable to run dart2js

I have a single file under src/main/dart and i am trying to run dart2js goal. It keeps telling me that there is nothing to compile. I have located the problem in Dart2JsMojo (as it appears to me) in the fact that the following line is returning no entries:

Set includedSources = scanner.getIncludedSources(packageRoot, packageOutputDirectory);

so includedSources is empty.

replace revision with version

The download of dart is organized by revisions of the SDK not by its version. So the plugin uses the revision as version. This is not correct.

Try fixing this behavior.

DartWebMojo package path missing trailing separator

Not sure if this is a plugin issue or a web_ui/dwc issue, but in the current releases the plugin's DartWebMojo constructs a package root argument that does not have a trailing file separator (/ or )... and web_ui's dwc precompiler seems to need it. If it's missing then packages can't be found and the build fails (on both Win7 and Linux).

To fix, in execute():
// cl.createArg().setValue(ARGUMENT_PACKAGE_PATH + getPackagePath().getAbsolutePath());
cl.createArg().setValue(ARGUMENT_PACKAGE_PATH + getPackagePath().getAbsolutePath() + System.getProperty("file.separator"));

Here's a snippet of the output and you can see the missing slash causing problems ("packageslogging"):

[INFO] Version: 0.4.2.5_r20193
[INFO] Execute dart: /bin/sh -c /opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/../dependencies/dart-sdk/bin/dart --package-root=/opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/src/main/portfolio-manager/packages /opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/src/main/portfolio-manager/packages/web_ui/dwc.dart --out /opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/src/main/portfolio-manager/web/out /opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/src/main/portfolio-manager/web/PortfolioManager.html

Unable to open file: /opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/src/main/portfolio-manager/packageslogging/logging.dart'file:///opt/jenkins/workspace/mSEE-Dev/ozone/dart/portfolio-manager/src/main/portfolio-manager/packages/web_ui/dwc.dart': Error: line 10 pos 1: library handler failed
import 'package:logging/logging.dart' show Level;

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.