diff --git a/pom.xml b/pom.xml index 57e3e53d9..99d523365 100644 --- a/pom.xml +++ b/pom.xml @@ -116,6 +116,7 @@ false + ${project.build.directory}/it dummy 3.0.4 UTF-8 @@ -541,6 +542,7 @@ maven-invoker-plugin 3.2.0 + ${invoker.workspace} true diff --git a/src/it/it-parent/pom.xml b/src/it/it-parent/pom.xml index 12af6e6c6..e8dd2b6a6 100644 --- a/src/it/it-parent/pom.xml +++ b/src/it/it-parent/pom.xml @@ -88,5 +88,33 @@ + + java-10+ + + [10,) + + + + + com.github.maven-nar + nar-maven-plugin + + + true + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + ${project.build.directory}/nar/javah-include + + + + + + diff --git a/src/it/it0040-multi-libtype/it0040-dep-lib-default/pom.xml b/src/it/it0040-multi-libtype/it0040-dep-lib-default/pom.xml new file mode 100644 index 000000000..e6b0bc97a --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-dep-lib-default/pom.xml @@ -0,0 +1,75 @@ + + + + + 4.0.0 + + + com.github.maven-nar.its.nar + it0040-pom + 1.0-SNAPSHOT + + + it0040-dep-lib-default + nar + + NAR Executable and default Library + 1.0-SNAPSHOT + + Executable depending on a library from a mixed type with default linkage. + + + + true + + + + + + @project.groupId@ + nar-maven-plugin + true + + + + LIB_IMPORTS + + + + + executable + + + + + + + + + + + com.github.maven-nar.its.nar + it0040-lib-sharedstatic + 1.0-SNAPSHOT + nar + + + diff --git a/src/it/it0040-multi-libtype/it0040-dep-lib-default/src/main/c/HelloWorldExe.c b/src/it/it0040-multi-libtype/it0040-dep-lib-default/src/main/c/HelloWorldExe.c new file mode 100644 index 000000000..15f98cc37 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-dep-lib-default/src/main/c/HelloWorldExe.c @@ -0,0 +1,28 @@ +/* + * #%L + * Native ARchive plugin for Maven + * %% + * Copyright (C) 2002 - 2014 NAR Maven Plugin developers. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +#include +#include "HelloWorldLib.h" + +int main(int argc, char *argv[]) { + printf("%s\n", HelloWorldLib_sayHello()); + return 0; +} + + diff --git a/src/it/it0040-multi-libtype/it0040-dep-lib-shared/pom.xml b/src/it/it0040-multi-libtype/it0040-dep-lib-shared/pom.xml new file mode 100644 index 000000000..844bad020 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-dep-lib-shared/pom.xml @@ -0,0 +1,78 @@ + + + + + 4.0.0 + + + com.github.maven-nar.its.nar + it0040-pom + 1.0-SNAPSHOT + + + it0040-dep-lib-shared + nar + + NAR Executable and Shared Library + 1.0-SNAPSHOT + + Executable depending on a shared library from a mixed type. + + + + true + + + + + + @project.groupId@ + nar-maven-plugin + true + + + + LIB_IMPORTS + + + + + executable + + + it0040-lib-sharedstatic:shared + + + + + + + + + + + com.github.maven-nar.its.nar + it0040-lib-sharedstatic + 1.0-SNAPSHOT + nar + + + diff --git a/src/it/it0040-multi-libtype/it0040-dep-lib-shared/src/main/c/HelloWorldExe.c b/src/it/it0040-multi-libtype/it0040-dep-lib-shared/src/main/c/HelloWorldExe.c new file mode 100644 index 000000000..15f98cc37 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-dep-lib-shared/src/main/c/HelloWorldExe.c @@ -0,0 +1,28 @@ +/* + * #%L + * Native ARchive plugin for Maven + * %% + * Copyright (C) 2002 - 2014 NAR Maven Plugin developers. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +#include +#include "HelloWorldLib.h" + +int main(int argc, char *argv[]) { + printf("%s\n", HelloWorldLib_sayHello()); + return 0; +} + + diff --git a/src/it/it0040-multi-libtype/it0040-dep-lib-static/pom.xml b/src/it/it0040-multi-libtype/it0040-dep-lib-static/pom.xml new file mode 100644 index 000000000..dee320226 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-dep-lib-static/pom.xml @@ -0,0 +1,73 @@ + + + + + 4.0.0 + + + com.github.maven-nar.its.nar + it0040-pom + 1.0-SNAPSHOT + + + it0040-dep-lib-static + nar + + NAR Executable and Static Library + 1.0-SNAPSHOT + + Executable depending on a static library from a mixed type. + + + + true + + + + + + @project.groupId@ + nar-maven-plugin + true + + + + executable + + + it0040-lib-sharedstatic:static + + + + + + + + + + + com.github.maven-nar.its.nar + it0040-lib-sharedstatic + 1.0-SNAPSHOT + nar + + + diff --git a/src/it/it0040-multi-libtype/it0040-dep-lib-static/src/main/c/HelloWorldExe.c b/src/it/it0040-multi-libtype/it0040-dep-lib-static/src/main/c/HelloWorldExe.c new file mode 100644 index 000000000..15f98cc37 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-dep-lib-static/src/main/c/HelloWorldExe.c @@ -0,0 +1,28 @@ +/* + * #%L + * Native ARchive plugin for Maven + * %% + * Copyright (C) 2002 - 2014 NAR Maven Plugin developers. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +#include +#include "HelloWorldLib.h" + +int main(int argc, char *argv[]) { + printf("%s\n", HelloWorldLib_sayHello()); + return 0; +} + + diff --git a/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/pom.xml b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/pom.xml new file mode 100644 index 000000000..87273bd90 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/pom.xml @@ -0,0 +1,93 @@ + + + + + 4.0.0 + + + com.github.maven-nar.its.nar + it0040-pom + 1.0-SNAPSHOT + + + it0040-lib-sharedstatic + nar + + NAR Shared + Static Library + 1.0-SNAPSHOT + + A library with both shared and static and test file + + http://maven.apache.org/ + + + true + + + + + + @project.groupId@ + nar-maven-plugin + true + + + + + static + + + + + + + shared + + nar-download + nar-unpack + nar-compile + nar-test-unpack + nar-testCompile + nar-test + + + + + shared + + + + + LIB_EXPORTS + + + + + + + + + diff --git a/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/main/c/HelloWorldLib.c b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/main/c/HelloWorldLib.c new file mode 100644 index 000000000..2611690ba --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/main/c/HelloWorldLib.c @@ -0,0 +1,26 @@ +/* + * #%L + * Native ARchive plugin for Maven + * %% + * Copyright (C) 2002 - 2014 NAR Maven Plugin developers. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +#include +#include "HelloWorldLib.h" + +char* HelloWorldLib_sayHello() { + return "Hello NAR LIB World!"; +} + diff --git a/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/main/include/HelloWorldLib.h b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/main/include/HelloWorldLib.h new file mode 100644 index 000000000..f16109a75 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/main/include/HelloWorldLib.h @@ -0,0 +1,43 @@ +/* + * #%L + * Native ARchive plugin for Maven + * %% + * Copyright (C) 2002 - 2014 NAR Maven Plugin developers. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +#ifndef HelloWorldLib_H +#define HelloWorldLib_H + +#ifdef WIN32 +#ifdef LIB_EXPORTS +#pragma message( "Export" ) +#define LIB_EXPORT __declspec(dllexport) +#else +#ifdef LIB_IMPORTS +#pragma message( "Import" ) +#define LIB_EXPORT __declspec(dllimport) +#else +#pragma message( "Static" ) +#define LIB_EXPORT +#endif +#endif +#else +#define LIB_EXPORT +#endif + + +LIB_EXPORT extern char* HelloWorldLib_sayHello(); + +#endif diff --git a/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/test/c/HelloWorldTest.c b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/test/c/HelloWorldTest.c new file mode 100644 index 000000000..15f98cc37 --- /dev/null +++ b/src/it/it0040-multi-libtype/it0040-lib-sharedstatic/src/test/c/HelloWorldTest.c @@ -0,0 +1,28 @@ +/* + * #%L + * Native ARchive plugin for Maven + * %% + * Copyright (C) 2002 - 2014 NAR Maven Plugin developers. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +#include +#include "HelloWorldLib.h" + +int main(int argc, char *argv[]) { + printf("%s\n", HelloWorldLib_sayHello()); + return 0; +} + + diff --git a/src/it/it0040-multi-libtype/pom.xml b/src/it/it0040-multi-libtype/pom.xml new file mode 100644 index 000000000..c642ad317 --- /dev/null +++ b/src/it/it0040-multi-libtype/pom.xml @@ -0,0 +1,55 @@ + + + + + 4.0.0 + + + com.github.maven-nar.its.nar + it-parent + 1.0-SNAPSHOT + ../it-parent/pom.xml + + + it0040-pom + pom + + NAR Multi Module + 1.0-SNAPSHOT + + Simple Multi Module project + + http://maven.apache.org/ + + + integration-test + + + + + it0040-lib-sharedstatic + it0040-dep-lib-default + it0040-dep-lib-shared + it0040-dep-lib-static + + diff --git a/src/main/java/com/github/maven_nar/NarCompileMojo.java b/src/main/java/com/github/maven_nar/NarCompileMojo.java index 0ec7404d8..d053bd0cf 100644 --- a/src/main/java/com/github/maven_nar/NarCompileMojo.java +++ b/src/main/java/com/github/maven_nar/NarCompileMojo.java @@ -145,7 +145,7 @@ private void createLibrary(final Project antProject, final Library library) // object directory File objDir = new File(getTargetDirectory(), "obj"); - objDir = new File(objDir, getAOL().toString()); + objDir = new File(objDir, getAOL().toString() + "-" + library.getType()); objDir.mkdirs(); task.setObjdir(objDir); @@ -371,8 +371,9 @@ private void createLibrary(final Project antProject, final Library library) // FIXME no handling of "local" - // FIXME, no way to override this at this stage - final String binding = dependency.getNarInfo().getBinding(getAOL(), Library.NONE); + String binding = getBinding(library, dependency); + if (binding == null) + binding = dependency.getNarInfo().getBinding(getAOL(), Library.NONE); getLog().debug("Using Binding: " + binding); AOL aol = getAOL(); aol = dependency.getNarInfo().getAOL(getAOL()); diff --git a/src/main/java/com/github/maven_nar/NarLayout21.java b/src/main/java/com/github/maven_nar/NarLayout21.java index 65a324f02..e858c35ce 100644 --- a/src/main/java/com/github/maven_nar/NarLayout21.java +++ b/src/main/java/com/github/maven_nar/NarLayout21.java @@ -233,12 +233,13 @@ public final void prepareNarInfo(final File baseDir, final MavenProject project, } else { // if the binding is already set, then don't write it for // jni/executable/none. - if (narInfo.getBinding(aol, null) == null) { + String current = narInfo.getBinding(aol, null); + if ( current == null) { narInfo.setBinding(aol, type); - } else if (type.equals(Library.STATIC)) { + } else if (!Library.SHARED.equals(current) + && type.equals(Library.STATIC)) { //static lib is preferred over other remaining types; see #231 narInfo.setBinding(aol, type); - narInfo.setBinding(null, type); } if (narInfo.getBinding(null, null) == null) {