I cloned a GitHub repo onto my disk an successfully built the project by:
ant clean-all resolve create-dot-classpath
within the projects root directory.
I assume this should also be possible from IntelliJ IDE but that fails by doing nothing at all - it simply states "All files are up-to-date" ... what I do is:
"Make module 'pentaho-kettle'"
"Compile module 'pentaho-kettle'"
I could use a hint where to look for a solution or what configuration is most likely missing.
As the project is a multi module project based on Ant and Ivy, you have to
import the project from sources
configure modules (like core, ui, the plugins, …) with the right directories for main and test sources and resources (they seem to overlap with java sources in that project)
setup the class path using an Ivy plugin (I recommend IvyIDEA), use the context menu on the ivy.xml file
and have luck to build. It will be some try and error!
You may also have a try importing from Eclipse as those .project and .classpath files are checked in. But than you also have to check the module directories, the import is more a partial guess and I worry that IntelliJ will not get any information about Ivy from the Eclipse setup.
Related
I have two gradle java projects imported into Eclipse, one being a dependency of the other.
I would like for Eclipse to use the local dependency code, instead of the compiled dependency in the gradle cache folders, so I can modify and debug both projects simultaneously.
How do I force Eclipse to use a local dependency code?
The feature you are referring to is known as Composite Builds:
Importing into the IDE
One of the most useful features of composite builds is IDE integration. By applying the idea or eclipse plugin to your build, it is possible to generate a single IDEA or Eclipse project that permits all builds in the composite to be developed together.
In addition to these Gradle plugins, recent versions of IntelliJ IDEA and Eclipse Buildship support direct import of a composite build.
Importing a composite build permits sources from separate Gradle builds to be easily developed together. For every included build, each sub-project is included as an IDEA Module or Eclipse Project. Source dependencies are configured, providing cross-build navigation and refactoring.
The most simple way of achieving this is to use includeBuild in your settings.gradle.
rootProject.name = 'my-composite'
includeBuild 'my-app'
includeBuild 'my-utils'
With that in place, there's no need to configure the build path manually in Eclipse.
Gosh this was a trivial one and it took me way too long to figure it out.
Solved the issue by creating a file named external-projects.properties in the root folder of the parent project with the relative or full path to the dependency project folder.
To be precise, for me the folders tree ends up like this:
git-folder/
|__parent-project/
|__external-projects.properties
|__build.gradle.kts
|__rest (src/main, etc)
|__dependency-project/
|__build.gradle.kts
|__rest (src/main, etc)
And the contents of the external-projects.properties file:
dependency-project = ../dependency-project
The dependency project must also be in the build path of the parent project (done by "Right-Click project > Build Path > Configure Build Path" and adding it in the "Projects" tab).
After that, a "Right Click > Gradle > Refresh Gradle Project" did the trick.
I've forked a Github project, used Eclipse to clone it locally, and imported that as a general project into Eclipse.
The accompanying .project file is an Eclipse .project file with the proper "nature" and "buildCommand" xml tags.
So it seems like a valid Eclipse project. However, I'm unable to specify a run configuration or configure the build path.
When I select the Build Path popup menu item, it says "no actions available" in grayed out text. When I select "Run/Run As" from the main menu,
it shows (none applicable). I'm wondering if the problem is that the project imported completely as source folders:
There are no packages to speak of. I created another project from scratch, and created the proper source folders and packages as needed
to match the package statements in the source code. After manually importing the source from the git repo, I can build and run that project.
If the lack of packages is indeed the problem, is there a quick way in Eclipse to convert source folders to packages?
What you did is you have probably cloned the repo in Eclipse and then Imported this project through a New Project Wizard, because in GitHub there is no existing .project (and no .classpath) files.
The "New Project Wizard" will create a set of defaults for a java project (I suspect that you selected just that), but is anaware of Maven structure, so all source folders will not be recognized and you will end up having to define them on your own. Worse, you will be unaware of any special parts of the Maven build that might be configured within pom.xml.
Because this project uses Maven for building, it would be better to use M2Eclipse while importing it. Install it using Help->Install new software.
Then there are a couple of steps required to make it use all Eclipse features.
Keep your cloned copy of the repository or clone again if you want to start from scratch. Then use File->Import feature to import a maven project into the workspace. Select Exisiting Maven Projects and point to the directory containing pom.xml file in the cloned repo. This will use Maven integration in Eclipse to generate .project and .classpath files based on pom.xml contents, so you will be able to more closely mimic Maven build in Eclipse. All source folders should be properly discovered this way. Eclipse might want to install some additional integrations for Maven features that this particular project uses. Let it, if that is the case.
Now, you will have the project operational and compiling in Eclipse, but it will not be aware that it is managed by Git... This is because M2Eclipse and Git Team provider are not integrated (at least they weren't when I last checked). In order to be able to commit to the repository in Eclipse, remove the project from workspace, but without deleting contents. Then, import from Repository view using Import Projects/Import exsisting Eclipse projects. Since necessary .project file is already generated, Eclipse will autodiscover the project and will use the right configuration prepared earlier by M2Eclipse.
In the end you will have a properly configured Maven project with Git as a team provider for it.
If this is a project meant to be built by Maven that contains a pom.xml file, install M2E before importing the project from your local cloned repository. It will handle this.
Right click at root of project select properties, in the sources tab add the folder "src/main/java" as source folder
Other way is to configure facet as java
I know that there is a Git plugin for Eclipse ("Egit"), but I like to do Git stuff on the command line, and I like to code in Eclipse, so I want to keep them separate.
I cloned a Git repo (I don't think its important, but for good measure, it was https://github.com/spinscale/dropwizard-jobs.git). I then opened up Eclipse (Juno) and created a new Java project, and selected the root of the cloned repo as the base path to my project. Eclipse asked me if I wanted to associate the project with the Java facet, and I clicked 'OK'.
This project has a large dependency tree (if you like, check out its 4 POM files). I don't use Maven to build (I use Gradle) so I just ran a script that resolves the dependencies of these POMs into a directory, and then I created a lib directory in this Eclipse project and copied all the JARs into it. I then added all these JARs to the project's classpath.
I am now seeing 10 errors in the Problems view in Eclipse, and they're all similar errors:
The type ApplicationStartTestJob is already defined ApplicationStartTestJob.java /dropwizard-jobs/dropwizard-jobs-core/src/test/java/de/spinscale/dropwizard/jobs line 10 Java Problem
The type ApplicationStartTestJob is already defined ApplicationStartTestJob.java /dropwizard-jobs/dropwizard-jobs-guice/src/test/java/de/spinscale/dropwizard/jobs line 10 Java Problem
8 more all like this, etc.
Sure enough, when I expand the entire project, I see it has the following structure:
dropwizard-jobs/
dropwizard-jobs-core/
src/test/java/
de.spinscale.dropwizard.jobs
ApplicationStartTestJob.java
dropwizard-jobs-guice
src/test/java/
de.spinscale.dropwizard.jobs
ApplicationStartTestJob.java
dropwizard-jobs-spring
src/test/java/
de.spinscale.dropwizard.jobs
ApplicationStartTestJob.java
So it seems that the maintainers of this project like to rename their unit tests with the exact same package/class names, and for some reason, Eclipse sees them as all belonging inside the same package. To test this I renamed dropwizard-jobs-core/src/main/java/de.spinscale.dropwizard.jobs.ApplicationStartTest to something else, and did the same for dropwizard-jobs-guice/src/main/java/de.spinscale.dropwizard.jobs.ApplicationStartTest and sure enough, all the errors associated with ApplicationStartTest being already defined went away.
So my suspicion is confirmed: The intention of these subfolders (dropwizard-jobs-core, dropwizard-jobs-guice and dropwizard-jobs-spring) is that they are sub-projects with separate classpaths. Eclipse thinks all of these source folders are part of the same project, and so it is lumping all of their classes into the same classpath. Since each subproject uses the same unit test naming conventions (same package/class names for each subproject), Eclipse see multiple classes in the same package as having the same name.
OK, good! I figured out the problem. But what's the solution? Ideally I would be able to keep all of these inside the same project, but perhaps modify the .classpath file or do something similar that instruct Eclipse to keep the subprojects separated from a classpath perspective. Any ideas?
SImply download eclipse m2e plugin, then import the project(considering you have already checked-out at your workstation), and do spend sometime learning MAVEN commands. here you can find an pverview of maven parent project and modules. Maven parent pom vs modules pom
One possible solution would be to introduce maven, which allows to naturally define a parent project and sub-projects in a multi-module maven project.
You can actually test that configuration outside of Eclipse, and then use M2Eclipse in order to import parent and its dependencies, at the same time (as commented in this answer) in your Eclipse.
Actually, the M2Eclipse project itself has guice test project, which you can use as model for your own guive subproject, in the repo sonatype/m2eclipse-guice, with an adequate pom.xml.
I have a application using a maven build and am using IntelliJ IDEA. Both Maven and IntelliJ build classes into the same target folder, however whenever I choose to rebuild a single class in IntelliJ it complains that it cannot find it's dependencies, even if maven just built them and they are in the output folders. If I do a full rebuild in IntelliJ it will build the class.
How do I make IntelliJ use the classes maven built as dependencies for the single class it is building?
If it's purely class files, I'm not sure why it'd be complaining if they're all under the directory you have configured IntelliJ to use for the project's compiled classes.
More frequently, what I've run into is the build creates some things other than class files and you have to create a library that points at that other stuff so that IntelliJ knows about them. Another wrinkle are resource files as those are hunted for relative to the project's working directory which is, by default, usually the root directory of the project which is rarely correct as most resources are dumped under a "build" or "deploy" directory.
If all else fails, you should be able to spit out verbose Maven build info and compare the classpath it's using at compile time to the one that IntelliJ uses to try and figure out where they differ.
I am using Buildr with a java/scala project.
Dependencies are descried in the buildfile. An as you may know, Buildr downloads dependencies into ~.m2 folder (as maven2 does).
I am wondering how can I import dependencies (from ~.m2 folder or buildfile) into my Intellij project to enjoy the code completion and error detection among other features offered by Intellij.
Thanks,
-A
buildr has a plugin to generate IntelliJ IDEA projects. It's described here:
If you use IntelliJ IDEA, you can generate project files by issuing:
$ buildr idea
It will generate a .iml file for every project (or subproject) and a .ipr that you can directly open for the root project. To allow IntelliJ Idea to resolve external dependencies properly, you will need to add a M2_REPO variable pointing to your Maven2 repository directory (Settings / Path Variables).
If you’re using IDEA 7 or later, use the buildr idea7x task instead. This task creates the proper .ipr and .iml files for IDEA version 7. It includes the -7x suffix in the generated files, so you can use the idea and idea7x tasks side by side on the same project.