Can't build plugin because of circular dependencies - java

My plugin consists of a collection of other plugins written by myself and these plugins have circular dependencies in their class paths (and I don't see a way to remove those because the plugins rely on each other).
The plugin runs just fine when testing after I have set eclipse to mark those dependencies as warnings and not as errors. However when I try to build my plugin via the site.xml or the export wizard it always tells me
A cycle was detected when generating the classpath
raven.sqdev.preferences_0.2.0, raven.sqdev.util_0.3.0,
raven.sqdev.preferences_0.2.0.
and quits the building process.
I already found the option to allow circular dependencies in the export wizard but the result stays the same.
Has anyone an idea how I can build my plugin with these circular dependencies?

Related

Including other projects in the Java Build Path using Eclipse and Maven

I have been using Eclipse and Maven quite happily (in a largely non-understanding way) for some time to build Java/Selenium/TestNG projects.
I have one project representing a set of utilities that I use in all of the other website-based projects.
To include the utility classes I have simply added the utilities Project to the Classpath via the Java Build Path dialog. This worked well and any changes made to the utilities project were immediately reflected in the projects that used it.
However, when adding Logging capability (slf4j + logback) I started hitting issues with multiple versions being included. I eventually tracked down the issues but in order to solve them I ran "clean install" on both the utilities project and the projects using the utilities.
As a result I am now unable to build the website-based projects without adding the utilities jar as a dependency in pom.xml.
The previous method of simply adding as a Project is still sufficient to remove the errors from displaying on the source files, but now Maven (maven-compiler-plugin:3.7.0) reports a Compilation Failure as it says the utilities packages do not exist.
Looking at the impact of adding a Project to the build path, I see that a line is added to the project's .classpath file:
<classpathentry combineaccessrules="false" kind="src" path="/myutils"/>
but Maven debug shows no indication that this has had any impact on the classpath that it uses to compile.
What did I break when I did "clean install" and how do I restore it?
What mechanism does the Java Build Path Projects tab use to include content (source files or compiled classes?) from other projects in the Workspace?
Alternatively is this just a feature of Maven, that it wants to control everything (but why did it work before?) and is the dependency solution just as good? When including via dependencies (in pom.xml) are changes made to utilities immediately reflected without the need for a complete rebuild?

Generate Eclipse launch configurations with Gradle

We use Eclipse to launch and debug our Java GWT project. We have a couple of eclipse launch configuration files with many classpath entries needed for running the project.
Previously we used ant to build our project and had all our dependencies present on our local storage, with all classpaths pointing to libraries explicitly for project as well as launch configuration classpaths.
Once we migrated over to Gradle 6.6 and used public repositories to download our dependencies, almost everything worked smoothly - all our project classpaths were generated correctly by the gradle build. However, our eclipse launch configurations still contain the old hardcoded classpaths and I'm unable to find a way to generate these launch configurations using those gradle configured classpaths. As a result we've had to maintain the dependencies on our local filesystem so that the configurations have access to them in order to debug and run our code.
Is there a way Gradle can be used to generate these launch configurations so that we can get rid of the libraries on our filesystem and rely on whatever it pulls from the repositories during a build?
Any suggestions or workarounds will be appreciated.
It you're using Eclipse's built-in Gradle tooling (aka, Buildship) and let Eclipse generate your launch configuration, it will automatically be in sync with the project's build path, which is automatically kept in sync with the dependencies declared in your Gradle build file.
Here is an example Gradle project I just created, where I added some dependencies and the launch configuration "just works." The project is named "lib," notice under Classpath Entries is "Project Dependencies"; that's where Eclipse's Gradle tooling maintains and syncs with what's in the build.gradle file.
Here's what the project's Build Path looks like if I inspect it:
Whenever you add a dependency to build.gradle, it will automatically be included there; the launch configuration(s) then reference the project dependencies so the launches are also always in sync.
You might need to delete your existing launch configurations and let Eclipse generate new ones to get this.

remove and add project dependencies with gradle/intellij

I am a Java newbie here. I am thinking of a way to remove all the project dependencies.
For example in nodejs, we can simply remove the node_module folder and then do an npm install.
I am using Gradle and IntelliJ IDEA
How can I do the following:
Remove the dependencies from the project
Re-add the dependency again
Lastly where do I see all the dependencies along with its version number in IntelliJ
To remove dependencies from the project, simply go to your
build.gradle file and remove all the lines containing
"implementation", "complie" or anything similar.
However if you just want to remove them from cache and redownload
them simply enter this command in the terminal:
gradle clean build
or in the gradle menu which you can find in the IntelliJ Sidebar
press "Reload all gradle projects"
To see the version of the dependencies you can either use
"Dependencies" new feature of IntelliJ, or find them in the
build.gradle file.
more info here
You can Remove the already installed dependencies by using clean command
gradle clean build
The clean task is defined by the java plugin and it simply removes the buildDir folder, thus cleaning everything including leftovers from previous builds which are no longer relevant. Not doing so may result in an unclean build which may be broken due to build artifacts produced by previous builds.
As an example assume that your build contains several tests that were failed and you decided that these are obsolete thus needs to be removed. Without cleaning the test results (using cleanTest task) or the build entirely (by running the clean task) you'll get stuck with the failed tests results which will cause your build to fail. Similar side effects can happen also with resources/classes removed from the sources but remained in the build folder that was not cleaned.
This will remove the old dependencies and build them back together once again .
and about the dependencies , to check Without modules:
gradle dependencies
For android :
gradle app:dependencies
Note: Replace app with the project module name
Here is a possible solution , Another one would be to create a gradle task inside build.gradle:
subprojects {
task listAllDependencies(type: DependencyReportTask) {}
}
Then call the task with
gradle listAllDependencies
and one final simple solution is using Project report plugin
Add this to your build.gradle
apply plugin: 'project-report'
And Then generate a HTML report using:
gradle htmlDependencyReport
And here is IntelliJ IDEA specific way .
Hope i helped .

Removing unused dependencies form pom.xml

I am working on a huge spring project and I want to optimize the build time for the project.
So, I ran the dependency:analyze to find out there are more than 400 unused dependencies in the project.
Is there any tool or maven command to update the original pom.xml by removing unused dependencies.
Removing 400+ dependencies manually is obviously not a good idea.
If dependencies are your bottleneck, then set up an internal Maven repository mirroring the world and tell your build process to use that.

Make maven generate dependencies even with errors

This feels like a really stupid question but I haven't been able to find an answer.
I'm working on a maven project but I do most of my development in eclipse. Is there any way for me to force maven to generate all of my dependencies under target even if there are errors in the code? I set my eclipse project's build path to use the jars under target/dependencies/jars, but calling mvn clean kills them and if there are any errors in my code causing it to not compile mvn package won't create the dependencies but will instead just crash saying BUILD FAILURE. This makes the problem even worse since instead of seeing the actual errors my eclipse will just bombard me with errors everywhere since all of its dependencies just died.
Or maybe the way I'm working with it is just stupid and there's a better way.
Are you using the m2e plugins for Eclipse to process maven projects, or simply importing the projects as general ones?
If the latter, you should use the m2 plugins (simply go to the Eclipse Marketplace and search for Maven), as they interrogate your POM and set up your dependences properly. You can then concentrate on any compile errors in your code.
You should not point to the jars in the target folder for dependent JAR's since this is where the products of building your project are stored. Performing a mvn clean removes this folder.
To use Maven with Eclipse install the m2e plugin in Eclipse. This makes Eclipse understand the structure of Maven projects.
Once installed you can import your Maven project into Eclipse. I use Import... | Existing Maven Projects for this. But you can also directly import form a versioning system.
During the import Eclipse will set up the Eclipse project to use the Maven dependencies to locate the required JAR's. These are taken from the repository as configured with the used Maven installation.

Categories

Resources