It is said in IntelliJ IDEA Q&A for Eclipse Users that Eclipse Workspace is equivalent to "project" in IntelliJ terms, while Eclipse's project is equivalent to IntelliJ's module.
But after I created a project untitled and then created module untitled2 I got the following picture
I would think untitled is a project and untitled2 is a module, but both has src subfolders and listed in
so, both are modules of different level. Is this correct?
Is it possible to create module untitled3 at the same level as untitled?
How to create several modules of the same level without topmost one?
If you want to simulate the Eclipse workflow, you should create an empty project (~ workspace) first:
New Project > Empty Project
Now you can create separate modules (~ projects) to be shown exactly like you want:
You could also select untitled2, press F6 (Refactor > Move) and move it one level up in your directory. While creating untitled3 you can specify the folder for your module (use IdeaProjects instead of untitled).
The workspace equivalent term refers to Project Window in intellij. It will consists of modules which are equivalent of individual projects in Eclipse.
EDIT: You can right click on untitled module and go to Open Module Settings. And select Modules in project settings. With + sign you can choose to create new module. This should create new module on same level as untitled
All the information you need is here. JetBrains has a wonderful guide called "Working with modules".
Modules can be created on any level and any location, regardless the project location. You can safely remove the "parent" module.
Related
I have seen several of this question asked here, but none have fully been answered to my necessity. I have a file I want to create a jar file with so I can simply place it on my desktop and run it. I think I understand the process up to using Process Structure, then I am lost.
Basically, you can generate an artifact in IntelliJ from the build menu -> build artifact.
Dependending on your project, possible artifacts may be found automatically or not (if you use a "build tool" like maven, ant or gradle).
In case of a build tool, check its documentation to find how to generate a jar file from it.
If you're using a pure IntelliJ project, select your project root and hit F4, it will open its settings. In Artifacts, you'll have to add a new jar (the green + at the top of the window). Select "From modules and dependencies...". Then, you'll have to select the module to use and its main class. It should be enough. Then, you'll just have to build the needed artifact. The jar file will be generated in the folder defined in the configuration (Project settings->Project, Project compiler output in case of a single module, otherwise it will be generated in the module's folder)
When you're looking for a feature in IntelliJ, don't forget to use ctrl+shift+A to search it by its name.
Hope it helps
I am new to IDEA.
What I would like to do is have a project (or module?) that has maven folder structure (aka src/main/java, src/main/groovy, src/test/groovy, etc), be managed by Gradle and support creation of Groovy classes, their compilation and execution.
What I tried:
Create a "Groovy" Project.
I can add "Maven" support, but not Gradle.
Create a "Gradle" project and add "Groovy" module to it
I can manage dependencies and plugins, but the file structure is screwed up.
The code goes into a sub-folder of the project (aka the name of the module)
I cannot directly add folders to the "src" of the module. When I copy them into the src folder they are considered package names.
What I am looking for:
Solution to the particular problem
General workflow for creating multi-facet (aka Gradle+Groovy or Java+Maven or Web+YouNameIt) project/modules.
Explanation of what is the reason for this paradigm/structure shift in IDEA?
I would suggest not creating the project from inside Intellij.
Since Intellij imports Gradle projects quite nicely you can just import one of the pre-made Groovy Gradle Quick Starts you can find at the root of your Gradle installation.
For example $GRADLE_HOME/samples/groovy/mixedJavaAndGroovy has the exact Java/Groovy layout you describe with the HelloWorld Classes and Tests in place. Just copy it, rename the root folder, import it into Intellij and code!
Solution to the particular problem
0) Turn on Gradle plugin in Preferences -> Plugins
1) Create any Java project (Groovy, Maven, plain Java)
2) Create build.gradle file in base directory
3) Open JetGradle view and click Add. Then select your build file
4) When you do this first time, IDEA will prompt you to locate your local Gradle distribution (you may also change it later in Preferences -> Gradle settings)
As for project structure, Gradle follows Maven conventions, so in the build file you just write:
apply plugin: 'java'
and everything just works.
Create a "Gradle" project and add "Groovy" module to it
I can manage dependencies and plugins, but the file structure is screwed up.
The code goes into a sub-folder of the project (aka the name of the module)
I cannot directly add folders to the "src" of the module. When I copy them into the src folder they are considered package names.
Explanation of what is the reason for this paradigm/structure shift in IDEA?
The main reason is to provide possibility of logical decomposition of your application into separate modules, e.g. app-core, app-web, app-ear etc. Each of this modules produces an artifact: jar, war, ear.
Compare this with other IDEs, say Eclipse, where you would have several different projects (perhaps dependent on each other) to accomplish the same thing. So basically, you may think of IDEA module as of Eclipse project (roughly). Also this greatly simplifies usage of Maven multi-module projects.
As for the src folder: IDEA lets you mark directories inside the module "content root" (base directory of the module) as Source, Test Source or Excluded. If src is marked as Source directory, then obviously everything inside is treated as packages and sources.
I followed the steps in this video:
Create "Gradle" project, with Gradle plugin enabled and Gradle API plugin disabled. Select "Create empty folders" option.
Add "apply plugin: 'groovy'". This will create groovy folders.
Add "" to IML project file in order to be able to create Groovy classes.
I try to create project as it is said in tutorial - play new myproject -> Java project
Then I open it with IntelliJ and the target/scala-2.10/src_managed/main/controllers/routes file is all in errors. It cannot resolve nor package nor RverseAssets.
I didn't mind it until I needed to add some dependencies to my project. My Build.scala file could not be compiled. By the way, I had to create this file manually, it wasn't created for me.
I have Play 2.0 Support and Playframework support plugins installed.
EDIT Forgot to mention. I run command idea from the project root folder once it was generated
play idea marks wrong folders as Sources Roots. Unfold target/scala-2.10/src_managed/main in Project View. As you can see, controllers and views are marked as a Sources Root. Right-click on each and choose Mark Directory As/Unmark As Sources Root. Then right-click on main folder and choose Mark Directory As/Generated Sources Root.
Here is all well described how to create a new project and open it in IDEA
a documentation
You must use a console play:
idea with-sources=yes
Later the project already open in IDEA
I've got two projects in Eclipse. Both have some source files, and I want to reference sources from one project in another one. The only thing that works is
Project Properties -> Java build path -> Projects
Where I add the required project.
The problem is that when I'm trying to launch the project1 activity it starts and then launches project2 default activity.
How could I add sources from another project?
If you want to use another project as an library in your Android project add the project via Project Properties --> Android --> Library. The referenced project should be marked 'Is Library' on their own properties page.
I've seen different packages in source code such as com.website.package These packages are used across multiple applications, and I've been trying to accomplish something similar.
The only way I know of to achieve using the same packages in different projects is to copy each source file into the new project which would create the new packages. this probably isn't the preferred method, as it could possibly drag thousands of files into the project (see Java's library).
How would this be achieved?
TL;DR: How can I use a custom written package in multiple projects without copying many files? (aka Java's libraries).
Take the class files and create a jar. Put the jar on the classpath of all the applications that need those classes.
How do you do that?
Inside an IDE, you can create multiple projects and put the shared java code in one project. Make the other projects depend on that project and you can share things within the IDE. That means you run inside the IDE and it will use the shared code.
For example, in Eclipse, you choose the project that will use the shared code/project. Right click on it in the package view or navigator view and choose "properties". Select the option to set the build path and there is a tab for selecting projects that this project depends on. Select the shared project and then it's code is callable from that project.
In this case, any change you make to the shared project will be immediately available, inside the IDE, to those projects that depend on it. Run them right then and the change will be in effect.
For running outside the IDE ...
If you are using Eclipse (or some other IDE) it will have an option for creating a jar. In Eclipse you create a java project and move the classes you want to be in the library/jar into this project. Then, once you have all the right classes, including those that others depend on, you will do some sort of build to create the jar.
Eclipse has an 'export' option on the 'file' menu. Use that and select to export as a "java" > "jar" and then select the project you just made.
You can also create a Maven project of type "jar" into which you put all those classes (as java files) and then building that project with Maven will create the jar. The "install" goal for Maven will deploy it to your local repository.
Any time your shared code is shared by way of a jar, you will have to rebuild the jar and copy it into the location(s) from which it is shared by other projects before changes inside the jar take effect.
Maybe export the package to some place on the drive and create linked folders to it in the projects?