Closure Compiler not generating minified file after upgrade - google-closure-compiler

This works perfectly with compiler version 2013.11.18:
java -jar C:/closure/compiler_v20131118.jar
--compilation_level ADVANCED_OPTIMISATIONS
--warning_level=VERBOSE
--jscomp_off=externsValidation
--summary_detail_level=3
--externs C:\path\externs.js
--create_source_map C:\path\min.map.js
--output_wrapper "%output%//# sourceMappingURL=urlToMap
--source_map_format V3
--js C:\path\file1.js
--js C:\path\file2.js
--js_output_file C:\path\min.js
--version 2>&1
But the minified file doesn't get created with compiler version 2016.05.17:
java -jar C:/closure/compiler_v20160517.jar
--compilation_level ADVANCED
--warning_level=VERBOSE
--jscomp_off=externsValidation
--summary_detail_level=3
--externs C:\path\externs.js
--create_source_map C:\path\min.map.js
--output_wrapper "%output%//# sourceMappingURL=urlToMap
--source_map_format V3
--js C:\path\file1.js
--js C:\path\file2.js
--js_output_file C:\path\min.js
--version 2>&1
I only get this output in the console:
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20160517
Built on: 2016/05/18 16:21
What am I doing wrong?

A lot has changed with the compiler from 2013 to 2016. This wiki page has some of the more important changes:
https://github.com/google/closure-compiler/wiki/Managing-Dependencies
As a data point here is an example compile command that is working for me:
java -jar ../javascript/closure-compiler/build/compiler.jar
--entry_point=goog:myphysicslab.sims.pendulum.DoublePendulumApp
--compilation_level=SIMPLE --define=goog.DEBUG=true --define=goog.LOCALE='de'
--define=myphysicslab.lab.util.UtilityCore.ADVANCED=false --generate_exports
--js=../closure-library/ --js=src --jscomp_error=accessControls
--jscomp_error=ambiguousFunctionDecl --jscomp_error=checkTypes
--jscomp_error=checkVars --jscomp_error=const --jscomp_error=constantProperty
--jscomp_error=fileoverviewTags --jscomp_error=globalThis
--jscomp_error=invalidCasts --jscomp_error=misplacedTypeAnnotation
--jscomp_error=missingProperties --jscomp_error=missingProvide
--jscomp_error=missingRequire --jscomp_error=missingReturn
--jscomp_error=newCheckTypes --jscomp_error=strictModuleDepCheck
--jscomp_error=suspiciousCode --jscomp_error=typeInvalidation
--jscomp_error=undefinedNames --jscomp_error=undefinedVars
--jscomp_error=unknownDefines --jscomp_error=uselessCode
--jscomp_error=visibility --language_in=ECMASCRIPT5_STRICT
--dependency_mode=STRICT --warning_level=VERBOSE
Most likely you need to add the --entry_point and --dependency_mode options.
Here is an example command using advanced-compile and output_wrapper:
java -jar ../javascript/closure-compiler/build/compiler.jar
--entry_point=goog:myphysicslab.sims.pendulum.DoublePendulumApp
--compilation_level=ADVANCED --define=goog.DEBUG=true
'--define=goog.LOCALE='\''en'\'''
--define=myphysicslab.lab.util.UtilityCore.ADVANCED=true --generate_exports
--js=../closure-library/ --js=src --jscomp_error=accessControls
--jscomp_error=ambiguousFunctionDecl --jscomp_error=checkTypes
--jscomp_error=checkVars --jscomp_error=const --jscomp_error=constantProperty
--jscomp_error=fileoverviewTags --jscomp_error=globalThis
--jscomp_error=invalidCasts --jscomp_error=misplacedTypeAnnotation
--jscomp_error=missingProperties --jscomp_error=missingProvide
--jscomp_error=missingRequire --jscomp_error=missingReturn
--jscomp_error=newCheckTypes --jscomp_error=strictModuleDepCheck
--jscomp_error=suspiciousCode --jscomp_error=typeInvalidation
--jscomp_error=undefinedNames --jscomp_error=undefinedVars
--jscomp_error=unknownDefines --jscomp_error=uselessCode
--jscomp_error=visibility --language_in=ECMASCRIPT5_STRICT
--dependency_mode=STRICT --warning_level=VERBOSE
'--output_wrapper='\''(function(){%output%}).call(window)'\'''
You might have some problem with the single quote in your output_wrapper?
To see compiler options:
java -jar ../closure-compiler/build/compiler.jar --help
That will give some good info on the options, for example:
--entry_point VAL : A file or namespace to use as the
starting point for determining which
src files to include in the compilatio
n. ES6 and CommonJS modules are
specified as file paths (without the
extension). Closure-library namespaces
are specified with a "goog:" prefix.
Example: --entry_point=goog:goog.Promi
se

