how to use the module mode in plovr - google-closure-compiler

The plovr works well for single file like this:
{
id:"main",
paths:".",
pretty-print:true,
inputs:["eval.js","util.js","ui.js"],
output-wrapper:"\n(function(){%output%}).call(this);\n",
}
As shown in the config,the inputs will be compiled together,and this is the core module in my application.
Then I have some sub modules in the /modules directory.
Now I want compile them together,but I do not know how to config them:
I tried this:
{
id:"main",
paths:".",
pretty-print:true,
modules:{
core:{
inputs:["eval.js","util.js","ui.js"],
deps:[]
},
panel:{
inputs:["modules/panel.js"],
deps:"core"
}
window:{
inputs:["modules/window.js"],
deps:"core"
}
}
}
Then it does not work.
How about the output-wrapper for the core module?
And where does the sub modules compile to?
BTW,this is my application directory:
src
eval.js
util.js
ui.js
modules
panel.js
window.js
plovr.jar
plovr-config.js

Related

How to get outputs of one Rule item as inputs of another one?

I want to create automatic crossplatform installation builder for my project. For this reason I made this file myprojectpackage.qbs:
Product {
type: "mypackage"
Depends { name: "myproject" } // <- this one has type "application"
Depends { name: "applicationpackage" }
}
applicationpackage.qbs uses some submodules and looks like:
Module {
name: "applicationpackage"
Depends { name: "qtlibsbinariespackage" }
Depends { name: "3rdpartybinariespackage" }
Depends { name: "resourcepackage" }
}
All these modules try to find something and copy to package directory. After they finish, I have a folder with a portable version of application. Every module of this group have typical structure:
Module {
name: "somepackage"
Rule {
condition: qbs.targetOS.contains("windows")
multiplex: true
alwaysRun: true
inputsFromDependencies: ["application"]
Artifact {
filePath: "Copied_files.txt"
fileTags: "mypackage"
}
prepare: {
var cmdQt = new JavaScriptCommand()
// prepare paths
cmdQt.sourceCode = function() {
// copy some files and write to Copied_files.txt
}
return [cmdQt]
}
}
}
After portable folder package complete, I want to make a zip archieve. So, I need another Module, which will run after package modules. I think, that only way to do like this is taking .txt files, that were created by modules in applicationpackage, as inputs for another Rule.
I have tried a lot of things (FileTaggers, outputFileTags etc.), but noone worked properly. So is there any way to do make modules work in pipeline as I want to do?
Do I understand correctly that you want to "merge" the contents of the txt files tagged "mypackage" into the archive, i.e. everything listed in all the files is supposed to end up there?
If so, then you simply need a "top-level" rule that does the aggregation. Your existing rules would tag their outputs as e.g. "mypackage.part" and then a multiplex rule would take these as inputs and create a "mypackage" artifact.
Note that there is the archiver module (https://doc.qt.io/qbs/archiver-module.html) that can do the final step of creating the package for you from the aggregated txt file.

JavaFX packager - can the name of the package icon be specified?

For a couple of years, I have been releasing updates to a modest app on a yearly basis -- just before the summer swim league starts up.
In the past, I have specified the various icons (volume, app, etc.) by placing them in the package/macosx/ folder. The filenames, MyApp-volume.icns etc., matched the <fx:application name="MyApp" .../> and everything worked just fine.
But starting with this year's build and deployment, the app's name will contain the year -- i.e., MyApp 2016. However, I don't want to be changing the icon filenames each year; I would like to keep them as they are (MyApp-volume.icns, MyApp.icns).
Is there a way to tell the Java packager to use a specific icon filename, one that is different from that of the app name or title? (I have looked at Oracle docs, but I don't see anything.)
-Bicon=<path to icon relative to project resourses>
is this what you looking for?
or you could just add it to your main app Stage.
hope it is usefull
As I wrote in my first comment to my question, javapackager doesn't have an option to do this.
Here's the solution that I worked out:
Create a new folder at the same level as the folder package (this doesn't refer to Java package but to Custom Resources). Name the new folder package-base.
Move the macosx and windows folders from package to package-base. (I don't produce an executable for Linux because none of my users use Linux.) Now, the package folder is empty.
In my build script, I added a step which, for every build that produces a "self-contained application package" (Oracle's terminology), cleans the package folder, and then copies the contents of package-base to package.
The files are renamed as they are copied to include the desired wording -- in my case, that means the year is appended to the filename. For example, MyApp-volume.icns when copied is renamed MyApp-2018-volume.icns.
Here are the relevant Gradle snippets:
import org.gradle.internal.os.OperatingSystem
...
def getYear() {
new Date().format('yyyy')
}
...
ext {
...
year = getYear()
appNameBase = "MyApp"
appName = appNameBase + " " + year
...
}
...
task macCleanPackage {
doLast {
if (OperatingSystem.current().isMacOsX()) {
delete fileTree(dir: "./package/macosx", include: "*.*")
}
}
}
task macCopyAndRenamePackageResources {
dependsOn macCleanPackage
doLast {
if (OperatingSystem.current().isMacOsX()) {
def toDir = "./package/macosx"
copy {
from './package-base/macosx'
into "${toDir}"
include "*${appNameBase}*.*"
rename { String fileName -> fileName.replace("$appNameBase", "${appName}") }
}
ant.replaceregexp(file: "${toDir}/${appName}-dmg-setup.scpt", match:"${appNameBase}", replace:"${appName}", flags:'g')
}
}
}
task windowsCleanPackage {
doLast {
if (OperatingSystem.current().isWindows()) {
delete fileTree(dir: "package/windows", includes: ["*.bmp", "*.ico", "*.iss"])
}
}
}
task windowsCopyAndRenamePackageResources {
dependsOn windowsCleanPackage
doLast {
if (OperatingSystem.current().isWindows()) {
def toDir = "./package/windows"
copy {
from './package-base/windows'
into "${toDir}"
include "*${appNameBase}*.*"
rename { String fileName -> fileName.replace("$appNameBase", "${appName}") }
}
// Replace app name in iss setup script to include year.
def issFilename = "./package/windows/${appName}.iss"
ant.replaceregexp(file: "${issFilename}", match: "${appNameBase}", replace: "${appName}", flags: "g")
ant.replaceregexp(file: "${issFilename}", match: "AppCopyright=Copyright (C)", replace: "AppCopyright=Copyright (C) ${year}", byline: "on")
ant.replaceregexp(file: "${issFilename}", match: "AppVersion=", replace: "AppVersion=${year} build ${buildNumber}", byline: "on")
ant.replaceregexp(file: "${issFilename}", match: "OutputBaseFilename=.*", replace: "OutputBaseFilename=${appName}-(build ${buildNumber})", byline: "on")
}
}
}
I don't just change filenames.
For the OS X release, ant.replaceregexp is used to modify the app's name in the custom AppleScript file.
For the Windows release, ant.replaceregexp is used extensively to replace version numbers, copyright, as well as the application's name (including the year) in the InnoSetup configuration file.
It may seem like a lot of extra work, but once the script is written, it just works.

How to pass _OPTIONS to included premake4 scripts?

I've got a main premake4.lua script:
solution "MySolution"
language "c++"
newoption = {
trigger = "my-option",
description = "This is an option"
}
include "../my_library"
I would like to pivot logic in the included script ( ../my_library/premake4.lua ) based on the contents of _OPTIONS:
if _OPTIONS["my-option"] then
project "myStaticLibrary"
kind "StaticLib"
else
project "mySharedLibrary"
kind "SharedLib"
end
files "foo.cpp"
How to get _OPTIONS in the scope of the included premake4 script?
You don't need to do anything. _OPTIONS is a global variable and will be accessible to all of your scripts automatically. Are you seeing otherwise?
I'm answering my own question just in case anyone else is tempted to solve things in the same way. I was Doing It Wrong. After struggling with it my final solution defined multiple configurations:
-- the main script
solution "MySolution"
language "c++"
configurations { "Release", "Debug", "ReleaseDLL", "DebugDLL" }
configuration { "Release", "ReleaseDLL" }
flags { "Optimize" }
configuration { "Debug", "DebugDLL" }
flags { }
defines {"_DEBUG=1"}
configuration {}
include "../my_library"
The included script specified the kind according to configuration:
-- the included script
project "myStaticLibrary"
configuration { "*" }
kind "StaticLib"
configuration { "*DLL" }
kind "SharedLib"
configuration {}
files "foo.cpp"
And to to build the right targets the config is specified at the make:
premake4 gmake
cd gmake
make config=release
make config=debug
make config=releasedll
make config=debugdll

Electron default app doesn't change

I am trying to convert my Google Closure Library used web app to Electron. I've used grunt-electron to package the application but it seems it doesn't change the default app of the Test.app. In Test.app/Contents/Contents/app/ there exist my application, but it doesn't load my app, but indeed loads default app.
My file hierarchy:
www: index.js (Electron config file), index.html, css/, fonts/, js/**
My grunt task:
electron: {
osxBuild: {
options: {
name: 'Test App',
dir: 'www',
out: 'build',
version: '0.25.3',
platform: 'darwin',
arch: 'x64'
}
}
}
Check if package.json file exists in your www directory and has main js set inside.
It should be something like:
{
"name" : "your-app",
"version" : "0.1.0",
"main" : "main.js"
}

How To Specify main class when using fatjar plugin in gradle.build

I am interested in building a single jar containing all the module dependencies and external jars in a single executable jar file which I will be able to run with java -jar myApp.jar.
I have module A which is dependent on module B.
Currently I'm using gradle, and my build.gradlescript looks like this:
apply plugin: 'fatjar'
description = "A_Project"
dependencies {
compile project(':B_Project')
compile "com.someExternalDependency::3.0"
}
When I build it through gradle command: clean build fatjar a fat jar 'A.jar' is created as expected.
But running it with as I written above results in:
no main manifest attribute, in A.jar
How can I modify my build.gradle file and specify the main class, or the manifest?
I have figured it out myself:
I've used uberjar Gradle task.
now my build.gradle file looks like this:
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'com.organization.project.package.mainClassName'
version = '1.0'
task uberjar(type: Jar) {
from files(sourceSets.main.output.classesDir)
from {configurations.compile.collect {zipTree(it)}} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest {
attributes 'Main-Class': 'com.organization.project.package.mainClassName'
}
}
dependencies {
compile project(':B_Project')
compile "com.someExternalDependency::3.0"
}
and now I i use it with the command:
clean build uberjar
and it builds one nice runnable jar :)
To get it working using fatjar, I added a manifest section in fatJar task:
task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
attributes 'Main-Class': 'com.organization.project.package.mainClassName'
}
}

Resources