I use a SuppressionFilter in my checkstyle-configuration. The path to the file suppression.xml is given relative to the checkstyle-configuration, using ${samedir} (http://eclipse-cs.sourceforge.net/#!/properties). Reason: I configured eclipse to use a remote checkstyle-configuration:
<module name="SuppressionFilter">
<property name="file" value="${samedir}suppress.xml"/>
</module>
The same checkstyle-configuration is used by my Gradle build-script. Unfortunately, the checkstyle-plugin for gradle seems to be unable to resolve the variable ${samedir}.
Is there a way to anyway use the same config-file for Eclipse and Gradle? I really don't want to maintain two files or use an absolute path in the Checkstyle-configuration.
You can manually set the "samedir" variable in your Gradle build script using configProperties.
checkstyle {
configFile = file("${rootDir}/build_dependencies/my_checks.xml")
configProperties = [samedir: "${rootDir}/build_dependencies"]
}
Source: adapted from Maven version
Related
I have the following line on my app properties file:
app.environment=#ENVIRONMENT#
and this line on my build.xml file:
<filter token="ENVIRONMENT" value="${PILTEnvironment}"/>
and this line on my build_dev.xml:
<property name="PILTEnvironment" value="LOCAL"/>
So, when running the app on Eclipse Version: 2021-06 (4.20.0), Build id: 20210612-2011, app.environment takes "LOCAL" value, as expected,
however, when running the app on Eclipse Version: Oxygen.3a Release (4.7.3a), Build id: 20180405-1200, app.environment takes value of "#ENVIRONMENT#"
What am I missing on Eclipe Oxygen?
Any help would be very appreciated.
Thanks.
Never mind, I figured it out. I was missing my C:/ant folder, now when running the servlet it understands #ENVIRONMENT#.
I want to compile Nutch 2.2.1 to use with MongoDB for data storage.
I changed gora-core to 0.5 in file ivy.xml:
<dependency org="org.apache.gora" name="gora-core" rev="0.5" conf="*->default"/>
Also added dependency for mongodb in ivy/ivy.xml file:
<dependency org="org.apache.gora" name="gora-mongodb" rev="0.5" conf="*->default" />
Added mongodb config in conf/gora.properties:
############################
# MongoDBStore properties #
############################
gora.datastore.default=org.apache.gora.mongodb.store.MongoStore
gora.mongodb.override_hadoop_configuration=false
gora.mongodb.mapping.file=/gora-mongodb-mapping.xml
gora.mongodb.servers=localhost:27017
gora.mongodb.db=nutch
Added gora-mongodb-mapping.xml to conf directory from Nutch-2.3-SNAPSHOT.
When I am trying to compile I get error:
Could not load definitions from resource org/sonar/ant/antlib.xml. It could not be found.
After which I get many compiler errors.
When I try to configure and compile Nutch with MySQL every compiles and work perfectly.
I am trying to compile on Debian.
The error is being thrown because the sonar jar is not present in one of the classpaths (see build.xml, line 883)
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${ant.library.dir}"/>
<classpath path="${mysql.library.dir}"/>
</taskdef>
It looks like the warning can be safely ignored, because it's only required when running the "sonar" target.
One simple solution would be to move the taskdef within the "sonar" target. That would avoid the error message.
I would suggest raising a JIRA issue to get this fixed.
After correcting this error I got another ;-). After research I found what it is not possible to compile Nutch 2.2.1 with Gora 0.5 to use MongoDB (gora-mongodb rev=0.5).
I have cloned Nutch 2.3 and successfully compiled it.
I am using antlr4.3 (complete) jar.
It has many duplicates in org.antlr.runtime and org.antlr.v4.runtime packages.
In code when I explicitly use 'v4.runtime' - at runtime, classpath picks up 'runtime'.
So I extracted the jar and recreated it without org.antlr.runtime.
But apparently some classes like RecognitionException is now not found.
How should I resolve this other than:
Exploding the latest Jar and specifying org.antlr.v4.runtime BEFORE org.antlr.runtime so that a duplicate class will be picked up from v4.runtime, and if there isn't one in it, it will look at org.antlr.runtime...??
To add to the above, here's the code snippet which gives a problem: the jars are in the classpath.
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.ANTLRInputStream;
public class AntlrMain {
public static void main(String[] args) {
System.out.println("Start Hello World");
try {
InputStream is = new FileInputStream(
"/home/ecworkspace/antlrCentral/DSL/mydev.dsl");
org.antlr.runANTLRInputStream input = new ANTLRInputStream(is);
org.antlr.v4.runtime.CharStream cs = (org.antlr.v4.runtime.CharStream) input;
VCFGLexer lexer = new VCFGLexer(cs);
Initially in the ANtlrMain class, I wasn't using explicit
org.antlr.v4.runtime.; but that failed at runtime, with 'CharStream not found'.
Then I changed to include full path of the class
Then changed the ANTLR4 Jar to 'exclude' org.antlr.runtime (it has org.antlr.v4.runtime). That's when the 'RecognitionException not found' error occurred.
The grammar by the way, compiles OK, generating all my VCFG*.java and tokens classes, where VCFG is the grammar name.
UPDATE 1
Keeping in line with suggestions from all - I removed my answer to my own questions and adding it to this original questions.
In antlr-4.2-complete.jar, I see:
/tmp/x/ $ jar -xf antlr-4.2-complete.jar
/tmp/x/ $ ls org/antlr
runtime stringtemplate v4
/tmp/x/ $ ls org/antlr/v4
analysis codegen parse semantics Tool$1UndefChecker.class Tool$OptionArgType.class
automata misc runtime tool Tool.class Tool$Option.class
/tmp/x/ $ ## The 2 runtimes above: org.antlr.runtime and org.antlr.v4.runtime
/tmp/x/ $ ## which to use where, along with same-name classes in
/tmp/x/ $ ## org.antlr and org.antlr.v4
So, in build.xml, I use above jar to:
`
java -jar antlr-4.2-complete grammar.g4 => compiles and gives me
VCFG*.java and VCFG*.tokens
javac -cp "antlr-4.2-complete-jar" VCFG*.java => Succeeds. I have
the VCFG*.class collection.
Then I compile my code AntlrMain.java (which uses AntlrInputStream
etc.), again with the above antlr jar and some 3rd-party Jars
(logging, commons) => successfully.
Finally the RUN of java -cp "antlr-4.2-complete.jar:log4j.jar" -jar
myJar => FAILS on 'CharStream' not found.
UPDATE 2
Adding, based on your response.
I have only recently started posting questions on Stackoverflow. So pointers about whether to respond to my question to provide more info, or to comment to a reply etc. are welcome.
-cp <3rd-party> is -cp "log4j.jar:commonsLang.jar".
By -cp "above-jar" I meant -cp "antlr-4.2-complete.jar.
And if I have not mentioned it, it is an oversight - I have, for every 'java' and 'javac commands, included antlr-4.2-complete.jar.
BUT I see you indicating antlr-runtime-4.2.jar. So there ARE separate antlr-runtime jar and antlr-complete jars.
In the 4 steps below (I am leaving out -cp for convenience, but am including antlr-4.2-complete.jar for 'every' step.
I believe, I should be using the antlr-run-time and antlr-complete jars at different steps:
1 (java MyGrammar.java)
2 (javac MyGrammar*.java)
3. javac MyOwnCode.java
4. Run myCode (java MyCode) ...
which of the two antlr JARs (runtime and complete; and their versions) should I then use, at each of the above 4 steps?
The jar file does not contain duplicate classes. The code generation portion of the ANTLR 4.3 Tool relies on the ANTLR 3.5.2 Runtime library, which is included in the "complete" jar file. While some of the classes have the same name as classes in ANTLR 4, they are not duplicates and cannot be used interchangeably.
#280Z28 / Sam:
I am mortified, but have to admit the simplest answer is most often the correct.
I spent time fleshing out the JAR, making multiple JAR files out of it, include one for compile, one for run and on and on.
The answer is succinctly explain in the ANT build.xml code snippet below: where I produce the 'final' production JAR file, which is the only JAR then included while executing my Main program:
<jar destfile="${p_productionJar}">
<fileset dir="${p_buildDir}" casesensitive="yes">
<include name="**/*.class"/>
</fileset>
<zipfileset includes="**/*.class" src="${p_genCodeJar}"/>
<!-- How did I miss including p_antlrJar earlier?? -->
<zipfileset includes="**/*.class" src="${p_antlrJar}"/>
<zipfileset includes="**/*.class" src="${p_jschJar}"/>
<zipfileset includes="**/*.class" src="${p_log4jJar}"/>
<zipfileset includes="**/*.class" src="${p_commonslangJar}"/>
<manifest>
<attribute name="Main-Class" value="AntlrMain"/>
.....
The production Jar was missing ${p_antlrJar} => which is antlr-4.3-complete.jar!!!!
You did mention this in your answer... but it was a pretty silly mistake to do, and didn't think I had done it...
Thank you.
I'm using Servlet 3.0 without any web.xml just using Spring WebApplicationInitializer. When I start the Webapplication with Run-Jetty-Run in eclipse, the JARScanning takes about 40 seconds since it tries to find HandlesTypes annotations in all jars.
Thus, I tried to set the WebInfIncludeJarPattern in the jetty-web.xml (I also tried jetty-context.xml) and put it in the webapp/WEB-INF folder as described in http://wiki.eclipse.org/Jetty/Howto/Avoid_slow_deployment. I also set metadata-complete="true". The content of the jetty-web.xml file is:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>.*/.*foo-api-[^/]\.jar$|./.*bar-[^/]\.jar$|./.*wibble[^/]*\.jar$</Arg>
</Call>
</Configure>
However, the JarScanner still scans all the JAR files. In the debug output I can see, that the jetty-web.xml file is parsed AFTER all the JARScanning is done:
OUTPUT:
2013-08-30 09:09:52.836:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/....../src/main/webapp/]} with runjettyrun.webapp.RJRWebInfConfiguration#1cdc4a5
......
2013-08-30 09:09:52.979:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/..../src/main/webapp/]} with org.eclipse.jetty.webapp.WebXmlConfiguration#136f39e
2013-08-30 09:09:53.076:DBUG:oejw.WebDescriptor:file:/C:/......../src/main/webapp/WEB-INF/web.xml: Calculated metadatacomplete = True with version=3.0
2013-08-30 09:09:53.076:DBUG:oejw.WebAppContext:preConfigure o.e.j.w.WebAppContext{/admin2,[file:/C:/....../src/main/webapp/]} with runjettyrun.webapp.RJRMetaInfoConfiguration#164de63
... <LOTS OF JARSCANNING>
2013-08-30 09:10:36.677:DBUG:oejw.JarScanner:Search of file:/C:/......./httpclient-cache-4.1.2.jar
2013-08-30 09:10:36.710:DBUG:oejw.WebAppContext:configure o.e.j.w.WebAppContext{/.................} with org.eclipse.jetty.webapp.JettyWebXmlConfiguration#803365
2013-08-30 09:10:36.711:DBUG:oejw.JettyWebXmlConfiguration:Configuring web-jetty.xml
2013-08-30 09:10:36.715:DBUG:oejw.JettyWebXmlConfiguration:Configure: file:/C:/......./src/main/webapp/WEB-INF/jetty-web.xml
How can I force RJR to pick up the jetty-web.xml earlier and only scan the files specified in there? Or is there any other way in RJR to specify the JARS to be scanned?
I am using following versions: Eclipse: Kepler Release 4.3 Build id: 20130614-0229 RJR: 1.3.3.201301020723 Jetty: 8.1.8.v20121106
WINDOWS: 64 bit
Thank you
Here is a workaround for speeding up Jetty 8 with Servlet 3.x.
Create a file (jetty.xml)
Open the RJR configuration
Click on "Show advanced options"
Additional Jetty.xml:
The file (jetty.xml) must have these lines:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Get name="handler">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
<Arg>.*/mwa-web-.*\.jar$</Arg>
</Call>
</Get>
</Configure>
Here, I'm telling Jetty that any file starting with mwa-web-* should be scanned for Servlet 3.x.
Looking through the RJR source code I came across this undocumented flag rjrDisableannotation which speeds up the startup time significantly in all Jetty 8/9/9.3.6 (so far I haven't noticed any unwanted side effects - of course as its name suggests it doesn't scan for annotations anymore).
It can be enabled as a "VM argument" in the "Run/Debug configuration" for a "Jetty Webapp".
e.g.:
-DrjrDisableannotation=true
Here the related source code for reference:
https://github.com/xzer/run-jetty-run/blob/rjr1.3.4/Jetty8Support/plugin-jetty8/bootstrap/runjettyrun/Configs.java#L210-L212
why can jruby find require 'susy' in my compass config.rb, but #import 'susy' within *.scss files produces the issue:
[java] error Web Content/common/sass/base/foundation_de_DE.scss (Line 9: File to import not found or unreadable: susy.
[java] Load paths:
[java] <removed>/Web Content/common/sass
My existing application wants to start using a responsive design on the front end. However, installing ruby / compass on all the developer's machines, integration environments, performance environments and production would kill the initiative.
per this question, and this simplified tutorial I used our current Ant build.xml to make some targets using jRuby.
gems in a jar trick to so that I don't need to install ruby everywhere:
downloaded jruby-complete-1.6.8.jar per latest jruby has relative path issue as of 2013.03.20
java -jar jruby-complete-1.6.8.jar -S gem install -i ./susy susy
jar uf jruby-complete-1.6.8.jar -C susy .
java -jar jruby-complete-1.6.8.jar -S gem list
ant target used during the build process:
<target name="compass.compile">
<java classname="org.jruby.Main" fork="true" failonerror="true" classpathref="jruby.classpath">
<arg line="${basedir}/compile.rb ${basedir} compile ${basedir}"/>
</java>
</target>
ant target used by Eclipse based IDE to 'auto-compile' when a user saves a scss file. Instructions to have Eclipse 'auto-build' scss files (start at step #5)
<target name="compass.dev">
<path id="jruby.classpath">
<fileset dir="../../../release/lib/arch/jruby">
<include name="jruby-complete.jar"/>
</fileset>
</path>
<java classname="org.jruby.Main" fork="true" failonerror="true" classpathref="jruby.classpath">
<arg line="${basedir}/compile.rb ${basedir} compile ${basedir}"/>
</java>
</target>
Finally, here is the 'compile.rb' used by the ant target:
Dir.entries(ARGV[0]).each do |lib|
$LOAD_PATH.unshift "#{ARGV[0]}/#{lib}/lib"
end
require 'rubygems'
require 'compass'
require 'susy'
require 'compass/exec'
exit Compass::Exec::SubCommandUI.new([ARGV[1], ARGV[2], "-q"]).run!
and the config.rb used by compass:
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
require 'susy'
http_path = "./Web Content/"
css_dir = "./Web Content/common/sass-output-css/"
sass_dir = "./Web Content/common/sass/"
add_import_path "./Web Content/sass"
images_dir = "./Web Content/common/images/"
javascripts_dir = "./Web Content/common/js/widgets"
# To enable relative paths to assets via compass helper functions. Uncomment:
#relative_assets = true
and finally, trying to use susy in an scss file:
#import 'reset';
#import 'utilities';
#import 'baseColorVariables';
#import 'font';
#import 'susy';
$total-columns: 12;
$column-width: 4em;
$gutter-width: 1em;
$grid-padding: 1em;
.magic-container { #include container; }
update as of 2013.03.20, this works. but it may not be the cleanest way to get Susy / compass on 'rubyless' machines. does anyone have anything cleaner?
found it. compass is not in the sass load path, nor is susy actually while running under a 'gems in a jar' jruby solution. Thank you Henning Petersen, and your post
specifically:
JRuby has quite a brilliant abstraction from the file-based way of all things Ruby, so most things keep working when packaged into a JAR. A file inside a JAR has a path roughly like this: /path/to/jar/gems.jar!file/in/jar/script.rb. JRuby keeps relative files and everything working when using JARs, with one great BUT: There is no way to do such a thing as a directory listing inside a JAR file. That's right, everything that reads directory listings is now broken.
I altered compass's frameworks.rb (not a fan) so it's directory listing call failure does not stop compass from loading itself into the sass load path:
Compass::Frameworks.discover(:defaults)
Compass::Frameworks.register_directory(File.join(Compass.base_directory, 'frameworks/compass'))
Compass::Frameworks.register_directory(File.join(Compass.base_directory, 'frameworks/blueprint'))
which changes a *.scss auto-compile request to:
Syntax error: File to import not found or unreadable: susy.
Load paths:
<removed>/Web Content/common/sass
file:<removed>/release/lib/arch/jruby/jruby-complete.jar!/gems/compass-0.12.2/frameworks/compass/stylesheets
file:<removed>/release/lib/arch/jruby/jruby-complete.jar!/gems/compass-0.12.2/frameworks/blueprint/stylesheets
ok, now we need to get susy into the load path. adding this line to compass's config.rb does not work, though I wish it did: add_import_path "../../../release/lib/arch/jruby/jruby-complete.jar!gems/susy-1.0.7/sass"
Henning Petersen also caught this, and it was again because of directory listing calls withing the jruby jar altered compass's configuration/adapters.rb and Sass's importers/filesystem.rb. Altering all those files is dirtier to maintain than I am comfortable with, and already the posting is out of date regarding compass && sass.
So I pulled the sass directory out of the jar, which let the compass's add_import_path work as intended. The cleanest solution I have so far is manually appending to the gem/compass-0.12.2/lib/frameworks.rb:
Compass::Frameworks.register_directory(File.join(Compass.base_directory, 'frameworks/compass'))
Compass::Frameworks.register_directory(File.join(Compass.base_directory, 'frameworks/blueprint'))
and then adding this line to the compass project's config.rb (whole file provided):
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
require 'susy'
http_path = "./Web Content/"
css_dir = "./Web Content/common/sass-output-css/"
sass_dir = "./Web Content/common/sass/"
add_import_path "./Web Content/susy-1.0.7-read-only"
images_dir = "./Web Content/common/images/"
javascripts_dir = "./Web Content/common/js/widgets"
# To enable relative paths to assets via compass helper functions. Uncomment:
#relative_assets = true
which led to the RAD / eclipse builder scss auto-compile ant target to spit out:
compass.dev:
BUILD SUCCESSFUL
Total time: 16 seconds