Configuring the plugin


#1

After installing the plugin, I get an entry in the project view for "New Kotlin file". Selecting this, and pasting some example code, still causes the calls to system libraries to be unresolved.

In the comments of the Kotlin blog, it’s mentioned that the plugin will set up the required dependencies automatically.
However, for me this does not happen. Perhaps this is caused by the current project being a Maven-based one?


#2

First thing to check is your IntelliJ IDEA version. It should be the latest EAP of 11.1. Is it?

BTW: do you have anything like the “Configuring Kotlin Runtime…” bar appear at the top of your editor when opening a Kotlin file?
See this video:
http://www.youtube.com/watch?feature=player_embedded&v=0jBPcIPVihI


#3

It works when adding a Kotlin file to a blank Java module, created from scratch.

It does not work when adding a Kotlin file to an existing Maven module.
While the file gets created, the editor popup does not appear.

Not a big deal at this point in time though :slight_smile:


#4

I'm interested in this question, too.  

I start with a Maven project, I add Evgeny Goldin’s plugin

http://evgeny-goldin.com/wiki/Kotlin-maven-plugin

to the existing POM, I create manually src/[main,test]/kotlin, and add a Kotlin file to src/main/kotlin that uses stdlib (say, println()).  I’m including my POM as a reference.  It seems like we should add the kotlin runtime as at least a Maven “provided” scope dependency.  So I did this by doing a manual install-jar operation within maven to install the kotlin runtime to the local repository.  Then add the runtime as a dependency – I used version 1.0 for the runtime because it was easy to type :slight_smile:

I also have a Java main class defined that instantiates a Kotlin class which contains a function that prints “hello”.  This much works for me when I run the app from within the IDE using App#main as an entry point.

I do notice that once in a while, IJ will unmark src/[main,test]/kotlin as source roots.  Not sure what is going on there.  

Here is my POM:

<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/xsd/maven-4.0.0.xsd">   <modelVersion>4.0.0</modelVersion>

  <groupId>org.petrovic</groupId>
  <artifactId>mailchimp-kotlin</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mailchimp-kotlin</name>
  <url>http://maven.apache.org</url&gt;

  <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencyManagement>
  <dependencies>
           <dependency>
           <groupId>net.mailjimp</groupId>
           <artifactId>mailjimp-core</artifactId>
           <version>0.4-SNAPSHOT</version>
           </dependency>
           <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <version>4.8.2</version>
           <scope>test</scope>
           </dependency>
  </dependencies>
  </dependencyManagement>

  <build>
  <pluginManagement>
           <plugins>
           <plugin>
                   <groupId>com.goldin.plugins</groupId>
                   <artifactId>kotlin-maven-plugin</artifactId>
                   <version>0.2.3.8-beta-6</version>
                   <executions>
                   <execution>
                           <id>compile-kotlin-sources</id>
                           <goals>
                           <goal>compile</goal>
                           <goal>testCompile</goal>
                           </goals>
                           <configuration>
                           <src>{project.basedir}/src/main/kotlin&lt;/src&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;output&gt;{project.build.outputDirectory}</output>
                           </configuration>
                   </execution>
                   </executions>
           </plugin>
           </plugins>
  </pluginManagement>
  <plugins>
           <plugin>
           <groupId>com.goldin.plugins</groupId>
           <artifactId>kotlin-maven-plugin</artifactId>
           </plugin>
  </plugins>
  </build>

  <dependencies>
  <dependency>
           <groupId>net.mailjimp</groupId>
           <artifactId>mailjimp-core</artifactId>
  </dependency>
  <dependency>
           <!-- manually added the runtime to mvn repo using rt jar from another newly created kt project -->
           <groupId>com.jetbrains</groupId>
           <artifactId>kotlin-runtime</artifactId>
           <version>1.0</version>
  </dependency>
  <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <scope>test</scope>
  </dependency>
  </dependencies>

  <pluginRepositories>
  <pluginRepository>
           <id>kotlin plugin repo</id>
           <url>http://evgeny-goldin.org/artifactory/repo/</url&gt;
  </pluginRepository>
  </pluginRepositories>
</project>


Here is my main Java class:
package org.petrovic.mailchimp;

import mailjimp.dom.response.list.MailingList;
import mailjimp.service.MailJimpException;
import mailjimp.service.impl.MailJimpJsonService;

import java.util.List;

public class App {
  public static void main(String[] args) throws MailJimpException {
  App app = new App();
  app.run();
  }

