Webstorm 11 EAP #WS-142.4148 and dart .packages - dart

In the previous WebStorm 11 EAP build, performing a pub upgrade or pub get generated the dart .packages file instead of the packages directory used prior to Dart 1.12.
However in the current WebStorm EAP both the .packages file and the packages directory are generated. I would like to use only the .packages file.
Is there a setting in WebStorm that I can use to force the .packages and remove the packages symlinks?

This was changed so the packages directory is created again because several tools don't work (yet) without the packages directory (for example pub run test).
There is no way to configure this in WebStorm currently. What you can do is to run pub get/pub upgrade from the command line with the --no-package-symlinks option.
See also:
https://youtrack.jetbrains.com/issueMobile/WEB-18006
https://github.com/dart-lang/test/issues/327

Related

How to Generate Gradlew on to Jenkins?

How to generate gradlew file to Jenkins Android Project? My project is not Android Native. My project is Flutter.
I try to create CD with Jenkins and I got some errors.
this is my pipeline code (JenkinsFile)
stage('Build Release APK') {
sh "ls ./android"
sh "./android/gradlew clean assembleRelease"
}
ls output is,(There is not gradlew file)
ls ./android
app
build.gradle
gradle
gradle.properties
key.properties
settings.gradle
This is an error I got
./android/gradlew clean assembleRelease
/Users/donperera/.jenkins/workspace/demo#tmp/durable-b0592b49/script.sh: line 1: ./android/gradlew: No such file or directory
Is there any way to build apk/aap with Jenkins?
Is it possible to use this plugin? but I already added this one. But not in this my script. https://guides.gradle.org/executing-gradle-builds-on-jenkins/
gradlew or gradlew.bat is an executable of Gradle that can be used to execute gradle commands.
gradlew or gradlew.bat uses gradle/wrapper/gradle-wrapper.jar file for execution.
So there are 3 files in play:
gradlew for mac and linux
gradlew.bat for windows
gradle/wrapper/gradle-wrapper.jar
The thing here is, these files already exists when you create your flutter project. But these files are ignored by .gitignore of the project by default. so these files won't be available in your CI/CD server.
METHOD 1 [RECOMMENDED]
You don't need them to build your project when it is a flutter project. You need flutter SDK to be installed. You can use flutter SDK to build your project. Use following command for release build [you might need to set flutter SDK for your Jenkins server]:
flutter build apk --release
It will run assembleRelease internally and will generate your APK file.
METHOD 2 [NOT RECOMMENDED]
If you want to do it your way then you can add those 3 files to version control by removing their references from .gitignore file and push it to your repository. Then you'll have those file in your Jenkins workspace. You'll have to grant execution permissions to gradlew if you are on mac or linux which can be done by following command.
chmod +x ./gradlew
then you can use following command to build your app:
./gradlew clean assembleRelease
NOTICE: Method 2 is not recommended because when you run flutter commands, it sets some properties to gradle from pubspec.yaml file like version name, version code. So if you made changes to pubspec.yaml file and haven't run flutter command after that, then running gradlew directly won't include those changes. In this case, your apk might built with older version or might not even built as it reads version info from local.properties file which is auto-modified by flutter commands and it is excluded by default from version control. So, you'll also have to add local.properties file by removing its reference from .gitignore file which is very very dirty because it has location reference of android SDK and your server might not have android SDK on that location. Again you need to tackle that. so don't use this method.
You should not do that "on Jenkins". You should do that in your codebase. Execute the wrapper command (gradle wrapper), add wrapper files to Git, commit and push.

Dart pub get generates link to packages in each folder and subfolders