Related

sbt 1.3.8 publishLocal creates a jar that sbt update can't resolve. scala version is appended to jar name

I published some libraries using sbt publishLocal it worked and published to my ~/.ivy2/local dir.
I then have a project that depends on these libraries but sbt update can't find them.
specifically, my project has these dependencies:
lazy val myDependencies = commonDependencies ++ Seq(
"my.corp" %% "lib1" % "1.0.1-SNAPSHOT" withSources () withJavadoc (),
"my.corp" %% "lib2" % "2.0.2-SNAPSHOT" withSources () withJavadoc ()
)
sbt update has this error:
[error] (services / update) lmcoursier.internal.shaded.coursier.error.FetchError$DownloadingArtifacts: Error fetching artifacts:
[error] file:////home/myuser/.ivy2//local/my.corp/lib1_2.12/1.0.1-SNAPSHOT/jars/lib1.jar: not found: /home/myuser/.ivy2//local/my.corp/lib1_2.12/1.0.1-SNAPSHOT/jars/lib1.jar
[error] file://///home/myuser/.ivy2//local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars/lib2.jar: not found: /home/myuser/.ivy2//local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars/lib2.jar
when I look in the dir I can see the published jars but their name has the scala version appended, which is why the update resolving fails, I think :
$ ls /home/myuser/.ivy2/local/my.corp/lib1_2.12/1.0.1-SNAPSHOT/jars
lib1_2.12.jar lib1_2.12.jar.md5 lib1_2.12.jar.sha1
$ ls /home/myuser/.ivy2/local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars
lib2_2.12.jar lib2_2.12.jar.md5 lib2_2.12.jar.sha1
If I publish to a repo for real I can resolve the libs.
Does anyone know the sbt incantation to fix this? ;-)
Cheers
Karl
Update:- I think coursier is the problem, not sure how to tell it to look for lib2_2_12.jar. Could it have a bad cached reference?
Caused by: lmcoursier.internal.shaded.coursier.cache.ArtifactError$NotFound: not found: /home/myuser/.ivy2/local/my.corp/lib2_2.12/2.0.2-SNAPSHOT/jars/lib2.jar
Update:-
disabling coursier worked
from the sbt REPL I can run
sbt:my-project> set ThisBuild / useCoursier := false
and then
sbt:my-project> update
and that worked, but setting it back to true update failed again, so this looks like a coursier issue.
Update:
coursier fetch from the command line worked!!
coursier fetch my.corp::lib1:1.0.1-SNAPSHOT --no-default -r central -r ivy2Local
downloaded the transitive dependencies and found my jar in my local ivy2 dir
so this is back to looking like an sbt - coursier interaction issue
I've just now run into this and after lots of diffs between an older working version and this non-working version I figured out that it is the withSources() that triggers the bug in sbt and/or coursier.

Symfony2 Composer install calls wrong php installation/version internally

I'm trying to set up Symfony 2.5 via Composer.
First I am calling:
php5.3.8-cli /kunden/81425/composer.phar create-project symfony/framework-standard-edition hhcadm/ "2.5.*"
This works until at some point it is internally not calling php5.3.8-cli anymore but somehow uses php. The problem is that php is version 4.4.9 and this causes following effect:
Nothing to install or update
Generating autoload files
Updating the "app/config/parameters.yml" file
X-Powered-By: PHP/4.4.9
Content-type: text/html
<br />
<b>Parse error</b>: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in <b>/kunden/81425/hhcadm/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php</b> on line <b>13</b><br />
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when generating the bootstrap file.
The error makes sense as 4.4.9 is too old. How can I tell Composer/Symfony installer which php installation to use during the install routine?
Same happens for me when I call:
php5.3.8-cli /kunden/81425/composer.phar install
I am pretty shure there must be a config / param for that but I can't find it for hours now.
Thank you very much.
'php' must be the PHP5 executable.
The only solution i see is to modify the PATH, launch the composer command (and eventually restore the old path)
For example :
OLDPATH=$PATH
PATH=/usr/local/php5/bin:$PATH
php /kunden/81425/composer.phar install
PATH=$OLDPATH
To help you, you can also create a small script 'composer.sh' :
#!/bin/sh
OLDPATH=$PATH
PATH=/usr/local/php5/bin:$PATH
php /kunden/81425/composer.phar $*
PATH=$OLDPATH
And you call 'composer.sh install'
Edit : if all php binaries are in the same, you can create symbolic links
For example :
mkdir /usr/local/bin/php5
ln -s /usr/local/bin/php53-cli /usr/local/bin/php5/php
And so PATH=$PATH:/usr/local/bin/php5:$PATH
Edit: If you are not allowed to create /usr/local/bin/php5 then just use any other folder like:
#!/bin/sh
OLDPATH=$PATH
PATH=/kunden/81425/php5:$PATH
php /kunden/81425/composer.phar $*
PATH=$OLDPATH

CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Carro, compiling:(carro/car.clj:6)

So.. I have this problem (the one in the title). Just to give a background about what I did:
Create a Java class called Carro:
public class Carro{
public Carro(){}
public void turnon(String sound){
System.out.println(sound);
}
}
I've compile it:
javac Carro.java
And created a .jar:
jar -cf Carro.jar Carro.class
So, I created a new lein project:
lein new test
Created a /lib directory and pasted the Carro.jar in it.
Create a folder called carro in test/src/ directory and create a .clj file, called car.clj:
(ns carro.car
(:import [Carro] )
)
(defn callCarro []
(let [car (new Carro)]
(.turnon "vruuum!" car)
)
)
After all of that, I edited the project.clj file and add a :import [Carro] after the last parenthesis.
So, when I run the project using lein repl, I get this error:
$ lein repl
user=> (require 'carr.car :reload)
CompilerException java.lang.IllegalArgumentException:
Unable to resolve classname: Carro, compiling:(carro/car.clj:6)
Any ideas to solve this... Problem?
Leiningen 2 relies on maven to manage dependencies. Version 1 used to copy jars to the lib directory but this behavior was removed (see https://github.com/technomancy/leiningen/blob/stable/doc/FAQ.md). If you need a certain jar for your project, the easiest way is to install that jar on your local maven repo and let leiningen do the rest.
Maven (and so leiningen) needs a version, a group and an artifact for the jar you are working with (see https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#artifact-ids-groups-and-versions). So our first step will be to rename Carro.jar to Carro-0.1.0.jar. To make things a little easier, lets use a leiningen plugin to do the rest. Add the lein-localrepo plugin to your project.clj, something like:
(defproject foo "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.4.0"]]
:plugins [[lein-localrepo "0.4.1"]])
Then you can ask leiningen for the coordinates of the Carro dependency:
$ lein localrepo coords Carro-0.1.0.jar
Carro-0.1.0.jar Carro/Carro 0.1.0
That last part is the info needed to install to the mvn repo:
$ lein localrepo install Carro-0.1.0.jar Carro/Carro 0.1.0
After that,the jar is installed in your mvn repository: ~/.m2/repository/Carro/Carro/0.1.0/Carro-0.1.0.jar. So finally, add the newly installed dependency to project.clj:
(defproject foo "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.4.0"]
[Carro/Carro "0.1.0"]]
:plugins [[lein-localrepo "0.4.1"]])
And then from the repl:
$ lein repl
user=> (new Carro)
#<Carro Carro#7c04703c>
I suspect there may be multiple causes:
Clojure has trouble loading classes without a package which causes this.
that is not the typical location for test classes if you are using Leiningen
If you didn't run (import 'Classname) from the repl you will need to do that as well.

Clang with Xcode 4 error: invalide option nodistribute

