Gradle throws an error of expecting EOF, found '<<'.Why? - java

I am using the below piece of code to copy and filter the properties from the properties file and it is working fine.There are one variable which is not static and I need to pass as a paramter so it could work on correct file.I am using -Penv=test or -Penv=at but I am getting the error.
task createLocalProp(type:Copy) << {
from "templates/local.properties.template"
into ("$buildDir/properties")
def myProps = new Properties()
file("Properties/${env}/local_${env}.properties").withInputStream{
myProps.load(it);
}
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: myProps)
}
Error:
C:\GRADLE_WORK\XXXX-GRADLE>gradle -b build_localprop.gradle createLocalProp -Pen
v=test
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\GRADLE_WORK\XXX-GRADLE\build_localprop.gradle' line: 37
* What went wrong:
Could not compile build file 'C:\GRADLE_WORK\XXXX-GRADLE\build_localprop.gradle'
.
> startup failed:
build file 'C:\GRADLE_WORK\XXX-GRADLE\build_localprop.gradle': 37: expecting
EOF, found '<<' # line 37, column 33.
task createLocalProp(type:Copy) << {
^
1 error

I'm not sure right now why the compiler error happens, but you should not configure the task in execution phase, but in configuration phase. << syntax is a shortcut for doLast and thus even if it would compile it would probably not work as expected. Remove the << and probably everything is ok.

I ran into a similar error reporting the bottom of my gradle file had an error. In reality it was a missing closing bracket in the middle of the file that I missed when doing a diff merge conflict.

Related

Why does gradlew return cannot find symbol error when compiling code?

I'm compiling a Minecraft mod with gradlew which I coded using Eclipse. The Minecraft mod uses an API which I have created previously. The problem is that when I'm trying to compile the mod with gradlew it gives me the error: "cannot find symbol".
The curious thing is now that when I'm moving the called function to a fresh class it does not give me the compilation error and everything is fine (I did not rename the function or changed anything in it I just moved it to a class where no other functions are in). Why is that? I would like to keep the function in the main class and not move it to a own class.
This is the method I'm using which gives me the error below:
public static void RegisterSlabBlock(Block slabBlock, Block doubleSlabBlock, Class ItemBlockSlab, String completeName, String slabBlockName, String doubleSlabBlockName, String ModID) {
try {
GameRegistry.registerBlock(slabBlock, ItemBlockSlab, slabBlockName, slabBlock, doubleSlabBlock, false);
GameRegistry.registerBlock(doubleSlabBlock, ItemBlockSlab,doubleSlabBlockName,slabBlock,doubleSlabBlock, true);
SetLSCount.increaseBlockCount(1);
DebugHelper.sendDebugInformation(slabBlock.toString(), 2, ModID, 5);
} catch (Exception e) {
ErrorHelper.AddError("Failed to register block: " + completeName + "; Exception: " + e);
}
}
The error in gradlew:
D:\Userdata\Louis\Dokumente\Programmieren\Forge Modding\1.8.9\Workspace - Trekcraft\build\sources\main\java\com\wix\lmh01\trekcraft\util\RegisterContent.java:34: error: cannot find symbol
RegisterHelper.RegisterBlockSlab(VariablesManager.block_warp_core_half_slab, VariablesManager.block_warp_core_double_slab, ItemBlockWarpCoreSlab.class, "block_warp_core_slab", "block_warp_core_half_slab", "block_warp_core_double_slab", Refrences.MODID);
^
symbol: method RegisterBlockSlab(Block,Block,Class<ItemBlockWarpCoreSlab>,String,String,String,String)
location: class RegisterHelper
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
The ^ points to the dot after RegisterHelper.
The line I call this function with:
RegisterHelper.RegisterSlabBlock(VariablesManager.block_warp_core_half_slab, VariablesManager.block_warp_core_double_slab, ItemBlockWarpCoreSlab.class, "block_warp_core_slab", "block_warp_core_half_slab", "block_warp_core_double_slab", Refrences.MODID);
The line I call the function with from the other class
RegisterHelperBlocks.RegisterSlabBlock(VariablesManager.block_warp_core_half_slab, VariablesManager.block_warp_core_double_slab, ItemBlockWarpCoreSlab.class, "block_warp_core_slab", "block_warp_core_half_slab", "block_warp_core_double_slab", Refrences.MODID);
So it seams like something is wrong with the way I call the function with. It should normally work in booth ways I think.

Internal Action was not loaded Error: java.lang.ClassNotFoundException

I am trying to run an implementation a jason code that is using some Internal Actions. The interpreter is showing that it was not possible to find the "java" code of the internal action, as showed:
Server running on http://191.36.8.42:3272
[aslparser] [peleus.asl:29] warning: The internal action class for 'org.soton.peleus.act.plan(Goals)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.plan
[aslparser] [peleus.asl:42] warning: The internal action class for 'org.soton.peleus.act.isTrue(H)' was not loaded! Error:
java.lang.ClassNotFoundException: org.soton.peleus.act.isTrue
[peleus] Could not finish intention: intention 1: +des([on(b3,table),on(b2,b3),on(b1,b2)])[source(self)] <- ... org.soton.peleus.act.plan(Goals); !checkGoals(Goals); .print("Goals ",Goals," were satisfied") /
{Goals=[on(b3,table),on(b2,b3),on(b1,b2)]}Trigger: +des([on(b3,table),on(b2,b3),on(b1,b2)])[noenv,code(org.soton.peleus.act.plan([on(b3,table),on(b2,b3),on(b1,b2)])),code_line(29),code_src("peleus.asl"),error(action_failed),error_msg("no environment configured!"),source(self)]
[peleus] Adding belief clear(table)
This mas2j file is as following:
MAS peleus {
infrastructure: Centralised
agents:
peleus;
}
Part of agent code (written by Felipe Meneguzzi) is showed bellow:
//The next line is line 28
+des(Goals) : true
<- org.soton.peleus.act.plan(Goals);
!checkGoals(Goals);
.print("Goals ",Goals," were satisfied").
+!checkGoals([]) : true <- true.
//The next line is line 40
+!checkGoals([H|T]) : true
<- .print("Checking ", H);
org.soton.peleus.act.isTrue(H);
!checkGoals(T).
I guess it is about the folder structure, how to set up Jason to search for java files in specific locations?
The folders structure is like this:
Peleus\src\org\soton\peleus for java files
Peleus\examples for mas2j and asl tested project
It all depends on how you are executing the application.
If you are using java, the CLASSPATH should be defined to include the missing classes.
if you are using jason script (that uses Ant), the .mas2j file should include the class path as well.
More on that in the FAQ. Notice that CLASSPATH is where .class files are found, not .java source code files. The error regards a missing class, not a missing source code.

Ansible: Changing permission of a directory issue

I'm running the following Ansible task to change permission of a directory and its content.
- name: Change ownership of everything below /opt/as2/app-server
file: path=/opt/as2/app-server state=directory recurse=yes owner=adrt group=adrt
When running it I get the following issue:
TASK [appserver : Change ownership of everything below /opt/as2/app-server] ****
fatal: [192.168.1.182]: FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_UrBo6x/ansible_module_file.py\", line 451, in \r\n main()\r\n File \"/tmp/ansible_UrBo6x/ansible_module_file.py\", line 335, in main\r\n changed |= recursive_set_attributes(module, to_bytes(file_args['path'], errors='surrogate_or_strict'), follow, file_args)\r\n File \"/tmp/ansible_UrBo6x/ansible_module_file.py\", line 146, in recursive_set_attributes\r\n changed |= module.set_fs_attributes_if_different(tmp_file_args, changed)\r\n File \"/tmp/ansible_UrBo6x/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1163, in set_fs_attributes_if_different\r\n File \"/tmp/ansible_UrBo6x/ansible_modlib.zip/ansible/module_utils/basic.py\", line 929, in set_owner_if_different\r\n File \"/tmp/ansible_UrBo6x/ansible_modlib.zip/ansible/module_utils/basic.py\", line 842, in user_and_group\r\nOSError: [Errno 2] No such file or directory: '/opt/as2/app-server-1.0.0/apps/station/WEB-INF/classes/org/adroitlogic/isuite/metrics/As2MetricsService/usr/bin/python$tt__collectStats_closure14.class'\r\n", "msg": "MODULE FAILURE"}
Basically it says there is no such file or directory as,
/opt/as2/app-server-1.0.0/apps/station/WEB-INF/classes/org/adroitlogic/isuite/metrics/As2MetricsService/usr/bin/python$tt__collectStats_closure14.class
The content of the directory, /opt/as2/app-server/apps/station/WEB-INF/classes/org/adroitlogic/isuite/metrics/ is,
As2MetricsService$_$tt__CountStatisticsLists_closure3.class
As2MetricsService$_$tt__collectStats_closure10.class
As2MetricsService$_$tt__collectStats_closure11.class
As2MetricsService$_$tt__collectStats_closure12.class
As2MetricsService$_$tt__collectStats_closure13.class
As2MetricsService$_$tt__collectStats_closure14.class
As2MetricsService$_$tt__collectStats_closure15.class
As2MetricsService$_$tt__collectStats_closure4.class
As2MetricsService$_$tt__collectStats_closure5.class
As2MetricsService$_$tt__collectStats_closure6.class
As2MetricsService$_$tt__collectStats_closure7.class
As2MetricsService$_$tt__collectStats_closure8.class
As2MetricsService$_$tt__collectStats_closure9.class
As2MetricsService$_CountStatisticsLists_closure1.class
As2MetricsService$_collectStats_closure2.class
As2MetricsService.class
There are no subdirectories.
Also when I run the command chown -R adrt:adrt . inside the directory /opt/as2/app-server it executes without any issue.
Help me to understand what is happening here.
Help me to understand what is happening here.
You have just found a bug in Ansible which causes modules to fail when the names of files it processes contain $_ sequence.
The name is passed without escaping the $ character (or rather with an explicit conversion request os.path.expandvars(filename)) and the sequence $_ is processed as an built-in variable resolving to the path of the current process (/usr/bin/python in this case, as Ansible uses Python to run its modules).
In result the file name:
As2MetricsService$_$tt__collectStats_closure14.class
is interpreted as:
As2MetricsService/usr/bin/python$tt__collectStats_closure14.class
and the system throws an error that the file does not exist (which is true).
Until it is fixed, I guess you have to call chown with the command module