I try to avoid Dart to generate symbolic links (to packages) in each folder/sub-folder. For example, in pubspec.yaml I add polymer package and run pub get. After that I got:
Now each folder has packages symbolic link! As I understand it's because to ensure that we can use package:.. statement in any Dart file in any subdirectory.
I've already read the following topic (Why is dart pub suddenly trying to install packages in my css folder?), but it was created 2 years ago. Maybe something new here? How can I specify folders to exclude generating links by pub?
These symlinks are necessary for many tools. You can use the experimental command line option --no-package-symlinks for pub get/pub upgrade to disable symlink creation. I tried this a while ago but the DartEditor debugger stopped working (see http://dartbug.com/21749).
There are plans to get rid of symlinks entirely. A proposal exists and I assume it will be implemented within a few months (no promises).
Update
No packages directory and no symlinks might become default with Dart 1.13.

Dart Package Management via dart2js

I'm learning Dart and its dependency manager pub and am having a tough time seeing the "forest through the trees" here.
Say I want to use Polymer.dart in my project. So, in my project root, I create the following pubspec.yaml:
name: test_dart
description: A sample web application
dependencies:
browser: any
polymer: ">=0.9.0 <0.10.0"
I then run pub get, which goes to the pub repo and fetches the browser and polymer dependencies that I've specified. It then creates a packages directory in my project root, which now means I have a project that looks like:
MyDartProject/
pubspec.yaml
myapp.dart
packages/
browser/
...
...all the packages that ship with Polymer
Now I start coding my Dart web app (myapp.dart), which will references various Polymer and browser types/functions/etc. in its source code.
When I'm all done, I want to create a JavaScript file called myapp.js.
According to the dart2js docs, I need to run something like:
dart2js --out=myapp.js --package-root=??? myapp.dart
How do I include all the browser & polymer packages on the buildpath?
There is a "pub build" option now.
http://pub.dartlang.org/doc/pub-build.html
Use pub build when you’re ready to deploy your web app. When you run
pub build, it generates the assets for the current package and all of
its dependencies, putting them into a new directory named build.
$ cd ~/dart/helloworld
$ pub build
Building helloworld......
Built 5 files!
If the build directory already exists, pub build deletes it and then creates it again.
That should do everything you are after here. You can also launch it from the IDE by right clicking on the pubspec.yaml file and choose "pub build"
EDIT: You should also see the links in zoechi's answer.
If you run dart2js from your MyDartProject directory you don't have to provide --package-root parameter.
An alternative way is running pub build. If you use Polymer you need to add a transformers section.
see also
How to deploy a Dart Polymer app to Javascript using dart2js
How do I pass multiple entry_points to polymer transformer in pubspec.yaml?

Pub does not download dependencies on Windows 7 after the update to lib v2 (SDK 0.3.1_r17328)

After the update to the version 0.3.1_r17328 of Dart SDK and Dart Editor I have some trouble to import some library particulary Args library. I have the same problem both directly importing Args or importing Web_ui where Args is one of the dependencies.
Here is my pubspec.yaml:
name: notes
description: A sample application
dependencies:
web_ui: 0.3.0+1
or:
name: notes
description: A sample application
dependencies:
args: 0.3.1+1
Here is the error generate from build.dart
Unable to open file: C:/Users/Fabio/Dropbox/progetti/note/packages/args/args.dart'package:web_ui/component_build.dart': Error: line 25 pos 1: library handler failed
import 'package:args/args.dart';
'file:///C:/Users/Fabio/Dropbox/progetti/note/build.dart': Error: line 1 pos 1: library handler failed
import 'package:web_ui/component_build.dart';
I solved the problem. It seems that the Cache folder (Pub) has been corrupted.
I have deleted the folder Cache: C:\Users\<UserName>\AppData\Roaming\Pub
Then i run pub install from command line and it works.
Unfortunately, I was getting the same error with my windows XP machine.
In the end, I logged into my windows 7 machine and was able to
download the packages, zipped them up and pasted the libraries into my
windows XP dart editor. Success!
I had no reason to believe I had the exact proxy issue #shindokaku had as I am using my home computer.
I tried all the suggestions on deleting the .cache files, pub.lock files and the packages folder and retrying. I uninstalled dart editor and tried again. I also tried using the git resources to download web-ui and running commands through the command line to no avail
Including suggestions in this similar questions:
cannot-find-referenced-source-packages
is-there-a-workaround-for-pub-dependency-resolution-through-proxies
This problem has been haunting me over and over for a few weeks. I am not using Windows, so this answer is not intended to help the original poster who is using Windows 7.
If you are using Linux here are the steps I use to repair corrupted pub cache.
Go to the top level directory of your app. You should see at least pubspec.lock, pubspec.yaml, a folder named packages, and a folder named web.
Delete your pubspec.lock, and packages folder.
[Make sure you aren't storing your own libraries in the packages folder]
cd ~/dart/myApp/
rm -r packages
rm pubspec.lock
Now once you have removed these files:
pub cache repair
Note 1: if your dart-sdk is not in your systems $PATH, than you will want to use the absolute path to the sdk when using the above command. Comment if you need that explained.
Note 2: This is working solution with Dart 1.5.3. I have not tested this on earlier versions.
Try deleting your pubspec.lock file and packages directory in the root folder of the project. Then run pub install again, when things get wacky thats what I do.
You should try to run pub update. I have sometimes found that this doesn't work as expected from the editor, but generally works quite smoothly when called from the command line.

Pub install fail, Package "html5lib" doesn't have a pubspec.yaml file

I've created a simple project. This is my pubspec.yaml
name: testapp
description: test application
dependencies:
html5lib: 0.0.12
And now i get this error
Pub install fail, Resolving dependencies...
Package "html5lib" doesn't have a pubspec.yaml file.
I'm guessing you are on windows? Dart seems to setup shortcuts (hard dir links?) between the packages folder in a project and where the packages are stored. So if you delete your packages dir from within Eclipse, it will trash the folder that stores the actual package.
On Windows 7, the folder is:
C:\Users\[user]\AppData\Roaming\Pub\
Go ahead and delete its contents and run pub install again.
If you start getting errors about UnitTest or other core libraries, you may need to re-download the Dark-SDK (or dart editor) and replace it.

Resources