  private void run() throws MailJimpException {
  String userName = “blah”;
  String password = “foo”;
  String apiKey = “thekey”;
  String apiVersion = “1.3”;
  boolean ssl = false;
  MailJimpJsonService mailJimpJsonService = new MailJimpJsonService(userName, password, apiKey, apiVersion, ssl);
  mailJimpJsonService.init();
  List<MailingList> lists = mailJimpJsonService.lists();
  for (MailingList list : lists) {
           System.out.println(list);
  }

  &nbsp;&nbsp;ChimpUtils c = new ChimpUtils(1);
  &nbsp;&nbsp;c.foo();

  }
}

And here is the Kotlin class:

package org.petrovic.mailchimp

class ChimpUtils(param : Int) {
  val property = param

  fun foo() {
  println(“hello”)
  }
}

I have no idea if I’m using the “package” statement correctly in the Kotlin file.  It feels like I may be lugging some Java paradigms into a realm where I may not need them?  Maybe not.  I need to read the docs.  Seems like I should know something about Kotlin modules before going much further.

Anyway, within a couple hours of downloading IJ EAP 11.1 and reading E. Goldin’s maven plugin post, I got ‘hello’ working from the IDE.

But I still cannot compile the app from the command line using mvn - I need to study the plugin config a bit more:  the compiler cannot resolve the Kotlin class from within the Java class.  Maybe it’s a maven compile-phase issue.

