lefou / mill-aspectj

AspectJ compiler/weaver support for mill build tool

GitHub

mill-aspectj - AspectJ compiler support for mill

Quickstart

Mill version 0.6.0 or newer is required.

import mill._
import mill.scalalib._
import mill.define._

// Load the plugin from Maven Central via ivy/coursier
import $ivy.`de.tototec::de.tobiasroeser.mill.aspectj:0.3.1`, de.tobiasroeser.mill.aspectj._

object main extends AspectjModule {

  // Select the AspectJ version
  def aspectjVersion = T{ "1.9.5" }

  // Set AspectJ options, e.g. the language level and annotation processor
  // Run `mill main.ajcHelp` to get a list of supported options
  def ajcOptions = Seq("-8", "-proc:none")

}

Configuration

Your module needs to extend de.tobiasroeser.mill.aspectj.AspectjModule which itself extends mill.scalalib.JavaModule.

The module trait de.tobiasroeser.mill.aspectj.AspectjModule has the following configuration options (over those from mill.scalalib.JavaModule).

def aspectjVersion: T[String]

The AspectJ version. Required. For a list of available releases refer to the AspectJ Download Page.

def ivyDeps: T[Agg[Dep]]

The compile and runtime dependencies. Contains by default the aspectjrt.jar which is resolved via ivy (ivy"org.aspectj:aspectjrt:${aspectjVersion()}"). If you do do not use super.ivyDeps() when overriding this def, you need to provide the aspectjrt.jar manually.

def aspectjToolsDeps: T[Agg[Dep]]

The ivy dependencies representing the aspectj compiler classes, which is typically a aspectjtools.jar. Default to ivy"org.aspectj:aspectjtools:${aspectjVersion()}".

def aspectjToolsClasspath: T[Agg[PathRef]]

The aspectj compiler classpath. By default resolved from aspectjToolsDeps.

def ajcOptions: T[Seq[String]]

Additional options to be used by ajc in the compile target.

def aspectPath: T[Agg[PathRef]]

Additional classes, JARs or ZIPs to be used as aspect path (ajc -aspectpath). In most cases it is enough to use aspectModuleDeps and aspectIvyDeps.

def aspectModuleDeps: Seq[JavaModule]

List of modules to be used as aspect path (ajc -aspectpath).

def aspectIvyDeps: T[Agg[Dep]]

List of ivy dependencies to be used as aspect path (ajc -aspectpath).

def effectiveAspectPath: T[Seq[PathRef]]

Effective aspect path (ajc -inpath). In most cases, it is enough to use aspectModuleDeps and aspectIvyDeps.

def weavePath: T[Seq[PathRef]]

List of directories with .class files to weave (into target directory). Corresponds to ajc -inpath option.

def compile: T[CompilationResult]

Compiles the source code with the ajc compiler.

def ajcHelp: Command[Unit]

Shows the help of the AspectJ compiler (ajc -help).

Version Compatibility Matrix

Mill is still in active development, and has no stable API yet. Hence, not all mill-aspectj versions work with every mill version.

The following table shows a matrix of compatible mill and mill-aspectj versions.

Table 1. Version Compatibility Matrix
mill-aspectj mill

{main}

0.6.0 - 0.6.3, 0.7.0 - 0.7.3

0.3.0

0.6.0 - 0.6.3

0.2.2

0.6.0 - 0.6.3

0.2.1

0.5.8 - 0.5.9

0.2.0

0.5.7

0.1.0

0.3.6 - 0.5.3

Download

You can download binary releases from Maven Central.

License

This project is published under the Apache License, Version 2.0.

Supporters

Thanks to iba Consulting Gesellschaft mbH & Co KG for the initial development support.

About

mill

Mill is a Scala-based open source build tool. In my opinion the best build tool for the JVM. It is fast, reliable and easy to understand.

me

I’m a professional software developer and love to do open source. I’m actively developing and maintaining mill as well as several mill plugins.

If you like my work, please star it on GitHub. You can also support me via GitHub Sponsors.

Contributing

If you found a bug or have a feature request, please open a new issue on GitHub. I also accept pull requests on GitHub.

Changelog

{main}

mill-aspectj 0.3.1 - 2020-06-15

  • Support for mill API 0.7.x and Scala 2.13

  • Switch to GitHub Actions workflow and removed Travis CI setup

  • Enabled auto-deployment of tagged and snapshot releases to Maven Central

mill-aspectj 0.3.0 - 2020-03-04

  • Splitted out new api and worker package to access Aspectj Java API instead of reflection

  • Removed need to use a Java SecurityManager to trap System.exit() calls

  • Made concurrent runs of the compiler configurable

  • Fixed ajcHelp task

  • Support for Java 11 and others

mill-aspectj 0.2.2 - 2020-02-24

  • Version bump mill API to 0.6.0

mill-aspectj 0.2.1 - 2020-02-24

  • Version bump mill API to 0.5.8

mill-aspectj 0.2.0 - 2020-01-08

  • Share ajc compiler instance between module

  • Version bump mill API to 0.5.7

mill-aspectj 0.1.0 - 2019-08-30

  • Initial public release