Maven Scriptlets - maven

when I am builting my project in NetBeans using Maven I get this warning message:
[WARNING] DEPRECATED [postinstallScript]: Use postinstallScriplet
[WARNING] DEPRECATED [preinstallScript]: Use preinstallScriplet
[WARNING] DEPRECATED [preremoveScript]: Use preremoveScriplet
I change
<preinstallScript>src/main/scripts/preinstall</preinstallScript>
<postinstallScript>src/main/scripts/postinstall</postinstallScript>
<preremoveScript>src/main/scripts/preremove</preremoveScript>
to
<preinstallScriptlet>src/main/scripts/preinstall</preinstallScriptlet>
<postinstallScriptlet>src/main/scripts/postinstall</postinstallScriptlet>
<preremoveScriptlet>src/main/scripts/preremove</preremoveScriptlet>
in pom.xml. Then I got this error:
[ERROR]BUILD ERROR
------------------------------------------------------------------------
Failed to configure plugin parameters for: org.codehaus.mojo:rpm-maven-plugin:2.0.1
(found static expression: 'src/main/scripts/postinstall' which may act as a default value).
Cause: Cannot assign configuration entry 'postinstallScriptlet' to 'class org.codehaus.mojo.rpm.Scriptlet' from 'src/main/scripts/postinstall', which is of type class java.lang.String
and project was not built. What's wrong with this?
Thanks in advance.

You probably need to use it like this:
<preinstallScriptlet>
<scriptFile>src/main/bin/preinstall.sh</scriptFile>
<fileEncoding>utf-8</fileEncoding>
</preinstallScriptlet>
(as per: http://www.mojohaus.org/rpm-maven-plugin/adv-params.html )

Related

Specifying plugin class in bytebuddy gradle plugin

I have updated ByteBuddy Gradle plugin to the version 1.11.18.
Unlikely the previous version, where I could set up byteBuddy.transform.plugin as a string, in the latest version I have to set it up as a class.
Cannot cast object 'com.test.PluginImpl.class' with class 'java.lang.String' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: com.test.PluginImpl.class
I'm trying to figure out how to get the plugin applied
I followed the readme (https://github.com/raphw/byte-buddy/tree/master/byte-buddy-gradle-plugin#buildgradle):
byteBuddy {
transformation {
plugin = com.test.PluginImpl.class
}
}
However, I've got the error:
* What went wrong:
A problem occurred evaluating root project 'Test'.
> Could not get unknown property 'com' for object of type net.bytebuddy.build.gradle.Transformation.
Did you add the plugin to the buildsource? Groovy is a bit guessy when it comes to these things. Also try importing the class and using the unqualified name.
The old approach did no longer work properly with newer Gradle versions which is why I had to redo it.

Gradle Incremental Java build fails with “cannot find Symbol error”

Build is failing when I did a change in Java file
Android Gradle Plugin: 3.2.1
Gradle Version: 4.6
Please find the snapshot of error below:
17:58:31.131 [ERROR] [system.err] symbol: class FragmentNavigationManager
17:58:31.132 [ERROR] [system.err] location: package com.microsoft.office.officemobile.FragmentManagerInfra
17:58:31.138 [ERROR] [system.err] D:\Office\dev\officemobile\android\Java\src\com\microsoft\office\officemobile\ActionsTab\ActionsAdapter.java:45: error: cannot find symbol
17:58:31.138 [ERROR] [system.err] import com.microsoft.office.officemobile.KaizalaPhoneauth.KaizalaPhoneAuthManager;
I checked the undefined symbols are present inside file FragmentNavigationManager.java file inside the sources.
Using debug logs, I found the class file FragmentNavigationManager.class is getting deleted before doing java build
gradle: 17:58:28.630 [DEBUG] [org.gradle.api.internal.file.delete.Deleter] Deleting d:\office\build\droidarm\ship\officemobile\android\java\intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\microsoft\office\officemobile\FragmentManagerInfra\FragmentNavigationManager.class
After deletion of above class, while doing Java incremental build, FragmentNavigationManager.java should be passed as an input for javac, but it is not happening, which is causing undefined symbol issue. Clean build working fine
I found the issue
The source file path is: src\com\microsoft\office\officemobilefragmentmanagerinfra\FragmentNavigationManager.java
Generated Class file: intermediates\javac\release\compileReleaseJavaWithJavac\classes\com\microsoft\office\officemobileFragmentManagerInfra\FragmentNavigationManager.class
There is a case mismatch in directory name at source path and generated class path, which is causing the issue. Source path has fragmentnavigationmanager instead of FragmentNavigationManager
I found that the package name is: com.microsoft.office.officemobile.FragmentManagerInfra.FragmentNavigationManager. Changing directory name to match the package name at the source path resolves the issue
Is this expected, as full build is working fine and incremental Gradle build is only failing?
Working on Windows 10

Drools 7.7.0.Final generateModel fails with line and column information but no file information

I'm trying to build a kjar from our existing drools project with lots of individual rules file.
To speed up deployment I would like to generate the model into the kjar as introduced with Drools 7.7.0.Final.
The command I use is: mvn clean install -DgenerateModel=WITHDRL -X
Pretty soon I get an error message:
[ERROR] Failed to execute goal org.kie:kie-maven-plugin:7.7.0.Final:generateModel (default-generateModel) on project foobar: Execution default-generateModel of goal org.kie:kie-maven-plugin:7.7.0.Final:generateModel failed: (line 1,col 33) Parse error. Found ",", expected one of "%=" "&=" "*=" "++" "+=" "--" "-=" "/=" ";" "<<=" "=" ">>=" ">>>=" "^=" "|="
[ERROR] Problem stacktrace :
[ERROR] org.drools.javaparser.GeneratedJavaParser.generateParseException(GeneratedJavaParser.java:11460)
There is no information in which file this error occured. Since our project contains >300 DRL Files it is a bit hard to find the culprit.
Is there any way to get more information out of the Drools Maven Plugin on which file is causing the issue?
That's bug of kie-maven-plugin.
There are the bug's JIRA below.
DROOLS-3505
DROOLS-3523
If dialect is java and your rules have connect expressions with "comma" inside a modify block, The workaround is that
property inside modify block one by one.
the other workaround is changing dialect to mvel.
But, you have to write 'dialect "mvel"' in each rule file.
because dialect species isn't shared in package.

Cannot initialize module TreeWalker - Unable to instantiate SuppressWarningsHolder

I have maven-checkstyle-plugin(v2.5) and maven-eclipse-plugin(v2.8) configured.
Everything worked as expected but as soon as I introduced,
module name="SuppressWarningsHolder" AND/OR module name="SuppressWarningsFilter" to my checkstyle-config.xml, I started to have problems building the project.
Here is what I get:
[ERROR] BUILD ERROR
1> [INFO] ------------------------------------------------------------------------
1> [INFO] Failed during checkstyle configuration
1>
1>EXEC : Embedded error : cannot initialize module TreeWalker - Unable to instantiate SuppressWarningsHolder
1> Unable to instantiate SuppressWarningsHolderCheck
If I remove SuppressWarningsHolderCheck, I get the same error for SuppressWarningsFilter.
Any ideas?
Thanks
It appears you have two problems:
You are using maven-checkstyle-plugin v2.5, which is based on Checkstyle 5.0. In Checkstyle 5.0, the SuppressWarningsHolderCheck and the SuppressWarningsFilter did not exist yet, as they were introduced in 5.7. So you must first upgrade your maven-checkstyle-plugin.
The SuppressWarningsFilter must be configured directly under Checker, not under TreeWalker. The documentation does not make that part very explicit, although it is there. Note that the SuppressWarningsHolder does go under TreeWalker.
If you do both things, stuff should hopefully start working.

Getting name of last folder from maven ${project.basedir}

I have the same question for Maven that someone had about Ant (How can I get the name of the last folder in my basedir path in Ant?).
How do you get just the last directory name from the variable ${project.basedir}?
For example, if my pom.xml is in:
/home/me/project/pom.xml
Then ${project.basedir} = /home/me/project/
I want just the directory name 'project'.
Thanks!
Use: ${project.file.parentFile.name}
How to work it out:
The ${project} actually resolved to a MavenProject object. From there, you can just use bean properties to get the value you need. In this case:
use the file property (through getFile())
use the parentFile property on java.io.File (through getParentFile())
use the name property of the File to get just the name without path information (through getName())
(edit: after comment)
It's not a good idea to use properties for artifact IDs. The ${project.file.parentFile.name} property cannot be resolved when using it as part of artifactId, however some properties do work (project.groupId for the artifactId seems to work).
However, this is not recommended. In fact, if you use any property for the artifact ID instead of a constant, you'll get a warning when you build your project:
[WARNING] Some problems were encountered while building the effective model for <your groupID>:<your artifactID>:jar:1.0-SNAPSHOT
[WARNING] 'artifactId' contains an expression but should be a constant. # <your groupID>:<your artifact ID>:1.0-SNAPSHOT, <basedir>/pom.xml, line 5, column 14
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

Resources