This looks like exactly what I would like:
http://d.hatena.ne.jp/Yoshiori/20081125/1227615261
(in Japanese, but should be apparent what it does from the commands and output)
Unfortunately, when I try those steps, it seems the plugin no longer exists at that location. Googling for it elsewhere also failed.
In short, what I'd like is to launch a jython shell with all of the pom file dependencies available on the Jython class path (hope I got that terminology right). I have a project with a rather complex and changing set of dependencies defined in maven. If I can just launch Jython from the same pom file, then I can experiment with and script all of those classes.
Other suggestions for easily loading maven dependencies into a jython shell?
Have a look at the maven-jython-compile-plugin. This plugin allows you to deploy a standalone project that includes jython with libraries. There is a demo project that shows how to use this plugin. Specifically, look at AbstractInitJython and InitJython in the code repository on how to launch a python/jython console. It will have all the libraries of the project, all pom dependencies and all the python libraries requested.
The sourceforge umbrella project is http://mavenjython.sourceforge.net/
Related
I'm new to Gradle. I see that Gradle lib already has a file 'groovy-all-2.4.12.jar' in lib folder and I don't seem to have any issues with tasks and or dependencies. Still, is it necessary in any scenario to install Groovy on my system on top of it?
Reason why I ask is that, when I do 'gradle -v' in command prompt, I see few warnings. Please see attached screenshot.
With gradle it is strongly recommended to use the Gradle wrapper committed into the project you are building instead of a system-wide gradle distribution (that is gradlew and not gralde). This guarantees the matching version of Gradle your project has been tested with.
With the Gradle wrapper you do not need to care about any dependencies that Grade itself needs, such as groovy and you really do not need to install anything of Gradle at all as the wrapper in your project will download all it needs on the first run.
The minimum setup for the Gradle wrapper is:
/gradlew - unix shell script
/gradlew.bat - windows batch script
/gradle/wrapper/gradle-wrapper.properties -- the properties file defining the version
/gradle/wrapper/gradle-wrapper.jar -- the minimal jar (50Kb) that takes care about the rest
The above files must be committed into your project and this is what 99% of all gradle projects do. You will find further details here https://docs.gradle.org/current/userguide/gradle_wrapper.html
I apologize if this sounds to simple (or the fact that there are other links that define this problem) - but I'm a complete beginner to Maven and even Java.
All that I'm trying to do is to run this code to see what it does:
https://github.com/semanticvectors/semanticvectors/wiki/GettingStarted
The Wiki says that uses can either download the .jar file or use the maven repo. I downloaded their .jar file and tried to run it but failed. I use this code:
java -jar /home/user/semanticvectors-5.6.jar
That .jar file didn't work for me and from other stackoverflow links, it seems that either the .jar file is not setup properly or I have a non-compatitble java version.
In any case, I've decided to try using Maven to get this running. I've installed Maven using:
sudo apt-get install maven
It seems to be working as everything was successful in setup. But now I'm not too sure what to do after. This Wiki (linked above) as go to this Maven repo site (https://oss.sonatype.org/#nexus-search;quick%7Esemanticvectors). To my understanding (and correct me if I'm wrong) I thought Maven is a super repository for developers and testers to work from the same code, so I thought I could use Maven as an alternative to running to program. Anyways, I'm open to any suggestions to get the program running to see what it does, thanks.
If you're interested in knowing more about me: I'm running a 16.04 Ubuntu system with Java 8.
The idea is that you can either build the JAR yourself - get the source from SVN and build it (using maven commands, as maven is a build tool), or you can use the existing JAR that is already "prepared" and ready for use in the maven-repository (nexus, in this case).
The result should be the same - if you use the JAR as a dependency in your code (add it to your pom.xml) or if you build it yourself.
You can learn more about Maven and things will be much clearer...
I had created a groovy project. It worked by itself.
After some additions I had to add a new jar of a new library into the imports.
While the whole workspace runs on Gradle, I added the appropriate Maven reference to the gradle.build file.
After running gradle cleanEclipse Eclipse the new library works OK.
But. All project references to the Groovy libraries disappeared. Foolish me, I had to put some references to them into the gradle.build, too.
The list of libraries:
groovy.util.slurpersupport
groovy.xml
org.codehaus.groovy.tools.xml
groovy.lang
But I don't know how to include them into gradle.build. I can't found them in maven repository. And even so, I have them installed in my Eclipse, and I should take these. And I can't google any help, because gradle groovy gives the results on how to call gradle from groovy, not vice versa.
Moving from plain Groovy to Gradle won't help, it is really about gradle support for calling a java library from groovy.
I have nothing against getting dependencies from Maven rep., but I don't know how to do it in my case - The problem is, that I have Eclipse 3.6. And I should use the last version of groovy for Eclipse 3.6. So, I have installed it from http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/. And I don't know what is the equivalent version in Maven - there is no info about it.
There was some error in the groovy in Eclipse installation. Now after running gradle cleanEclipse Eclipse while build.gradle has NO dependencies to groovy, almost everything runs OK, I only have to add the groovy nature to the project
I tried to remote debug a maven plugin for a liquibase project with Intellij. IDEA is highlighting the wrong source code line.
I manually built and installed the plugin in my local maven repository from sources in my Intellij project. Intellij version is 11.1.3 and maven version is 3.0.4 running on Ubuntu 12.04.
For debugging the maven plugin I used mvnDebug comand.
If someone has any ideas please give me some advice. I'm not too used to remote debugging (in fact this is the second time I've done this).
For me, whenever IntelliJ is highlighting the wrong line, it was always because the version of the JAR/classes being used to run the application differs from my source files - i.e. different version of the sources were used to build the JAR and/or classes.
You are going to have to be sure that you are working from the exact source that was used to build the classes you are debugging.
You can verify this by looking at the classpath being used to launch the application, locating the JAR file or classes directory that contains the classes you are debugging, and verifying that they were built from the sources you are inspecting.
Note that when you are debugging third-party libraries, you often can download the "sources" jar (see IntelliJ2-IDEA get Maven-2 to download source and documentation).
If you stumbled across this post, and sure that the source and JAR are the same code, then this could be your problem.
http://youtrack.jetbrains.com/issue/IDEA-8021
Instead of doing remote debugging you can run the plugin directly from IntelliJ.
Have the liquibase plugin project loaded in IntelliJ by just pointing at the pom.xml.
Choose Edit Configurations...
Press the + button to Add New Configuration.
Select Maven.
Enter the Working directory to the project you want to run the plugin on.
Enter the Command line. Could be process-sources, compile or liquibase:status depending on what you want to do.
Press OK
Set a breakpoint in the Liquibase Mojo.
Now you can start this configuration by pressing Shift+F9.
Maven will start and finally you will see that your plugin is waiting at the breakpoint!
Make sure that you have defined the plugin in the target pom.xml with correct version and also that you build the plugin before launching it. You can ensure that by enabling Make in the Before Launch pane.
Yay, my thesis is done! Now that the pressure is off and I've had my fill of playing Skyrim, I'm converting the code I wrote for my thesis from a chaotic directory built with ant to a nice maven project.
I originally had a bin directory with about 20 bash scripts that ran the various java and ruby programs used in my thesis, including the final jruby/sinatra-based web server. I am planning on moving my scripts to src/main/scripts, but I need to figure out how to handle the classpath.
I had previously just hardcoded paths in my scripts to the manually-downloaded dependencies. However, now that maven is downloading and storing all the jars I need, what's the best way to reference them from my scripts:
Should I just get the scripts to reference the full paths of various jars in the local repository like before?
Should I make the local repository directory a configuration option for my scripts and use relative paths to this directory?
Should I build a big hairy jar with all the dependencies using the maven assembly plugin and access this via the script-relative path ../../../target/*-jar-with-dependencies.jar?
Is there some better option I haven't thought of?
In your script, use the exec:java plugin to run Java classes. It will sort out the classpath based on the defined dependencies. Then you don't need to worry about it.
Relook at all the scripts that you have. Potentially you could achieve the functionality of some of them using maven exec plugin.
Besides assembly and shade plugins, you may want to look at the functionalities provided by maven dependency plugin as well.
In my project (Soluvas fb-tools/fbcli), because I use Java 6 and later (which supports wildcard classpaths), here's what I do:
#!/bin/bash
# Must run first: mvn package dependency:copy-dependencies
java -cp 'target/dependency/*:target/fbcli-1.0.0-SNAPSHOT.jar' org.jboss.weld.environment.se.StartMain "$#"
No need for manual generation of classpaths. :)
There are quite some plugin doing similar things you mentioned. Assembly plugin you mentioned is doubtless one of them (and the way you suggested is also a neat working solution).
You may want to take a look in AppAssembler and Shade. They all provide some mechanism to bundle the dependencies and produce a directly executable package.
Here is CLI example using Maven plugin exec:java as mentionned by #artbristol in another comment:
mvn exec:java -Dexec.mainClass="mypackage.MyClassWithMain" -Dexec.args="arg1 arg2"