Commit d6a0f546 authored by Tommy Olofsson's avatar Tommy Olofsson
Browse files

Added config to build and deploy 2014 as a bundle using maven.

parent 95aef48f
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>se.lth.control</groupId>
<artifactId>labcomm</artifactId>
<name>LabComm</name>
<version>2014.3.0-SNAPSHOT</version>
<description>Java implementation of the LabComm library.</description>
<packaging>bundle</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!-- Not default maven tree. -->
<sourceDirectory>.</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Description>${project.description}</Bundle-Description>
<Import-Package>
*
</Import-Package>
<Export-Package>
se.lth.control.labcomm
</Export-Package>
<Embed-Dependency>
*;scope=compile|runtime;type=!pom;
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<!-- Building version 2014 only. -->
<includes><include>se/lth/control/labcomm/**</include></includes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>CSLTH</id>
<name>CS LTH maven repo</name>
<url>http://maven.cs.lth.se/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>CS LTH snapshots maven repo</name>
<url>http://maven.cs.lth.se/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>releases</id>
<name>CS LTH release maven repo</name>
<url>http://maven.cs.lth.se/content/repositories/releases</url>
</repository>
</distributionManagement>
</project>
  • I'll need a lecture on maven...

  • If you have an account on the Nexus server you basically do mvn deploy to compile, package, and upload the bundle to the server.

    If a project depends on labcomm2014.jar it includes

    <dependency>
      <groupId>se.lth.control</groupId>
      <artifactId>labcomm</artifactId>
      <version>2014.3.0-SNAPSHOT</version>
    </dependency>

    in its build file instead of having to build and package the jar. (Or more likely, hope that everybody have compatible jars lying around on their machines...)

    If a project is run in an OSGi runtime which knows about the bundle repository in will get it resolved automatically as well.

  • 'the Nexus server'? http://maven.cs.lth.se/content/repositories/snapshot? how long do we need to support versions in the snapshot directory, ...

  • Snapshots? Not at all. I suppose we could upload one in releases/ for each future version tag in git repo? Just to keep the versions consistent across the board.

  • And maybe a maven plugin for the compiler as well... :)

    This is what I had to do to run the compiler because I really did not want to commit generated code (in another project):

          <!-- Create proper labcomm plugin? -->
          <plugin>                                                                                                                                                                                                                                                          
            <groupId>org.codehaus.mojo</groupId>                                                                                                                                                                                                                            
            <artifactId>build-helper-maven-plugin</artifactId>                                                                                                                                                                                                              
            <executions>                                                                                                                                                                                                                                                    
              <execution>                                                                                                                                                                                                                                                   
                <phase>generate-sources</phase>                                                                                                                                                                                                                             
                <goals>                                                                                                                                                                                                                                                     
                  <goal>add-source</goal>                                                                                                                                                                                                                                   
                </goals>                                                                                                                                                                                                                                                    
                <configuration>                                                                                                                                                                                                                                             
                  <sources>                                                                                                                                                                                                                                                 
                    <source>${project.build.directory}/generated-sources</source>                                                                                                                                                                                           
                  </sources>                                                                                                                                                                                                                                                
                </configuration>                                                                                                                                                                                                                                            
              </execution>                                                                                                                                                                                                                                                  
            </executions>                                                                                                                                                                                                                                                   
          </plugin>                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                            
          <plugin>                                                                                                                                                                                                                                                          
            <artifactId>exec-maven-plugin</artifactId>                                                                                                                                                                                                                      
            <groupId>org.codehaus.mojo</groupId>                                                                                                                                                                                                                            
            <executions>                                                                                                                                                                                                                                                    
              <execution>                                                                                                                                                                                                                                                   
                <id>Run LabComm compiler</id>                                                                                                                                                                                                                               
                <phase>generate-sources</phase>                                                                                                                                                                                                                             
                <goals>                                                                                                                                                                                                                                                     
                  <goal>exec</goal>                                                                                                                                                                                                                                         
                </goals>                                                                                                                                                                                                                                                    
                <configuration>                                                                                                                                                                                                                                             
                  <executable>                                                                                                                                                                                                                                              
                    ${basedir}/lib/run_labcomm_compiler.sh                                                                                                                                                                                                                  
                  </executable>                                                                                                                                                                                                                                             
                </configuration>                                                                                                                                                                                                                                            
              </execution>                                                                                                                                                                                                                                                  
            </executions>                                                                                                                                                                                                                                                   
          </plugin>

    and

    #!/usr/bin/env bash
    java -jar ../labcomm/compiler/labcomm2014_compiler.jar --java=target/generated-sources --javapackage=generated_sources ../labcomm-switch/metadata.lc 2>&1 1> /dev/null

    But that is a later problem. Makefiles are simpler...

Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment