First, I've attempted to use the kie-maven-plugin in the project parent:
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>6.1.0.Final</version>
<extensions>true</extensions>
but after further reading it doesn't sound like it actually precompiles the rules before placing them in the jar (and I don't see any sign of it doing so).
I also see that there is a drools verifier, however it seems that this only works to verify drl files within Java.
Is there a good way to compile / verify a drl file in a Maven build so that I don't deploy and run the webservice only to find that there is a typo in the drl file?
I'm currently using Eclipse Kepler w/ the Drools plugins, Maven 3.x and Drools 6.0.1.
I would guess that you forgot to specify the packaging as "kjar". If that is the case, the plugin won't be executed during the Maven build. Simply add <packaging>kjar</packaging> into you pom.xml.
Please see the example usage of the kie-maven-plugin: https://github.com/droolsjbpm/drools/blob/master/kie-maven-plugin-example/pom.xml
To best of my knowledge the kie-maven-plugin only verifies that the resources can be compiled. Running Drools verifier is not part of the execution.
If you are already using the "kjar" packaging, please post the entire pom.xml, otherwise it is hard to guess what is actually causing the described behavior.
Related
Here is my situation: I am turning in a coding challenge for an interview. We are allowed to use any programming language, I chose Java. I completed the project and it provides the correct output, but I am stuck on some technicalities of turning it in. The spec says that it will be compiled and run using the terminal on a mac or linux machine, and it says to "turn in source code only, please do not include compilation artifacts or binary dependencies". I have a couple jars as dependencies. Does this mean I can't include them with my source code? How would they compile the program then. Right now I am not using any management tool. I could use Maven and declare the dependencies in the pom.xml, but then I have to assume whoever grades my solution has Maven installed to run "mvn".
Should I stick with a basic java project and include the jars, use Maven instead, or is there another better way to do this? Sorry if I am overthinking this, I want to make it simple to run my project so my work can be assessed for its accuracy, not how I packaged it.
Yes, you can't include any dependencies as JARs. You need to use Maven or Gradle for this.
You don't need to assume that Maven is installed, Maven Wrapper can be used instead.
You can provide mvnw, what stands for maven wrapper. It's project-local installation of maven that is treated as source code and is used by calling ./mvnw instead of global mvn command (to make it working for the first time, use mvn -N io.takari:maven:wrapper). Reference.
I am calling Processing functions from Java code.
This works fine for the standard Processing classes, but how to you import other Processing libraries; e.g. gicentre?
I've actually got it working by extracting the jar file from the processing library and then manually installing the artifact into the maven project.
Is there a proper way to do it?
Add this dependancy in your maven pom.xml file.
<!-- mvnrepository.com/artifact/org.processing/core -->
<dependency>
<groupId>org.processing</groupId>
<artifactId>core</artifactId>
<version>2.2.1</version>
</dependency>
Sandip's answer will work for the core Processing library (with the caveat that you should use the latest version, not version 2.2.1), but like you've discovered, gicentre doesn't have a maven repository.
You can download the various gicentre libraries from this page. Each of those libraries comes as a .zip file that contains a .jar file.
Now that you have the .jar file, it's just a matter of adding that .jar to your classpath. How you do that depends on how you've set up your project. The simplest way to do it is to use the command line to compile your project, and then you'd use the -cp argument. You've said you're using Maven, so Googling "maven local jar" will lead to a ton of results, including this one: How to add local jar files to a Maven project?
But note that you don't have to use Maven. You could just set the classpath yourself, either via the command line or via your IDE settings. For simple projects, this can be a better option, especially if Maven is giving you trouble.
I want to modify a jenkins plugin called Files Found Trigger. But after I downloaded the source code from github, I found there are lots of lines started with import hudson.XXX. And I have no clue where to get the hudson library.
I thought maybe I could find some information at Jenkins Plugin Tutorial. But it seems that the tutorial doesn't mention about where to get the library.
Anyone can help?
From here (Upgrading from Hudson to Jenkins):
Jenkins is basically a drop-in replacement to Hudson.
It's the continuation of the same code base, in same package structure. There has been no major surgery since the rename, and the rename really only affected what's shown in the UI. As such, it understands the same set of environment variables, same system properties, and the same information in the home directory. So if you rename jenkins.war as hudson.war, and simply overwrite your hudson.war, the upgrade is complete.
So my conclusion is: just rename hudson to jenkins.
There is no need to do anything, the Jenkins core has loads of references to java packages pointing to hudson.XXX. This is for legacy reasons, Jenkins used to be called Hudson. When the splitting of the project and renaming to Jenkins was done, the java package structure and names was kept in order to maintain backwards comparability for plugins (otherwise all plugins would have to be updated).
In case you've got compilation errors due to this, then something is wrong with your setup, ensure that the maven dependencies are correct as mishadoff says.
Every jenkins plugin should refer to parent object in pom.xml
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.21</version>
<relativePath />
</parent>
You can find more examples at official git plugin https://github.com/jenkinsci/git-plugin/blob/master/pom.xml#L3
UPDATE: The plugin Files Found Trigger you're trying to modify, uses parent dependency in pom.xml https://github.com/jenkinsci/files-found-trigger-plugin/blob/master/pom.xml#L4
All import hudson.* statements, come exactly from that lib:
I have a simple webapp in an mavenized Eclipse project.
My pom.xml contains some lines that add Google's appengine-maven-plugin to the build plugins.
When I run mvn appengine:devserver I eventually get an error telling me that my class could not be loaded:
[INFO] WARNING: Error starting handlers
[INFO] java.lang.ClassFormatError: Incompatible magic value 4022320623 in class file com/teamlazerbeez/http/di/StartupListener
That number is EFBFBDEF in hexadecimal notation, something that is clearly not CAFEBABE, the byte sequence Java class files should start with.
I only found this and this on the subject matter, which leads me to believe that the encoding went wrong during either writing or reading the class file.
Is this the problem? How do I force maven to read/write classes with e.g. UTF-8 encoding?
And what is a good encoding?
My java files are all encoded the same way: Eclipse says ISO-8859-1, Notepad++ says ANSI.
PS: I'm on a windows machine.
As Joakim Erdfeld's answer suggests, one of the plugins is fiddling with the build.
The culprit is the maven-war-plugin v2.3, but only in the following situation:
Having the GAE nature enabled on the mavenized Ecipse project (where the appengine-maven-plugin v1.7.5 is listed in the pom.xml) will break running mvn appengine:devserver iff the following conditions apply:
'default output folder' (in the Eclipse project's 'Build Path' settings) is set to src/main/webapp/WEB-INF/classes/ (required for the GAE Eclipse plugin to work)
The GAE plugin decided to put GAE-jars in src/main/webapp/WEB-INF/lib/, even though these jars are already in the classpath.
In conclusion, the maven-war-plugin improperly copies .class and .jar files from your WEB-INF/ to your resulting .war file. Somewhere in the process, it mis-encodes these files.
Check your src/main/webapp/WEB-INF folder, it should not contain a classes folder.
If it does, it means you probably misconfigured your eclipse project.
One case we encountered is that the developer imports a maven project and runs the project "as a web application". The first time he does this, Eclipse asks him where the webapp folder is. If you answer src/main/webapp then Eclipse will put its classes there, and it will get messed up by maven after.
To solve this, delete the project from Eclipse and remove the src/main/webapp/WEB-INF/classes folder, then re-import the project.
And when Eclipse asks where the webapp folder is, it is in target/yourproject-yourversion.
Something in your maven build is messing with the class files after the compile and before the package phases.
Start by commenting out all of your <plugins> and then adding them back 1 at a time till the build breaks again.
Be sure you run > mvn help:effective-pom to check on what your pom looks like when it has been fully resolved to parent poms and whatnot.
(Experimental) You can possibly even get the build itself to tell you if the classes are bad by simply using the project-info-reports command line for the dependencies report.
> mvn clean org.apache.maven.plugins:maven-project-info-reports-plugin:2.6:dependencies
I found this question which also mentioned the invalid magic number EFBFBDEF. It also seems to suggest that you set the maven encodings properly. Use the following property:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
But I think that this only helps if you get an encoding warning during the maven build process.
I have an eclipse plugin project which dependes on java project in my eclipse. usually what I did is export the project as jar and use it as-is in the plugin. but this requires manual work. can I have a reference from my plugin projct to a java project that will be both compile-time and run-time dependency ?
I saw a similar question, but not exactly the same.
I think, the closest thing to this is to create a jar file from the referenced project, and import it to the projects repository. But thats quite hard to manage for a currently developed project.
On the other hand, isn't it possible to simply convert the Java project into a plug-in permanently? If the other user does not use OSGi/Eclipse, he/she will see only a manifest/manifest.mf file (and possibly a plugin.xml) next to the java project specific stuff, so this would not disturb them, but would help you.