개요
Niagara Framework에 대한 개발환경 구축 방법본 문서는 "A non-programmer's guide to setting up a N4 development environment with Eclipse IDE"
https://www.niagara-community.com/s/feed/0D5D000005DPI4qKAH?u=005D0000005RPu2&tab=sfdc.ProfilePlatformFeed&fId=0D5D000005DPI4q
위의 링크를 번역하여 요점 정리한것이다.
Eclipse와 IntelliJ에 대한 개발환경 구축방법을 각각 정리한다.
(Eclipse와 IntelliJ 의 아이콘을 구경하라는 취지로... 별의미 없음) |
Eclipse 개발환경 구축
- Java Developer Kit(JDK) : http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Eclipse IDE for java Developers : http://www.eclipse.org/downloads
Gradle 다운로드
- gradle Download : http://gradle.org/gradle-download/
- 하드디스크에 압축해제. (바이너리용으로도 가능)
환경변수 추가 : GRADLE_HOME
- 제어판->시스템->고급시스템설정->환경변수
- 시스템변수 추가 : GRADLE_HOME , d:\gradle-2.12 (압축을 풀어놓은 폴더경로)
GRADLE_HOME/bin 안에 PATH 환경설정
- 제어판->시스템->고급시스템설정->환경변수
- 시스템변수의 Path에 "D:\gradle-2.12\bin;" 추가
GRADLE에 대한 설치 확인
- cmd 실행 후 "gradle -v" 를 실행하여 버전을 확인한다.
- GRADLE의 버전과 로컬환경설정에 대한 정보 출력을 확인
Eclipse용 Gradle Plugin 설치
- Eclipse에서 Help>EclipseMarketplace
- 검색 : "Buildship"
- 'Buildship Gradle Integration' 플러그인을 설치
N4 프로젝트 생성
- workplace에서 Tools>new Module을 이용하여 새로운 폴더 생성
- N4 프로젝트를 Eclipse에 임포트
- Gradle > GradleProject 선택
- ProjectRootDirectory는 N4프로젝트 폴더를 선택
이클립스내에서 프로젝트 개발 가능
- 패키지와 클래스를 추가할 수 있는 상태 완료
- 이클립스에서 locate view를 "Gradle Tasks" 선택
- Project header를 확장
- "build" 아래있는 "jar"를 더블클릭
- 소스를 컴파일해야하며 생성된 모듈은 나이아가라 폴더에 넣어주어야함
- 만일 .palette를 만들었다면 n4 팔레트에서 사용 가능
IntelliJ 개발환경 구축
In October 2018, I put together these steps for a customer who asked about IntelliJ (they're already outdated):
1) Install Java JDK 8u181 (or newer)
2) Install "IntelliJ IDEA Community Edition 2018.2.4"
3) Create a new module using 4.6, save it in a *good* directory location, like C:\Niagara\src\modules (not under Workbench's Niagara User Home). This will be the top level of your build environment.
4) At the top level of your build environment, right click on settings.gradle and choose "Open with" and select IntelliJ
5) In the "Import Project from Gradle" dialog, use the default settings
6) Find the "src" folder. Right-click on "src" and choose "Mark Directory As" > "Sources Root"
7) On module-part (i.e. myModule-rt), right-click and choose "Open Module Settings"
8) On Libraries tab, Add "New Project Library" for Java
9) In the Select Library Files dialog, navigate to and select <Niagara System Home>/modules/docSource-doc.jar, click OK to accept all detected roots as sources, and choose the appropriate modules in the next step.
10) Change the name to "Niagara"
11) Click on the "Add" button for the "Niagara" library, and in the Add Files dialog, navigate to and select <Niagara System Home>/modules/docDeveloper-doc.jar!/doc. Select JavaDocs and click OK.
12) Click on the "Add" button for the "Niagara" library, and in the Add Files dialog, navigate to and select <Niagara System Home>/bin/ext/nre.jar. Select JavaDocs and click OK.
13) Click on the "Add" button for the "Niagara" library, and in the Add Files dialog, navigate to and select <Niagara System Home>/modules. Click OK.
14) Write some code
15) When IntelliJ inspections highlight a missing dependency, click on the issue highlighted in red (i.e. "cannot resolve symbol 'BTagInfo'"), press Alt+Enter, and choose the option to add the library to the classpath. Then edit the gradle file (i.e. myModule-rt.gradle) and add the dependency.
16) Address all the IntelliJ inspection warnings for errors, missing imports and such
17) On the far right, click on Gradle
16) Expand myModule-rt>Tasks>niagara>slotomatic and double-click on slotomatic
17) Watch the build process run and complete
18) Review each file to see the updates, and address all the IntelliJ inspection warnings for errors, missing imports and such
19) For each Java file, optionally apply the right-click options to optimize imports and/or reformat code
20) Double-click on the moduleTestJar task
21) Watch the build process run and complete
There are various ways to handle libraries/dependencies, and the way I've described it here may not be the best way - but it was quick, and easy to document. I prefer to only have libraries for what I have defined as dependencies in my <module>-<part>.gradle file. That way, I get warnings when I use classes outside those dependencies, before I attempt to build/compile. As I recall, the errors you get when you're missing dependencies in the gradle file and you attempt to build, are rather obscure.
1) Install Java JDK 8u181 (or newer)
2) Install "IntelliJ IDEA Community Edition 2018.2.4"
3) Create a new module using 4.6, save it in a *good* directory location, like C:\Niagara\src\modules (not under Workbench's Niagara User Home). This will be the top level of your build environment.
4) At the top level of your build environment, right click on settings.gradle and choose "Open with" and select IntelliJ
5) In the "Import Project from Gradle" dialog, use the default settings
6) Find the "src" folder. Right-click on "src" and choose "Mark Directory As" > "Sources Root"
7) On module-part (i.e. myModule-rt), right-click and choose "Open Module Settings"
8) On Libraries tab, Add "New Project Library" for Java
9) In the Select Library Files dialog, navigate to and select <Niagara System Home>/modules/docSource-doc.jar, click OK to accept all detected roots as sources, and choose the appropriate modules in the next step.
10) Change the name to "Niagara"
11) Click on the "Add" button for the "Niagara" library, and in the Add Files dialog, navigate to and select <Niagara System Home>/modules/docDeveloper-doc.jar!/doc. Select JavaDocs and click OK.
12) Click on the "Add" button for the "Niagara" library, and in the Add Files dialog, navigate to and select <Niagara System Home>/bin/ext/nre.jar. Select JavaDocs and click OK.
13) Click on the "Add" button for the "Niagara" library, and in the Add Files dialog, navigate to and select <Niagara System Home>/modules. Click OK.
14) Write some code
15) When IntelliJ inspections highlight a missing dependency, click on the issue highlighted in red (i.e. "cannot resolve symbol 'BTagInfo'"), press Alt+Enter, and choose the option to add the library to the classpath. Then edit the gradle file (i.e. myModule-rt.gradle) and add the dependency.
16) Address all the IntelliJ inspection warnings for errors, missing imports and such
17) On the far right, click on Gradle
16) Expand myModule-rt>Tasks>niagara>slotomatic and double-click on slotomatic
17) Watch the build process run and complete
18) Review each file to see the updates, and address all the IntelliJ inspection warnings for errors, missing imports and such
19) For each Java file, optionally apply the right-click options to optimize imports and/or reformat code
20) Double-click on the moduleTestJar task
21) Watch the build process run and complete
There are various ways to handle libraries/dependencies, and the way I've described it here may not be the best way - but it was quick, and easy to document. I prefer to only have libraries for what I have defined as dependencies in my <module>-<part>.gradle file. That way, I get warnings when I use classes outside those dependencies, before I attempt to build/compile. As I recall, the errors you get when you're missing dependencies in the gradle file and you attempt to build, are rather obscure.
댓글 없음:
댓글 쓰기