I have been trying to get clang's analysis tool working, but I am not sure how to overcome a particular error when I run it. I have installed X-Code 4.0 and iOS 5 the output I get is:
Generating class dependency graph.
Launching /Users//Desktop/HomeWork2/tools/AnalysisTool.app/Contents/Resources/llvm/utils/scan-build with arguments: (
"-o",
"/Users/<homedir>/Development/myApp/Static analysis/results",
"-v",
"--status-bugs",
"-checker-cfref",
"-warn-dead-stores",
"-warn-objc-methodsigs",
"-warn-objc-missing-dealloc",
"-warn-objc-unused-ivars",
"-analysistool-checker-access-control",
"-analysistool-checker-coersions",
"-analysistool-checker-cyclomatic-complexity",
"-analysistool-checker-conditional-logical-complexity",
"-analysistool-checker-conditional-nesting-depth",
"-analysistool-checker-loop-nesting-depth",
"-analysistool-checker-dealloc-safety",
"-analysistool-checker-declaration-conventions",
"-analysistool-checker-discouraged-method-calls",
"-analysistool-checker-error-handling",
"-analysistool-checker-extra-parentheses",
"-analysistool-checker-finalize",
"-analysistool-checker-format-strings",
"-analysistool-checker-kvo",
"-analysistool-checker-memory-management",
"-analysistool-checker-naming-conventions",
"-analysistool-checker-shadow",
"-analysistool-checker-unused-ivars",
"--use-cc=/Developer/usr/bin/llvm-gcc-4.2",
"--use-c++=/Developer/usr/bin/llvm-g++-4.2",
"-generate-class-dependency-graph",
xcodebuild,
"CONFIGURATION_BUILD_DIR=/Users/<homedir>/Development/myApp/Static analysis/build",
"CONFIGURATION_TEMP_DIR=/Users/<homedir>/Development/myApp/Static analysis/build",
"-configuration",
Debug,
clean,
build
).
scan-build: Emitting reports for this run to '/Users//Development/AMMO_SVN_Projects/MobXpo/branches/MobXpo_v12/Static analysis/results/2011-06-30-8'.
scan-build: 'clang-cc' executable not found in '/Users//Desktop/SWEN_646/HW2/tools/AnalysisTool.app/Contents/Resources/llvm/utils/libexec'.
scan-build: Using 'clang-cc' from path.
xcodebuild: error: invalid option '-nodistribute'
Usage: xcodebuild [-project ] [[-target ]...|-alltargets] [-configuration ] [-arch ]... [-sdk [|]] [=]... []...
xcodebuild -workspace -scheme [-configuration ] [-arch ]... [-sdk [|]] [=]... []...
xcodebuild -version [-sdk [|] [] ]
xcodebuild -list [[-project ]|[-workspace ]]
xcodebuild -showsdks
Options:
-usage print full usage
-verbose provide additional status output
-project NAME build the project NAME
-target NAME build the target NAME
-alltargets build all targets
-workspace NAME build the workspace NAME
-scheme NAME build the scheme NAME
-configuration NAME use the build configuration NAME for building each target
-xcconfig PATH apply the build settings defined in the file at PATH as overrides
-arch ARCH build each target for the architecture ARCH; this will override architectures defined in the project
-sdk SDK use SDK as the name or path of the base SDK when building the project
-parallelizeTargets build independent targets in parallel
-jobs NUMBER specify the maximum number of concurrent build operations
-showsdks display a compact list of the installed SDKs
-list lists the targets and configurations in a project, or the schemes in a workspace
-find BINARY display the full path to BINARY in the provided SDK
-version display the version of Xcode; with -sdk will display info about one or all installed SDKs
I have researched the internet but I have found nothing to help my specific problem. I think what i need to do is edit the clang tool to not include the "nodistribute" option, but im not sure if there is another way or where to get the source code to do so. Thanks in advance for any help.
I found a way around this after a lot of looking for an answer I decided to see if I could modify the line of code that was including the -nodistribute option. So I used grep to find the line of code in the .app bundle and then opened it in vi. I added a comment # to the line and bingo, off to the races.
The file, relative to the app bundle root is found at: ./Resources/llvm/utils/scan-build

how to check the version of jar file?