> mvn clean compile [INFO] Scanning for projects... [INFO]                                                                    [INFO] ------------------------------------------------------------------------ [INFO] Building mailchimp-kotlin 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ mailchimp-kotlin --- [INFO] Deleting /Users/petrovic/Projects/mailchimp-kotlin/target [INFO] [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ mailchimp-kotlin --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/petrovic/Projects/mailchimp-kotlin/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mailchimp-kotlin --- [INFO] Compiling 1 source file to /Users/petrovic/Projects/mailchimp-kotlin/target/classes [INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /Users/petrovic/Projects/mailchimp-kotlin/src/main/java/org/petrovic/mailchimp/App.java:[28,8] cannot find symbol symbol  : class ChimpUtils location: class org.petrovic.mailchimp.App [ERROR] /Users/petrovic/Projects/mailchimp-kotlin/src/main/java/org/petrovic/mailchimp/App.java:[28,27] cannot find symbol symbol  : class ChimpUtils location: class org.petrovic.mailchimp.App [INFO] 2 errors [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.432s [INFO] Finished at: Mon Feb 27 07:51:51 PST 2012 [INFO] Final Memory: 9M/81M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project mailchimp-kotlin: Compilation failure: Compilation failure: [ERROR] /Users/petrovic/Projects/mailchimp-kotlin/src/main/java/org/petrovic/mailchimp/App.java:[28,8] cannot find symbol [ERROR] symbol  : class ChimpUtils [ERROR] location: class org.petrovic.mailchimp.App [ERROR] /Users/petrovic/Projects/mailchimp-kotlin/src/main/java/org/petrovic/mailchimp/App.java:[28,27] cannot find symbol [ERROR] symbol  : class ChimpUtils [ERROR] location: class org.petrovic.mailchimp.App [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
hth

Mark


#5

Hi Mark, In order to compile Java sources using Kotlin libraries you need to use an "ivy-maven-plugin" that downloads Kotlin dependencies from TeamCity and adds them to Maven's "compile" scope. An example to that can be found in Kotlin GitHub repo, "kdoc" sub-project.  Can you try doing the same and let us know? I see this question is becoming common so I'll add this scenario to plugin's Wiki. Also, the work is being done on deploying Kotlin artifacts to Maven repository, this will eliminate the need in using "ivy-maven-plugin" and will allow to use Kotlin runtime as a regular Maven <dependency>.


#6

I hope this answers the question about adding Kotlin dependencies to the compilation classpath. Btw, if you follow "kdoc" example linked above it means you need to remove the Kotlin <dependency> you have added:

<dependency>   <groupId>com.jetbrains</groupId>   <artifactId>kotlin-runtime</artifactId>   <version>1.0</version> </dependency>

As about compiling Java sources with Kotlin-compiled classes I'll try to provide a sample example later today.

#7

Ah, that could be easier than I thought :) In your case Maven attempts to compile Java sources before Kotlin sources are compiled. Can you try setting Kotlin's plugin phase to, say, "process-resources" ?

<id>compile-kotlin-sources</id>
<goals>
  <goal>compile</goal>
  <goal>testCompile</goal>
</goals>
<phase>process-resources</phase>


This will ensure that Kotlin compilation runs before “compile” phase.


#8

Yep, running the Kotlin compiler plugin in an earlier phase did the trick:

<pre>

  &nbsp;&nbsp;&lt;pluginManagement&gt;

           <plugins>
           <plugin>
                   <groupId>com.goldin.plugins</groupId>
                   <artifactId>kotlin-maven-plugin</artifactId>
                   <version>0.2.3.8-beta-6</version>
                   <executions>
                   <execution>
                           <id>compile-kotlin-sources</id>
                           <goals>
                           <goal>compile</goal>
                           <goal>testCompile</goal>
                           </goals>
                           <phase>process-resources</phase>
                           <configuration>
                           <src>{project.basedir}/src/main/kotlin&lt;/src&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;output&gt;{project.build.outputDirectory}</output>
                           </configuration>
                   </execution>
                   </executions>
           </plugin>
           </plugins>
  </pluginManagement>

</pre>

Genie wrote:

Ah, that could be easier than I thought :slight_smile: In your case Maven attempts to compile Java sources before Kotlin sources are compiled. Can you try setting Kotlin’s plugin phase to, say, “process-resources” ?

<id>compile-kotlin-sources</id>
<goals>
  <goal>compile</goal>
  <goal>testCompile</goal>
</goals>
<phase>process-resources</phase>


This will ensure that Kotlin compilation runs before “compile” phase.


#9

Excellent, glad it worked for you!


#10

Hallo

Yep, running the Kotlin compiler plugin in an earlier phase did the trick:

But what if you have Kotlin classes that depend on Java classes and the other way around? Maybe even only two classes that depend on one another. Is that supported, too? Currently I get "Unresolved reference FooBar" whatever I try.

bye,

-christian-


#11

Genie wrote:

Hi Mark,


In order to compile Java sources using Kotlin libraries you need to use an “ivy-maven-plugin” that downloads Kotlin dependencies from TeamCity and adds them to Maven’s “compile” scope. An example to that can be found in Kotlin GitHub repo, “kdoc” sub-project.  Can you try doing the same and let us know? I see this question is becoming common so I’ll add this scenario to plugin’s Wiki.


Also, the work is being done on deploying Kotlin artifacts to Maven repository, this will eliminate the need in using “ivy-maven-plugin” and will allow to use Kotlin runtime as a regular Maven <dependency>.


How do I keep up with the progress of the Kotlin runtime artifacts being deployed to a well-known Maven repository?

Thanks!


#12

Genie wrote:

Hi Mark,


In order to compile Java sources using Kotlin libraries you need to use an “ivy-maven-plugin” that downloads Kotlin dependencies from TeamCity and adds them to Maven’s “compile” scope. An example to that can be found in Kotlin GitHub repo, “kdoc” sub-project.  Can you try doing the same and let us know? I see this question is becoming common so I’ll add this scenario to plugin’s Wiki.


Also, the work is being done on deploying Kotlin artifacts to Maven repository, this will eliminate the need in using “ivy-maven-plugin” and will allow to use Kotlin runtime as a regular Maven <dependency>.


I’m quite impressed – using the kdoc trick worked :slight_smile:   And I removed the Maven <dependency> on the kotlin-runtime in my POM.

One odd effect, however:  I can buld and run the project from the command line with something like

mvn clean compile exec:java -Dexec.mainClass=“namespace” -Dexec.args=“foolist”

But when I try to “Run namespace” within the IDE, the IDE fails to run with a “StackOverflow” error in the bottom border of the window.  Not good :slight_smile:

Anyway, my POM:

<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/xsd/maven-4.0.0.xsd">   <modelVersion>4.0.0</modelVersion>

  <groupId>org.petrovic</groupId>
  <artifactId>mailchimp-kotlin</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mailchimp-kotlin</name>
  <url>http://maven.apache.org</url&gt;

  <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <kotlin-maven-plugin.version>0.2.3.8-beta-6</kotlin-maven-plugin.version>
  <mailjimp.version>0.4-SNAPSHOT</mailjimp.version>
  </properties>

  <dependencyManagement>
  <dependencies>
           <dependency>
           <groupId>net.mailjimp</groupId>
           <artifactId>mailjimp-core</artifactId>
           <version>${mailjimp.version}</version>
           </dependency>
           <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <version>4.8.2</version>
           <scope>test</scope>
           </dependency>
  </dependencies>
  </dependencyManagement>

  <build>
  <sourceDirectory>src/main/kotlin</sourceDirectory>
  <testSourceDirectory>src/test/kotlin</testSourceDirectory>
  <pluginManagement>
           <plugins>
           <plugin>
                   <groupId>com.goldin.plugins</groupId>
                   <artifactId>kotlin-maven-plugin</artifactId>
                   <version>{kotlin-maven-plugin.version}&lt;/version&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;executions&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;execution&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;/plugin&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;plugin&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;groupId&gt;com.goldin.plugins&lt;/groupId&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;artifactId&gt;ivy-maven-plugin&lt;/artifactId&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;version&gt;{kotlin-maven-plugin.version}</version>
                   <executions>
                   <execution>
                           <id>add-ivy-dependencies</id>
                           <goals>
                           <goal>ivy</goal>
                           </goals>
                           <phase>initialize</phase>
                           <configuration>
                           <ivyconf>{project.basedir}/src/main/resources/ivyconf.xml&lt;/ivyconf&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;dependencies&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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&lt;/verbose&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;/configuration&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;/execution&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;/executions&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;/plugin&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;/plugins&gt; &nbsp;&nbsp;&lt;/pluginManagement&gt; &nbsp;&nbsp;&lt;plugins&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;plugin&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;groupId&gt;com.goldin.plugins&lt;/groupId&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;artifactId&gt;ivy-maven-plugin&lt;/artifactId&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&lt;version&gt;{kotlin-maven-plugin.version}</version>
           </plugin>
           <plugin>
           <groupId>com.goldin.plugins</groupId>
           <artifactId>kotlin-maven-plugin</artifactId>
           </plugin>
  </plugins>
  </build>

  <dependencies>
  <dependency>
           <groupId>net.mailjimp</groupId>
           <artifactId>mailjimp-core</artifactId>
  </dependency>
  <dependency>
           <groupId>junit</groupId>
           <artifactId>junit</artifactId>
           <scope>test</scope>
  </dependency>
  </dependencies>

  <pluginRepositories>
  <pluginRepository>
           <id>kotlin plugin repo</id>
           <url>http://evgeny-goldin.org/artifactory/repo/</url&gt;
  </pluginRepository>
  </pluginRepositories>
</project>


#13

Woops.  Using the kdoc trick, which includes removing the <dependency> on the Kotlin runtime in the POM, deprives the IDE of println resolution.  See the attached screenshot.



kotlin-stdio.png (173 KB)

#14

Hi Christian, No, joint Java/Kotlin compilation isn't supported right now, as far as I know.


#15

http://youtrack.jetbrains.com/issue/KT-1472 is the issue to follow.


#16

As long as Kotlin is only available in TeamCity Ivy repo, we can only fool Maven by adding it through "ivy-kotlin-plugin" <dependencies>, not a real Maven <dependencies>. This solves the Maven compilation issue but it makes IDEA unaware of the workaround made so it doesn't see the Kotlin library. To make it aware of Kotlin, I add Kotlin manually as project's library: File => Project Structure => Libraries => "+" => Java => point to .ivy2 cache in your home directory where Kotlin binaries are downloaded to (see the screenshot attached). Once we have the Maven repo available all those inconveniences should go away.



ScreenShot001.png (33.1 KB)

#17

Just voted for it.


#18

For fun, I added the maven shade plugin to the POM.  You have to keep an eye on the output in the uber jar, but the shade plugin can often be real handy.  When you add the shade plugin, you can do stuff like this to run the app:

$ java  -cp target/mailchimp-kotlin-1.0-SNAPSHOT-shaded-uber.jar namespace

Here’s the POM snippet:

  <plugins>            <plugin>            <groupId>com.goldin.plugins</groupId>            <artifactId>ivy-maven-plugin</artifactId>            <version>${kotlin-maven-plugin.version}</version>            </plugin>            <plugin>            <groupId>com.goldin.plugins</groupId>            <artifactId>kotlin-maven-plugin</artifactId>            </plugin>            <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-shade-plugin</artifactId>            <version>1.4</version>            <executions>                    <execution>                    <phase>package</phase>                    <goals>                            <goal>shade</goal>                    </goals>                    <configuration>                            <shadedArtifactAttached>true</shadedArtifactAttached>                            <shadedClassifierName>shaded-uber</shadedClassifierName>                            <transformers>                            <!-- Concatenate the META-INF/services entries for each input jar -->                            <transformer                                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"                                    />                            </transformers>                    </configuration>                    </execution>            </executions>            </plugin>   </plugins>


#19

I created a github repo that holds this work in progress:

git@github.com:ae6rt/mailchimp-kotlin.git

I can’t run the app from within the IDE, and I don’t know why.  I based the creation of the IDEA project on the Maven POM.  Whenever I try to run it in IDEA, I get a StackOverflow message in the IDE bottom tray.  I may be doing something silly.

But you can run the app from the command line:

mvn compile exec:java -Dexec.mainClass=“namespace” -Dexec.args="–list somelist --since ‘2013-12-12 23:21:33’"

To run the app for full effect, you need a MailChimp account, at least one mailing list, and at least one user on that list who has unsubscribed since some known date.  Add your MailChimp credentials to src/main/resources/mailchimp.properties before you run.

http://mailchimp.com/