Skip to content
Permalink
Browse files

maven project for clion ide initial commit

maven nar c/c++ project for clion ide
  • Loading branch information...
lmiguelmh lmiguelmh
lmiguelmh authored and lmiguelmh committed Feb 25, 2016
1 parent e05534a commit 2c20c453b88c05914a213fe11585acc663751824
@@ -0,0 +1,3 @@
cd clion-executable
call mvn clean install
pause
@@ -0,0 +1,12 @@
@echo off
echo For groupId, artifactId you could use:
echo groupId: organization.projectname, organization.projectname.app, organization.projectname.lib
echo This groupId directories hierarchy should be created inside the project src/main and src/include and in their own namespaces(like Java packages)
echo artifactId: projectname, projectname-app, projectname-lib
echo.

call mvn archetype:generate -DarchetypeGroupId=clion.archetype -DarchetypeArtifactId=clion-executable -DarchetypeVersion=1.0

echo.
echo Now you should open the project using the CLion IDE and compile it (with CLion and then with Maven)
pause
@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>clion.archetype</groupId>
<artifactId>clion-executable</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>C/C++ NAR Project for CLion IDE</name>
<description>Maven archetype to create a C/C++ NAR project which will be open by the CLion IDE</description>
<url>https://github.com/lmiguelmh</url>

<developers>
<developer>
<name>lmiguelmh</name>
<url>https://github.com/lmiguelmh</url>
</developer>
</developers>

<build>
<defaultGoal>install</defaultGoal>
</build>
</project>
@@ -0,0 +1,29 @@
<archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">

<id>clion-executable</id>

<!--
according docs https://maven.apache.org/guides/mini/guide-creating-archetypes.html
there should be sources/testSources/resources/testResources.
All files are located in resources because in sources Maven will try to find ".java"
<sources>
<source>src/main/c/main.cpp</source>
<source>src/main/include/main.h</source>
</sources>
<testSources>
<source>src/test/c/main-test.cpp</source>
</testSources>
-->

<resources>
<resource>src/main/c/main.cpp</resource>
<resource>src/main/include/main.h</resource>
<resource>src/test/c/main-test.cpp</resource>
<resource>CMakeLists.txt</resource>
</resources>

</archetype>
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.3)
project(${artifactId})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

#this project's include directories
include_directories("src/main/include")

#dependencies' include directories should be added here (as is pom.xml) (first you must mvn compile for target directory to be created)
#in one project I have opencv libraries in my pom.xml and thus should be here too (see the NAR projects for OpenCV binaries/Windows/VS12 in https://github.com/lmiguelmh)
#make sure you follow this answer to generate your own libraries http://stackoverflow.com/questions/34076669/add-a-static-library-for-the-link-phase-of-a-maven-nar-project
#opencv-core
#include_directories("target/nar/opencv-core-2.4.10-noarch/include")
#opencv-highgui
#include_directories("target/nar/opencv-highgui-2.4.10-noarch/include")
#opencv-imgproc
#include_directories("target/nar/opencv-imgproc-2.4.10-noarch/include")
#log4z - a really good logger
#include_directories("target/nar/log4z-3.0-noarch/include")
#commons - some commons functions
#include_directories("target/nar/commons-1.0-noarch/include")

#every file you add to the project should be added so CLion will recognize it
set(SOURCE_FILES src/main/include/main.h src/main/c/main.cpp)

add_executable(${artifactId} ${SOURCE_FILES})

add_executable(${artifactId}-test src/test/c/main-test.cpp)
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>nar</packaging>

<name>C/C++ NAR Project for CLion IDE</name>
<description>
C/C++ NAR Project ready to be open by CLion IDE.
CLion doesn't support compilation using the NAR plugin, it will use CMake instead. So if you want to compile and
install this project use the terminal (Alt+F12) you will need the compiler in your path. For msvc++ see
http://stackoverflow.com/a/34658125/2692914.
mvn compile
mvn package
mvn install
</description>
<url>https://github.com/maven-nar/</url>

<!--
<properties>
<skipTests>true</skipTests>
</properties>
-->

<!--
If you setup your environment you could do this and easily have OpenCv, logger and other functionalities in your program!
See https://github.com/lmiguelmh to find the NAR projects for OpenCV binaries/Windows/VS12 used here
<dependencies>
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv-core</artifactId>
<version>2.4.10</version>
<type>nar</type>
</dependency>
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv-highgui</artifactId>
<version>2.4.10</version>
<type>nar</type>
</dependency>
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv-imgproc</artifactId>
<version>2.4.10</version>
<type>nar</type>
</dependency>
<dependency>
<groupId>my.commons</groupId>
<artifactId>commons</artifactId>
<version>1.0</version>
<type>nar</type>
</dependency>
<dependency>
<groupId>zsummer.log4z</groupId>
<artifactId>log4z</artifactId>
<version>3.0</version>
<type>nar</type>
</dependency>
</dependencies>
-->

<build>
<defaultGoal>integration-test</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.2.3</version>
<extensions>true</extensions>
<configuration>
<libraries>
<!--
all of these configurations could be enabled at the same time
the NAR plugin will generate an artifact for each one
-->
<!-- executable -->
<library>
<type>executable</type>
<run>true</run>
</library>

<!-- static library
<library>
<type>static</type>
</library>
-->

<!-- shared library
<library>
<type>shared</type>
</library>
-->
</libraries>

<!-- comment this if you don't want to execute the main-test.cpp everytime -->
<tests>
<test>
<name>NativeLibTest</name>
<link>static</link>
</test>
</tests>
</configuration>
</plugin>

</plugins>
</build>

</project>
@@ -0,0 +1,13 @@
/*
It is recommend to use namespaces as physical directory levels (much like Java does)
*/

\#include <iostream>

using namespace std;

int main() {
cout << "Hello world from Maven NAR Project and with CLion IDE!" << endl;
cout << "Now you should open the terminal set your compiler path and type: mvn test or mvn install" << endl;
return 0;
}
@@ -0,0 +1,5 @@
/*
This is the directory where all headers will be (src/include)
For example, it will be easy to migrate the project to a static library
It is recommend to use namespaces as physical directory levels (much like Java does)
*/
@@ -0,0 +1,13 @@
/*
It is recommend to use namespaces as physical directory levels (much like Java does)
*/

\#include <iostream>

using namespace std;

int main() {
cout << "FROM TEST: Hello world from Maven NAR Project and with CLion IDE!" << endl;
cout << "FROM TEST: Now you should open the terminal set your compiler path and type: mvn test or mvn install" << endl;
return 0;
}

0 comments on commit 2c20c45

Please sign in to comment.
You can’t perform that action at this time.