Let say that I have execute an ionic run android or ionic build android command. And i have an after prepare hook script. I would like to know whether i am building an android or other platform in the after prepare script so that i can perform the correct action in the script. How could it be done?
Something i would expect:
if (ionic.build.platform === 'android')
You could achieve this using separate settings in config.xml for your hook scripts, then either have one hook script per platform, or maybe use parameters passed to your hook script to identify the platform.
For example, you might want to do something like:
<platform name="android">
<hook type="after_prepare" src="scripts/android/after_prepare.sh" />
</platform>
<platform name="ios">
<hook type="after_prepare" src="scripts/ios/after_prepare.sh" />
</platform>
Source: Cordova documentation.
Related
Is there a way to get the VS 2015 Play Button to execute an NPM script in node tools for VS?
Ideally I would like to have developers click the "run" button, and it executes npm run watch or something similar.
You can use Pre and Post Build Actions
You may find it necessary to run a script or process immediately before or after build. This is achieved with minimal effort when using Node.js Tools for Visual Studio. A small bit of xml code needs to be added to the Node.js project file (.njsproj) and your custom action will be called on build. Place this code just before in the project file.
<PropertyGroup>
<PreBuildEvent>
PRE BUILD ACTION
</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PostBuildEvent>
POST BUILD ACTION
</PostBuildEvent>
</PropertyGroup>
These actions are run as if they were run manually through cmd.exe. You could use this to do just about any custom action before or after build.
docs here
I'm wondering if there is any convenient way to add plugins to hybrid app without using npm. For example I've created a phonegap app using their program so I did't have to use npm commands. But now I want to add this plugin to my app "cordova-plugin-crosswalk-webview" and I can't because constantly pop up different errors. I've searched for the solutions in internet but the reasons are different (always something in my windows is missing). So I've decided to reinstall windows and install everything afresh. But I thought that is a good question anyway. So is there any other way to do it? And If some one would be so kind and do for me a sample corova app with already added crosswalk plugin I would be happy because I will reinstall my windows next week.
I don't think that there is any other convenient way. And respecting your problem just add this code:
<preference name="android-build-tool" value="gradle" />
<gap:plugin name="phonegap-plugin-push" source="npm" version="1.3.0" />
<gap:plugin name="cordova-plugin-crosswalk-webview-pgb-adapt" source="npm" version="1.4.0-dev-11"/>
to your config.xml
I want to reference a 3th party library:
import com.googlecode.mp4parser.authoring.Movie;
but in android studio, gradle puted the library in C:\Users\flieks\.gradle\...
Now how do i "export" the plugin project?
i want to have mp4parser somewhere in folders src\android\main.java
Greetings
Felix
You can reference a Gradle file in your plugin to allow you to pull in other libraries (if I'm understanding your question correctly). Check out plugin.xml in the crosswalk-webview plugin for an example on how to add one in:
https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview/blob/master/plugin.xml
Once you do that you can import the class in your plugin code.
adding this to the plugin.xml did the trick
<platform name="android">
<config-file parent="/*" target="res/xml/config.xml">
<feature name="Mp4Parser">
<param name="android-package" value="com.catwalk.mp4parser.Mp4Parser" />
</feature>
</config-file>
<config-file parent="/*" target="AndroidManifest.xml" />
<source-file src="src/android/Mp4Parser.java" target-dir="src/com/catwalk/mp4parser/Mp4Parser" />
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
</platform>
and this in same folder as the JAVA file
dependencies {
compile group: 'com.googlecode.mp4parser', name: 'isoparser', version: '1.1.7'
}
I have the following error in Jenkins ( refers to a path on the disk, each instance of below can be different and not neccasarily the same as all other instances of )
The command "tsc "C:\<path>\shared.editpage-default.ts" "C:\<path>\shared.editpage-editenabled.ts" "C:\<path>\shared.filters.ts" "C:\<path>\perfect.common.interfaces.d.ts" "C:\<path>\perfect.hide-and-seek.ts" "C:\<path>\perfect.domutils.ts" "C:\<path>\jquery.validation.d.ts" "C:\<path>\perfect.pagination.ts" "C:\<path>\perfect.sorting.ts" "C:\<path>\jquery.d.ts" "C:\<path>\perfect.langchange.ts" "C:\<path>\perfect.switchbox.ts" "C:\<path>\perfect.validation.ts"" exited with code 9009.
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\<path>\<proj>.csproj]
Now, the issue is this. We have a section in our project file that builds our TypeScript files and creates .js files each time we save the TypeScript file. This is the section:
<Target Name="BeforeBuild">
<Message Text="Compiling TypeScript files" />
<Message Text="Executing tsc$(TypeScriptSourceMap) #(TypeScriptCompile ->'"%(fullpath)"', ' ')" />
<Exec Command="tsc$(TypeScriptSourceMap) #(TypeScriptCompile ->'"%(fullpath)"', ' ')" IgnoreExitCode="true" />
</Target>
This all works great locally, but fails in Jenkins because the Jenkins server does not have TypeScript installed. The thing is that I don't actually need the TypeScript command to be executed on Jenkins because the generated .js files are, as I said, built and created on save anyway, and we check these in. So there are three options.
Install TypeSctipt on the build server.
Change the command in the project file so that it only carries out the <Exec Command="tsc ... if we are in the configuration is Debug.
Change my build scripts to somehow not build the TypeScript files.
Here's what I've tried.
I thought I'd try install TypeScript on the build server, but the server is an old Windows Server 2003 machine and when I tried to install TypeScript 0.8.3 on it I got the below error. So, I installed the latest windows updates on the machine and restarted and re-ran the TypeScript installation and got the same error.
As for options 2 and 3.
I think 2 would be the easiest one, though I just don't know the if statement that I must use to only build for the Debug configuration. If this is the solution please do let me know the command.
Option 3 I think is probably quite difficult.
Please do make some suggestions.
Option 2 should be easily doable. The Exec task (http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx) supports the Condition parameter (http://msdn.microsoft.com/en-us/library/7szfhaft.aspx). I think what you want looks something like this:
<Exec Command="..." Condition="'$(Configuration)' == 'Debug'" />
I'm not sure if this is possible, but currently I am using a CruiseControl.net build server with a nAnt script to handle all of the building, testing, and packaging. I have nAnt manipulate some files and archive them. Is there a way to display that zip file that the nAnt script generated in the CruiseControl.net Package List? I am using ccnet 1.5 and nAnt 0.91 alpha2.
Thanks.
After much research, I have come to this conclusion:
Packages only show the files related to that build not all.
You can only build these packages within the CCNet.config
If you make a package by hand, it will be corrupted within the build server
It might be possible to create the package and drop the required files in the folder, but you will have to modify a couple of the statistic files and what not, but i gave up and no one has responded to this.
I did this because I was not happy with ccnet's package publisher. First you need to trick ccnet into creating a dummy package; the package will be created in [ArtifactDirectory]\[CCNetLabel]. Then run a nant script which replaces the package and updates the package xml.
ccnet config:
<publishers>
<package>
<name>Build-$[$CCNetLabel]</name>
<compression>0</compression>
<packageList />
</package>
<nant>
<buildArgs>-D:PackageName="Build-$[$CCNetLabel]"</buildArgs>
<buildFile>script.build</buildFile>
<targetList>
<target>PackagePublisher</target>
</targetList>
</nant>
</publishers>
nant:
<target name="PackagePublisher">
<property name="PackageDirectory" value="${CCNetArtifactDirectory}\${CCNetLabel}" />
<property name="PackageFullPath" value="${PackageDirectory}\${PackageName}.zip" />
<delete file="${PackageFullPath}" />
<zip zipfile="${PackageFullPath}">
<fileset>
<!-- include everything you need to package -->
</fileset>
</zip>
<!-- find package.xml; it is the only xml file in the PackageDirectory -->
<foreach item="File" property="PackageXml">
<in>
<items basedir="${PackageDirectory}">
<include>*.xml</include>
</items>
</in>
<do>
<xmlpoke file="${PackageXml}" xpath="//package[#name='${PackageName}']/#size" value="${file::get-length(PackageFullPath)}" />
</do>
</foreach>
</target>
The last part ensures the package size is displayed properly in the PackageList web page.