I have a requirement,where in which if i click on a particular link from the main project,the eclipse has to connect to a different sub project,perform the desired action,return the action performed to the main project,and main project renders the desired result,is there any way to do it?
You could do it in several different ways, first is simply to define a dependency on a different project that you have in your workspace:
Eclipse - How to give dependency between projects?
Then there is of course gradle and maven like ways to define dependencies:
Maven:
Maven jar dependencies and relations
Gradle:
http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
Either make one project a library and use that, or use an automated build system like Gradle or Jenkins
Related
What is the exact dependency I need to develop a Gradle Plugin in Java? Ideally I would like to get it from a well-known repository such as Maven Central or similar.
I have a Maven project with a core functionality and I just added two extra plugins, one for Ant, one for Maven. They are already tested and working; easy! Now, I wanted to add a third module for a Gradle plugin to make this functionality also available from any Gradle project.
However, I can't find the exact dependencies I need to develop a Gradle plugin.
The Gradle docs (such as https://docs.gradle.org/current/userguide/java_gradle_plugin.html) are not very well written to say the least. They mention:
the gradleAPI() dependency
or the java-gradle-plugin dependency
But they are quite unclear... no group, no version (really?).
If anyone can enlighten me to where I can get these dependencies from, I would be very thankful.
Gradle's public and internal APIs, aka gradleApi(), are bundled with the Gradle distribution and not independently published and therefore not easily consumable by Maven builds. There's the pending epic #1156 (Ensure plugin cross-version compatibility by allowing a user to depend on gradlePublicApi()) that might help here.
Since Gradle plugins are best to be built with Gradle, a pragmatic solution is to invoke the Gradle build from Maven and attach the produced artifact to the Maven build. Andres Almiray (aalmiray) once described this in the blog post Running Gradle Inside Maven (Web Archive Link). He describes the following high level steps:
Create a new Maven module (e.g. gradle-plugin) and add attach it to the parent POM
In the POM of gradle-plugin add a dependency to your core module. Use the maven-dependency-plugin to store dependencies to the Maven build folder, e.g. target/dependencies.
Create the build.gradle, add a Maven repository that points to target/dependencies (step 2) and let it depend on the core module as well as gradleApi(). Implement the Gradle plugin.
Use the exec-maven-plugin to invoke the Gradle build.
Use the maven-resources-plugin to copy the Gradle built plugin jars to the standard Maven build folder.
Use the build-helper-maven-plugin to attach the copied jars to the Maven build.
Sample project to be found here (gradle-in-maven).
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:custom_plugins_standalone_project
In here it is mentioned that it is gradleApi() and I know that this works (from experience). The localGroovy() on that page is only needed if your plugin code uses groovy (does not apply if you only use groovy in the build.gradle of your plugin).
java-gradle-plugin is a library that makes it a bit simpler to make plugins, it is not required though. I personally prefer using gradleApi only.
EDIT:
It appears I've misunderstood the question. Here are the steps to get gradleApi jar:
Create a Gradle project with your desired Gradle version.
Add implementation gradleApi() dependency.
Import/run the project once.
Go to your .gradle folder (located in home folder in Linux-based operating systems).
Open caches folder
Open the version folder you want, e.g. 6.0.1
Open generated-gradle-jars folder.
Copy the jar to wherever you want and use it.
For me the 6.0.1 jar is at ~/.gradle/caches/6.0.1/generated-gradle-jars/gradle-api-6.0.1.jar
Please note that I have not tested this, I know the jar is there but I haven't tried using it.
I try to install Javalin framework for creating an API on my Java project. (old java 8 project without maven, gradle, etc). I would like to install the framework with adding the jars to my build path.
But If I add the main jar file then it needs another dependencies jar , then another one another one another one.. etc.
Is there any simple way to add this to my project and all it's dependencies without any build tool like Maven,etc?
I have tried adding it manually , but each jar has many dependencies that it is almost impossible(?)
Well you could create a Maven project and use it to download the dependencies for you.
Maven dependency plugin might be useful. With it you could just call:
mvn dependency:copy-dependencies
and it will download all your dependencies into target/dependency.
I don't think there's a way, I'm afraid. Dependency management is the exact problem that build tools like Maven and Gradle were created to solve!
The framework supplier could provide a ‘fat’ jar including all the dependencies; but I'm not aware of any that do, as everyone uses Maven or Gradle (or SBT or Ivy or Grape or Leiningen or Buildr).
I think the only real alternative is to do it manually — which, as you've discovered, can be a horrible and lengthy task if the dependency tree is big. (And would need redoing with every update.)
So I'd suggest biting the bullet and using Maven if you can.
As example, i have program with version 0.0.1. Maven must create separate folder for it - "target/0.0.1/" instead of "target/". It must be done for version "0.0.2", "0.0.3", etc.
I use Eclipse & it's Maven:
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200
JDK 1.8.0_172
Maven doesn't work that way, and trying to do something like that will lead to a path of suffering. Options I see include
Creating a separate assembly (and output Jar) for each version (see Maven Assembly Plugin)
Create a multi-project reactor with a separate output configuration for every project. Keep common code in one project that you link as dependency from the others. Possibly use the maven-shade-plugin to re-link the packages in your common project into the individual output projects
As you can see, both of these approaches are pretty hacky and require advanced Maven skills. It would be much easier to have parameterized builds where you pass in the output version. But that would make sense on a CI server like Jenkins.
I have a multi-module project with test dependencies between modules.
Layout:
main-module - has SpecialsTableQueryBuilderTest that depends on AbstractTestHelper from the generic-search module
generic-search - has AbstractTestHelper
The problem: is that when I run "Make project" the SpecialsTableQueryBuilderTest class it complains that it "cannot find symbol, symbol: class AbstractTestHelper".
I tried in the modules settings, for the main-module, dependencies tab to move the generic-search module up, but it didn't help.
Another thing I tried on the same dependencies tab, it was to add the folder output for test-classes ("/target/test-classes")from the generic-search module as dependencie
What can I do so my project setup to see the AbstractTestHelper class?
Instead of trying to build one project at a time, I suggest trying to run the test of interest. This will build that class and everything it depends on (often a few classes you didn't really need) but it does all this for you.
If you are trying to include a class from a test module into another test module, you need to export it as this is not how maven projects work by default. You can have maven also build it's tests into an additional jar which you can include as a dependency.
Here is instructions on how to build a test JAR http://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html
I follow this steps for setting External dependencies:
https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle
(section: External Dependencies Examples >> universal-tween-engine using maven)
After do that, i check maven repo direcory and the files are there:
C:\Users\Admin.m2\repository\aurelienribon\tweenengine\6.3.3
Executing gradlew bat for rebuilding the project returns no errors:
I'm missing something because in Eclipse didn't see the references to Tween engine:
And obviously, if i try to add a reference to Tween Engine on my code i get an error:
How can i set up a new reference on existing gradle project, using libGDX for using Tween Engine in this case?
You did everything correct, but just adding the dependencies will not refresh the dependencies in eclipse.
You have to mark all related projects in eclipse, right click them and perform a Gradle -> Refresh Dependencies. Depending on what exactly you have changed, you might even need to do a Gradle -> Refresh All.
This will update the dependencies in eclipse and you will find the needed classes.