I'm using Gradle 7.4.2. I'm trying to see what it uses for generatedSourceOutputDirectory (among other CompileOptions.
I've tried:
tasks.compileJava {
println(options.generatedSourceOutputDirectory.toString())
}
but this prints an unhelpful:
task ':lib:compileJava' property 'options.generatedSourceOutputDirectory'
Sleuthing around the code itself on Github, I see that's its defaults are (seemingly) mangaged via XML code here.
How can I see what the current compile options are?
The option generatedSourceOutputDirectory is of type DirectoryProperty; therefore, to get the value that it holds, you need to call get().
Related
I am trying to get NeoVim to compile a simple Java program. The program itself has no ideas but I am not able to exactly output the compiled program.
I have this in my config:
autocmd Filetype java set makeprg=javac\ %
set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
map <F9> :make<Return>:copen<Return>
map <F10> :cprevious<Return>
map <F11> :cnext<Return>
I am able to see errors and compile but don't know how to see the output directly in NeoVim. Any way I can do so because I couldn't figure it out nor could find any useful information online.
In Neovim you have 2 options:
suspend the editor (Ctrl+Z), run your program and then return to editor with fg command
use build-in terminal
In Vim you would also have 3rd option: to use :!, but in Neovim it doesn't support input yet (see issue #1496)
If you choose option 2 then you simply use command :term java %<
But you would probably want it in a new window (in Neovim :term takes over the current one).
In such case you would need to use command: :new term://java %<
So in conclusion you would need to add to your init.nvim the following:
autocmd Filetype java nnoremap <F8> :new term://java %<<CR>
I have a story with parameters:
Given save in the <fileName> the data from <sqlQuery>
Then...
Examples:
fileName |sqlQuery
file.txt |query1
I run my test on particular environment with maven -Denvironment=DEV.
Now I would like to run this test on UAT using -Denvironment=UAT but the problem is that the sqlQuery is different then. How to indicate in the java code that if -Denvironment=DEV then use query1 but if -Denvironment=UAT then use query2 using JBEHAVE stories?
Does anyone cen help me with that?
In my opinion the easiest and clanest way is to provide different parameters for each environment directly in the story/scenario,
and pick a proper parameter in the java code depending on the environment.
We are using this method for 3 test environments: DEV, UAT, PRE and it work for us very well.
When the story failed then you do not neet to dig into logs or implementation to find which value of the parameter was used, everything is visible in JBehave report.Also changing parameters is easier, the tester just changes the story, he does not need to look into the implemetation in code.
Given save in the <fileName> the data from the query:
- DEV:<DevSqlQuery> UAT:<UatSqlQuert> PREPROD:<PreSqlQuery>
Then...
Examples:
|fileName |DevSqlQuery|UatSqlQuery|PreSqlQuery|
|file.txt |query1 |query2 |query3 |
I am generating code starting from two related Metamodels. The main one has references to classes of the second one. The Acceleo execution works well when executed as an Acceleo plugin but not when executed as a Java application. If I start the Java main Class, data of the 2nd related metamodels are not visible.
The error I get is
org.eclipse.acceleo.engine.AcceleoEvaluationException: Unresolved compilation error in generation module
I show you a snippet of Debug mode. target is a reference to a class of the 2nd metamodel (named peersbehavior).
---- The URI is correct, it's pointing to the exact location ----
---- But values are not retrieved ----
I had a similar problem with ATL Model2Model transformation: the option "Allow inter-model reference" must be checked. But in Acceleo I don't find anything similar
[EDIT]
As pointed by standalone documentation,
I added these 2 rows of code at the Java class
public void registerResourceFactories(ResourceSet resourceSet)
{
super.registerResourceFactories(resourceSet);
// code added by me
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("systembehavior", new XMIResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("peerbehavior", new XMIResourceFactoryImpl());
}
Now It works also starting the Java class, But if I export the project as Jar, and try to use it in another project, I have the same problem as before
I solved this problem adding this code (as pointed in the [EDIT] section of my question)
public void registerResourceFactories(ResourceSet resourceSet)
{
super.registerResourceFactories(resourceSet);
// code added by me
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("systembehavior", new XMIResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("peerbehavior", new XMIResourceFactoryImpl());
}
and adding manually the .emtl compiled files, in the src dir (otherwise they will not be inserted in the .jar).
With these modification, the code generation works if executed as Java application. Running the transformation as Acceleo application doesn't work
Hello I am trying to pass arguments to my ImageJ PlugIn. However it seems no matter what I pass, argument string will be considered as empty by the program. I couldn't find any documentation on the internet about THAT issue.
My Java plugIn looks like this, and compiles fine.
import ij.plugin.PlugIn;
public class Test implements PlugIn {
public void run(String args) {
IJ.log("Starting plugin Test");
IJ.log("args: ." + args + ".");
}
}
I compile, make a .jar file and put it into the ImageJ plugins folder.
I can call it with the ImageJ userInterface (Plugin>Segmentation>Test) and the macro recorder will put the command used:
run("Test");
Then my code is executed, the log window pops-up as expected:
Starting plugin Test
args: ..
I can manually run the same command in a .ijm file, and get the same result.
However, when I run the following macro command:
run("Test", "my_string");
I get the same results in the log window:
Starting plugin Test
args: .. // <- I would like to get "my_string" passed there
Where it should have displayed (at least what I expect it to do)
Starting plugin Test
args: .my_string.
So my question is: how can I pass parameters to PlugIn and especially how to access them?
Many thanks
EDIT
Hey I found a way to bypass that:
Using the Macro.getOptions() : this method will retrieve the string passed in argument to the plugin.
However, I still can't find a way to pass more than 1 string argument. I tried overloading the PlugIn.run() method but it doesn't work at all.
My quick fix is to put all my arguments in 1 string, and separating them by a space. Then I split this string:
String [] arguments = Macro.getOptions().split(" ");
I don't see a more convenient way to get around that. I can't believe how stupid this situation is.
Please, if you have a better solution, feel free to share! Thanks
You are confusing the run(String arg) method in ij.plugin.Plugin with the ImageJ macro command run("command"\[, "options"\]), which calls IJ.run(String command, String options).
In the documentation for ij.plugin.Plugin#run(String arg), it says:
This method is called when the plugin is loaded. 'arg', which may be blank, is the argument specified for this plugin in IJ_Props.txt.
So, arg is an optional argument that you can use in IJ_Props.txt or in the plugins.config file of your plugin to assign different menu commands to different functions of your plugin (see also the excellent documentation on the Fiji wiki).
To make use of the options parameter when running your plugin from macro code, you should use a GenericDialog to get the options, or (as you apparently learned the hard way) use the helper function Macro.getOptions().
I have a test that compares a large blob of expected XML with the actual XML received. If the XML is significantly different, the actual XML is written to disk for analysis and the test fails.
I would prefer to use assertEquals so that I can compare the XML more easily in Eclipse - but this could lead to very large JUnit and CruiseControl logs.
Is there a way I can change a JUnit test behaviour depending on whether it's running through Eclipse or through Ant.
Here are 2 solutions.
Use system properties
boolean isEclipse() {
return System.getProperty("java.class.path").contains("eclipse");
}
Use stacktrace
boolean isEclipse() {
Throwable t = new Throwable();
StackTraceElement[] trace = t.getStackTrace();
return trace[trace.length - 1].getClassName().startsWith("org.eclipse");
}
Yes - you can test if certain osgi properties are set (System.getProperty("osgi.instance.area") for instance). They will be empty if junit is started through ant outside of eclipse.
Maybe the "java.class.path" approach can be weak if you include some eclipse jar in the path.
An alternative approch could be to test "sun.java.command" instead:
On my machine (openjdk-8):
sun.java.command org.eclipse.jdt.internal.junit.runner.RemoteTestRunner ...
A possible test:
boolean isEclipse() {
return System.getProperty("sun.java.command")
.startsWith("org.eclipse.jdt.internal.junit.runner.RemoteTestRunner");
}
Usually, the system proeprties are different in different environments. Try to look for a system property which is only set by eclipse or ant.
BTW: The output in eclipse is the same, its just that the console for eclipse renders the output in a more readable form.
Personally, I wouldn't worry about the size of the logs. Generally you don't need to keep them very long and disk space is cheap.
With Java 1.6+, it looks like the result of System.console() makes a difference between running for Eclipse or from a terminal:
boolean isRealTerminal()
{
// Java 1.6+
return System.console() != null;
}