I'm new to IntelliJ and Java but I have a fair bit of TeamCity experience, mostly building .Net projects.
I have created a very simple Android Library project in IntelliJ with basically a single class that uses RxJava ( Reactive Extensions for Java ). I have added the Rx library in IntelliJ using Project Structure -> Libraries -> From Maven . The actual library I have added is com.netflix.rxjava:rxjava-android:0.19.6
which pulls in com.netflix.rxjava:rxjava-core:0.19.6
.
This works brilliantly and my project compiles within IntelliJ without even having to install Maven. Nice job, JetBrains.
However, when I try to build the project in TeamCity using the IntelliJ-IDEA runner, the project doesn't compile. Bad JetBrains!
I get errors on all the references to rx.*
, which as I said all worked perfectly on my workstation. The errors from TeamCity look like this:
C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:3: package rx does not exist import rx.Observable; ^ C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:4: package rx.subjects does not exist import rx.subjects.BehaviorSubject; ^ C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:18: cannot find symbol symbol: class BehaviorSubject location: class com.example.TigraAndroidUtilities.ObservableModel private BehaviorSubject modelStream; ^ C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:63: cannot find symbol symbol: class Observable location: class com.example.TigraAndroidUtilities.ObservableModel public Observable toObservable() ^ C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:28: cannot find symbol symbol: variable BehaviorSubject location: class com.example.TigraAndroidUtilities.ObservableModel modelStream = BehaviorSubject.create(modelData); ^ C:\BuildAgent\work\eefd62e2c3082b56\src\com\example\TigraAndroidUtilities\ObservableModel.java:65: cannot find symbol symbol: variable Observable location: class com.example.TigraAndroidUtilities.ObservableModel if (completed) { return Observable.empty(); } ^
Here's what I've tried:
This is all a bit frustrating, I've been tinkering with it hours but nothing seems to work and basically I have no clue what I'm doing wrong. I must have missed something somewhere. How can I get this build working properly in TeamCity?
As of TeamCity 9.1 , its IDEA runner can't build Maven modules any longer, nor can it auto-download external artifacts from Maven Central .
Basically, what you need is:
Download external artifacts, one by one, using TeamCity Maven runner and maven-dependency-plugin
, as described in this answer., eg:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:get com.netflix.rxjava:rxjava-android:0.19.6
You'll need as many Maven build steps as the number of dependencies in your IDEA project, and these steps must precede the IDEA runner build step.
At the build configuration level, set the system.path.macro.MAVEN.REPOSITORY
system property to %env.HOME%/.m2/repository
.
That's it.
Happy building!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.