I am currently working on a J2ME polish application, just enhancing it. I am finding difficulties to get the exact version of the jar file.
Is there any way to find the version of the jar file for the imports done in the class? I mean if you have some thing, import x.y.z; can we know the version of the jar x.y package belongs to?
Decompress the JAR file and look for the manifest file (META-INF\MANIFEST.MF). The manifest file of JAR file might contain a version number (but not always a version is specified).
You need to unzip it and check its META-INF/MANIFEST.MF file, e.g.
unzip -p file.jar | head
or more specific:
unzip -p file.jar META-INF/MANIFEST.MF
Just to expand on the answers above, inside the META-INF/MANIFEST.MF file in the JAR, you will likely see a line: Manifest-Version: 1.0 ← This is NOT the jar versions number!
You need to look for Implementation-Version which, if present, is a free-text string so entirely up to the JAR's author as to what you'll find in there.
See also Oracle docs and Package Version specificaion
Just to complete the above answer.
Manifest file is located inside jar at META-INF\MANIFEST.MF path.
You can examine jar's contents in any archiver that supports zip.
Each jar version has a unique checksum. You can calculate the checksum for you jar (that had no version info) and compare it with the different versions of the jar. We can also search a jar using checksum.
Refer this Question to calculate checksum:
What is the best way to calculate a checksum for a file that is on my machine?
Basically you should use the java.lang.Package class which use the classloader to give you informations about your classes.
example:
String.class.getPackage().getImplementationVersion();
Package.getPackage(this).getImplementationVersion();
Package.getPackage("java.lang.String").getImplementationVersion();
I think logback is known to use this feature to trace the JAR name/version of each class in its produced stacktraces.
see also http://docs.oracle.com/javase/8/docs/technotes/guides/versioning/spec/versioning2.html#wp90779
Thought I would give a more recent answer as this question still comes up pretty high on searches.
Checking CLi JAR Version:
Run the following on the CLi jar file:
unzip -p jenkins-cli.jar META-INF/MANIFEST.MF
Example Output:
Manifest-Version: 1.0
Built-By: kohsuke
Jenkins-CLI-Version: 2.210 <--- Jenkins CLI Version
Created-By: Apache Maven 3.6.1
Build-Jdk: 1.8.0_144
Main-Class: hudson.cli.CLI
The CLi version is listed above.
To get the Server Version, run the following:
java -jar ./jenkins-cli.jar -s https://<Server_URL> -auth <email>#<domain>.com:<API Token> version
(the above will vary based on your implementation of authentication, please change accordingly)
Example Output:
Dec 23, 2019 4:42:55 PM org.apache.sshd.common.util.security.AbstractSecurityProviderRegistrar getOrCreateProvider
INFO: getOrCreateProvider(EdDSA) created instance of net.i2p.crypto.eddsa.EdDSASecurityProvider
2.210 <-- Jenkins Server Version
This simple program will list all the cases for version of jar namely
Version found in Manifest file
No version found in Manifest and even from jar name
Manifest file not found
Map<String, String> jarsWithVersionFound = new LinkedHashMap<String, String>();
List<String> jarsWithNoManifest = new LinkedList<String>();
List<String> jarsWithNoVersionFound = new LinkedList<String>();
//loop through the files in lib folder
//pick a jar one by one and getVersion()
//print in console..save to file(?)..maybe later
File[] files = new File("path_to_jar_folder").listFiles();
for(File file : files)
{
String fileName = file.getName();
try
{
String jarVersion = new Jar(file).getVersion();
if(jarVersion == null)
jarsWithNoVersionFound.add(fileName);
else
jarsWithVersionFound.put(fileName, jarVersion);
}
catch(Exception ex)
{
jarsWithNoManifest.add(fileName);
}
}
System.out.println("******* JARs with versions found *******");
for(Entry<String, String> jarName : jarsWithVersionFound.entrySet())
System.out.println(jarName.getKey() + " : " + jarName.getValue());
System.out.println("\n \n ******* JARs with no versions found *******");
for(String jarName : jarsWithNoVersionFound)
System.out.println(jarName);
System.out.println("\n \n ******* JARs with no manifest found *******");
for(String jarName : jarsWithNoManifest)
System.out.println(jarName);
It uses the javaxt-core jar which can be downloaded from http://www.javaxt.com/downloads/
I'm late this but you can try the following two methods
using these needed classes
import java.util.jar.Attributes;
import java.util.jar.Manifest;
These methods let me access the jar attributes. I like being backwards compatible and use the latest. So I used this
public Attributes detectClassBuildInfoAttributes(Class sourceClass) throws MalformedURLException, IOException {
String className = sourceClass.getSimpleName() + ".class";
String classPath = sourceClass.getResource(className).toString();
if (!classPath.startsWith("jar")) {
// Class not from JAR
return null;
}
String manifestPath = classPath.substring(0, classPath.lastIndexOf("!") + 1) +
"/META-INF/MANIFEST.MF";
Manifest manifest = new Manifest(new URL(manifestPath).openStream());
return manifest.getEntries().get("Build-Info");
}
public String retrieveClassInfoAttribute(Class sourceClass, String attributeName) throws MalformedURLException, IOException {
Attributes version_attr = detectClassBuildInfoAttributes(sourceClass);
String attribute = version_attr.getValue(attributeName);
return attribute;
}
This works well when you are using maven and need pom details for known classes. Hope this helps.
For Linux, try following:
find . -name "YOUR_JAR_FILE.jar" -exec zipgrep "Implementation-Version:" '{}' \;|awk -F ': ' '{print $2}'
If you have winrar, open the jar with winrar, double-click to open folder META-INF. Extract MANIFEST.MF and CHANGES files to any location (say desktop).
Open the extracted files in a text editor: You will see Implementation-Version or release version.
You can filter version from the MANIFEST file using
unzip -p my.jar META-INF/MANIFEST.MF | grep 'Bundle-Version'
best solution that does not involve extracting the jar files is to run the following command. If the jar file does not contain a manifest file you will get a "WARNING: Manifest file not found"
java -jar file.jar -v
Just rename the extension with .zip instead of .jar. Then go to META-INF/MANIFEST.MF and open the MANIFEST.MF file with notepad. You can find the implementation version there.
It can be checked with a command java -jar jarname

Resources