determining whether javadoc encountered any errors or warnings

I would like to determine whether the javadoc command that we issue from a makefile encounters any errors or warnings. Currently, I can see that we're encountering errors due to import statements that are not on the classpath that we specify to javadoc (but should be). I ultimately want to fix our javadoc invocation and content and then lock it down so that any error or warning will be caught by the makefile and stop the build. However, as far as I can tell, the documentation does not mention any return code values from the javadoc command. Note that we're using Java 7 and running javadoc from a command in a GNU makefile, not from Ant or Maven. What do you recommend that I do?
UPDATE: My command looks like this:
<path1>/javadoc -overview <path2>/overview.html -sourcepath <path3> <file1> <file2> <dir1> <dir2> -d <output_dir>
There's nothing I can see in that call that would cause errors to be treated as warnings.
Here's a fragment from the output that shows the error/warning messages I'm seeing:
....
Constructing Javadoc information...
../../../<path>/<filename>.java:5: error: package javax.servlet.http does not exist
import javax.servlet.http.HttpSessionBindingEvent;
....
The word "error" appears in them, but at the end, the output says only "50 warnings". If I add another issue (such as the #invalid tag suggested in one of the answers), I get 51 warnings.
I just tried from the commandline, when no errors are present, a value of zero is returned:
> javadoc my.package.name
> ....
> echo $?
> 0
After editing a javadoc command with:
/**
* #invalid
*/
and running the same javadoc command again, I get an error message and a return code of 1:
> javadoc my.package.name
> ....
> ./my/package/name/Coordinate.java:21: error: unknown tag: invalid
> * #invalid
> ^
> ....
> echo $?
> 1
So you just should check if the return value of javadoc is 0 or not. If you do not know how to check that return, read this SO question and answer
Even though javadoc 1.7 reports errors, it returns with a zero return value, so the build doesn't catch it. However, javadoc 1.8 returns with a nonzero return value, which the build does catch.

Can't build spring framework using gradle on Windows 7 x64

Platform: Windows 7 x64
JDK version: 7.0.25 x64 or 7.0.45 x64
JDK installation path:
C:\Java\jdk725 or default c:\Program Files\Java\jdk1.7.0_25\
Spring Framework Release: 3.2.4 or 3.2.5
UAC: enabled or disabled
gradlew build (after gradlew):
:referenceHtmlMulti FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':referenceHtmlMulti'.
Failed to compile stylesheet. 59 errors detected.
Try:
Run with --info or --debug option to get more log output.
Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':referen
ceHtmlMulti'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
..
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: javax.xml.transform.TransformerConfigurationException: Failed to comp
ile stylesheet. 59 errors detected.
at com.icl.saxon.PreparedStyleSheet.prepare(PreparedStyleSheet.java:136)
at com.icl.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryI
mpl.java:127)
at com.icl.saxon.TransformerFactoryImpl.newTransformer(TransformerFactor
yImpl.java:79)
..
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
... 70 more
BUILD FAILED
My question is: why did my build fail?
The problem happens when :referenceHtmlMulti task is executing.
If we look in groovy class we will see that XSLT transformation is used to create docbook-reference. Despite the fact, that Saxon is used (TransformerFactoryImpl is selected) the choosen SAXParserFactory is org.apache.xerces.jaxp.SAXParserFactoryImpl (I wonder why not to use com.icl.saxon.aelfred.SAXParserFactoryImpl).
IF we look what implementation of xerces is used by gradle we will see xercesImpl-2.9.1.jar, which is old enough.
Now let's find class URI in xerces sources. It represents a Uniform Resource Identifier (URI). On line 1134 we can find
else if (!isURICharacter(testChar)) {
throw new MalformedURIException(
"Opaque part contains invalid character: " + testChar);
}
Now let's look how this function works:
private static boolean isURICharacter (char p_char) {
return (p_char <= '~' && (fgLookupTable[p_char] & MASK_URI_CHARACTER) != 0);
}
We can see that function will return true if char comparision will return true also. But that means rather close limits of chars (from code 0 - 126 (~)). But what about non US-ASCII character set?
Let's read RFC 2396 about non us-ascii characters (that can exist in your windows path, representing your local language or can be found in account name, under which gradle unpacks itself and works): other catagory - The Unicode characters that are not in the US-ASCII character set, are not control characters (according to the Character.isISOControl method), and are not space characters (according to the Character.isSpaceChar method) (Deviation from RFC 2396, which is limited to US-ASCII). The set of all legal URI characters consists of the unreserved, reserved, escaped, and other characters.
So. URI identification fails. And that is the place where build code fails.
There are 2 solutions:
To make your account name or path consist only of US-ASCII characters.
To patch URI class (for example, by rewriting function isURICharacter)

Categories