Maven plugin for J2ObjC library

In addition to standard J2ObjC conversion, this plugin supports dependencies conversion within the same projects.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.smoope.utils
ArtifactId

ArtifactId

j2objc-maven-plugin
Last Version

Last Version

1.1.4
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Maven plugin for J2ObjC library
In addition to standard J2ObjC conversion, this plugin supports dependencies conversion within the same projects.
Project URL

Project URL

https://www.smoope.com
Project Organization

Project Organization

smoope GmbH
Source Code Management

Source Code Management

https://github.com/smoope/j2objc-maven-plugin

Download j2objc-maven-plugin

How to add to project

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.4</version>
</plugin>

Dependencies

compile (8)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.3.9
org.apache.maven : maven-project jar 3.0-alpha-2
org.apache.maven : maven-aether-provider jar 3.3.9
org.eclipse.aether : aether-impl jar 1.0.2.v20150114
org.eclipse.aether : aether-connector-basic jar 1.0.2.v20150114
org.eclipse.aether : aether-transport-wagon jar 1.0.2.v20150114
org.eclipse.aether : aether-transport-file jar 1.0.2.v20150114
org.eclipse.aether : aether-transport-http jar 1.0.2.v20150114

provided (1)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.4

test (2)

Group / Artifact Type Version
org.apache.maven.plugin-testing : maven-plugin-testing-harness jar 3.3.0
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Maven plugin for J2ObjC library

Build Status Maven Central

Installation

Add the following plugin entry into your pom's plugins section:

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.4</version>
    <configuration>
        <j2objcPath>path/to/j2objc</j2objcPath>
    </configuration>
</plugin>

In order to run the plugin, execute the following command: mvn j2objc:convert.

Once you want to try a snapshot version, don't forget to add the following section as well:

<pluginRepositories>
    <pluginRepository>
        <id>sonatype-nexus-snapshots</id>
        <name>sonatype-nexus-snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </pluginRepository>
</pluginRepositories>
...
<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.5-SNAPSHOT</version>
    <configuration>
        <j2objcPath>path/to/j2objc</j2objcPath>
    </configuration>
</plugin>

Please note, that plugin supports Maven versions >= 3.1.x.

Usage

After you added the plugin to project, the only required parameter you have to specify is j2objcPath, which is path to J2ObjC's executable file. All the other plugin's parameters are proxies of J2ObjC's original parameters.

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <j2objcPath>${J2OBJC_DISTRIBUTION}/j2objc</j2objcPath>
        <useArc>true</useArc>
        <noPackageDirectories>true</noPackageDirectories>
        <!-- default value -->
        <sourcePath>${project.basedir}/src/main/java</sourcePath>
        <!-- default value -->
        <d>${project.build.directory}/j2objc</d>
    </configuration>
</plugin>

Full list of parameters you can find at J2ObjC library home page.

The example above shows how you can externalize the path to J2ObjC library. Don't forget to add the parameter definition to call: mvn j2objc:convert -DJ2OBJC_DISTRIBUTION=/folder/of/j2obc.

Sometimes, the code you want to convert to Objective-C contains dependencies, which should be converted as well. In this case you have to add all those dependencies into appropriate configuration section:

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <j2objcPath>${J2OBJC_DISTRIBUTION}/j2objc</j2objcPath>
        <useArc>true</useArc>
        <noPackageDirectories>true</noPackageDirectories>
        <dependencies>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>2.8.1</version>
            </dependency>
        </dependencies>
    </configuration>
</plugin>

This mechanism doesn't support nested dependencies recognition which means you have to specify every nested dependency separately. For example, joda-time library depends on joda-convert, so in order to have all the necessary dependencies in your Xcode project, you have to specify it as well:

<plugin>
    <groupId>com.smoope.utils</groupId>
    <artifactId>j2objc-maven-plugin</artifactId>
    <version>1.1.2</version>
    <configuration>
        <j2objcPath>${J2OBJC_DISTRIBUTION}/j2objc</j2objcPath>
        <useArc>true</useArc>
        <noPackageDirectories>true</noPackageDirectories>
        <dependencies>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>org.joda</groupId>
                <artifactId>joda-convert</artifactId>
                <version>1.8</version>
            </dependency>
            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>2.8.1</version>
            </dependency>
        </dependencies>
    </configuration>
</plugin>

Please note, that in order to make it work your local repository must contain the sources version of every dependency.

Advanced Options

Skip parent project

The configuration <skipParent>true</skipParent> in parent pom can be used to only translate child projects.

Fail on errors

By default the plugin will throw the exception in case of any error occured during the conversion. The configuration <failOnErrors>false</skipParent> prevents such behavior.

Translate dependencies only

<dependenciesOnly>true</dependenciesOnly> configuration allows to translate dependencies only and ignore the parent project.

com.smoope.utils

Smoope

Versions

Version
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.1
1.0.0