Integrating gulp in building .war file - deployment

I am interested in minifying and concatenating the css and js files of my application.
I am able to automate this with gulp, as outlined in this tutorial:
https://travismaynard.com/writing/getting-started-with-gulp
I am using netbeans to generate the .war file of my project for deployment (right click project --> clean and build).
At the moment, gulp simply generates the files to a folder in the build directory. And obviously, the .war file that I generate doesn't include these files.
I was wondering how I can have the generated .war file include the files that I generate with gulp (which can be found at say: /my_project/build/web/js or /my_project/build/web/css).
Currently, gulp "watches" for a change in the js or css files, but I would be fine with just calling the gulp tasks once (when the .war is generated).
Would I need to make changes to my build.xml file?
Do I need a different way of minimizing these files (eg: minimize and concat once deployed)?
Thanks.

Check this gulp package: https://www.npmjs.com/package/gulp-war
You can create a gulp task where you can define the files to be included/excluded files.
Sample
var war = require('gulp-war'),
zip = require('gulp-zip'),
.....
gulp.task('war', function () {
gulp.src('./tmp/**')
.pipe(war({
welcome: 'index.html',
displayName: "YOUR APP NAME",
}))
.pipe(zip('webapp.war'))
.pipe(gulp.dest('./target/'));
});

please try this :
https://github.com/eirslett/frontend-maven-plugin
Basically maven will call gulp to prepare some files, then generate a war for all of them

Related

How to add library path in bnd file in liferay7?

I have created a module project using mvc-portlet.For my project, I need to import a few jar files.
For this purpose, I have created a lib file in the project module and have added its path to the build.gradle .Now while building the project is working, but at the time of deployment it is not starting(i.e.: the portlet stays in installed phase).
I understand it is because I have not added the lib folder path in my and files. But I am not sure as to how should I proceed regarding it.
I am using eclipse ide and Liferay 7 along with tomcat for development
First of all, if you want to know why your module is not working, I suggest you tu use the diag command on the Gogo Shell.
Now, to manage the problem with the libraries, you have to include the jar files (extracted) inside your module, this is create a fat jar. Basically add a task to your build gradle like this:
task customFatJar(type: Jar) {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
It could be great if you create a fat jar with only the libraries, and export it's packages on the bnd, and then you consume them from a different module.

Where are the eclipse product build scripts stored?

i'm exporting an eclipse product with the eclipse Product export wizard. when i run this wizard a lot of build scripts are generated and executed - i want to re-use these build scripts for my p2e-build. where does eclipse store these build scripts?
The files for the build are created in the root folder of the project containing the xxx.product file you are using. They only exist while the build is running. The main file is a build.xml Ant script.

Copy file from sbt plugin to project folder

I'm writing an sbt plugin to help with deployment. It depends on sbt-native-packager. Principally it adds a deploy task. However, I also need it to copy a bash script run-class.sh into the /bin folder of the package.
How do I copy a file from the sbt plugin to my project? Presently my only idea is to add the file to src/main/resources/run-class.sh in the plugin and generate a file using sbt. Then I can supply a Universal mapping to put the file in the sbt-native-packager package.
Is there an easier way to get a file from the plugin into my sbt project?
You are on the right track with Generating files, specifically Generate resources. You can keep your original file either as a resource or String, but important thing is that the files are generated into resourceManaged in Compile, which is under target. This folder is typically skipped from version control.

JavaFX FXML 2.2 - Deploy Application with bitmaps

I have searched a lot and tried several ways to do this, but am stumped. I am writing a desktop app (though I suppose it could also run in a browser) that allows an Android programmer to edit all of their dimens.xml files at once. I have created my own images to use in ImageViews as buttons. I am using different methods to access these images:
Some are referenced in the FXML file, like <Image url="#Icons/ic_launcher.png" />. The path is "src/Icons/". The path of the FXML file is "src/application/xxx,fxml".
Some are referenced in the css file, like "-fx-image:url("QuestionMark.png");". The css file and png file are in the same directory "src/MessageBox/"
Some are changed dynamically at runtime:
ImageView mButtonIcon = new ImageView("/insert_item_above.png");
The path of the image: src/
The path of the class: src/ContextMenuButton/
The above only works in Netbeans 7.4. None work when I run the app in Eclipse.
If I go to the dist/ directory and run it from any of the 3 methods, I see my images.
If I move the dist/ folder somewhere else, the only way I can get it to work is if I copy the src/ folder to the same directory and delete everything but the png and css files. So, I end up with:
+ F:/AndroidDimens
+ dist
xxx.jar
+ src
insert_item_above.png
+ Icons
ic_launcher.png
+ MessageBox
QuestionMark.png
So, the jar file has modified all of the paths to be relative to the src/ folder. My goal is to make the paths relative to where the jar file is. I tried to place the images where I would not need project related paths. But it must have made the paths something like "../src/MessageBox/QuestionMark.png" in the jar (relative to the project's dist/ folder).
Is there any way to fix this? Ideally, I would like all images to be in one directory. Then I could zip that directory, and someone else could just unzip it and run the app.
Thanks!
EDIT
Thanks to #jewelsea (in chat), I found that the problem was due to having an older version of JDK 7u13 installed with the latest one needed for JavaFX 2.2. Deleting the old version, and updating global variables that referenced it, solved the problem. No changes were needed to the default project settings.
Packaging Advice
Package all of your application's runtime class files and resources (fxml, css, png, etc) in the application jar file using the JavaFX packaging tools.
Using the JavaFX packaging tools is what NetBeans 7.4 does automatically during it's build process for JavaFX application projects.
Eclipse and other build environments will not use the JavaFX packaging tools automatically. I believe, if you use Eclipse with the recommended e(fx)clipse extension toolset for JavaFX development, then that toolset will, through its UI, provide you with the ability to use the JavaFX packaging tools to package your application.
There are 3rd party packaging alternatives for JavaFX such as the JavaFX Maven Plugin or the JavaFX Gradle Plugin which will also package your application correctly.
Whatever packaging tool you choose, test the packaging process by unzipping the files from your resultant jar and checking that all of the resource files (fxml, css, png, properties etc) are where you expect them to be in the jar's internal directory structure. This unzipping process is just a developer sanity check, you don't need to ask your end users do perform such an extraction.
Your end users can run your application as either an installed native application (JavaFX term self-contained application) or as a click to execute jar file (JavaFX term standalone program) and all of your application's resources will automatically be available from the packaged application, with no additional work required by the user.
Resource Access Advice
I advise not referring to a src path in your code (as you won't have a src path inside your distribution jar), css or fxml files, but instead refer to those paths relative to the root of the distribution jar or your JavaFX application class. For example, to load a scene style sheet in a JavaFX Application subclass, use a form as recommended by the JavaFX deployment guide - 3.3.4 Loading Resources:
scene.getStylesheets().
add(this.getClass().getResource("my.css").toExternalForm());

Generate Jar in netbeans 7.1

I am using netbeans 7.1 (new to it). I would like to know how to export our projects as a .jar file (though I have searched a lot in Internet).
Many times ./dist folder itself is not created, even though it is created, I see only .zip files (not jar). It would be great if one can help me out in this aspect. Seems like in earlier version of netbeans, the jar would be available in ./dist folder.
Do this before search :) (right click the project > Clean and Build)
When you use the Clean and Build command, the IDE runs a build script that performs the following tasks:
Deletes any previously compiled files and other build outputs.
Recompiles the application and builds a JAR file containing the compiled files.
There is no difference in Netbeans 7.1, the jar will be in the dist folder :)