Build one jar per platform for multi-platform SWT application

后端 未结 1 1249
清酒与你
清酒与你 2020-12-03 16:39

There are a couple of questions to this topic already, but none of them seem to work properly.

Here is a list of them:

  • Bulding an multi-platform SWT ap
1条回答
  •  时光取名叫无心
    2020-12-03 17:05

    Right, so I finally came up with a solution that I successfully tested on three platforms.

    The two magic components are the jar-in-jar-loader and a proper build script.

    The build script with comments can be found here:

    
    
        
    
        
        
        
        
        
        
        
        
    
        
        
    
        
            
        
    
        
        
            
            
        
    
        
        
            
        
    
        
        
            
            
        
    
        
            
            
            
                
                    
                    
                    
                        
                            
                            
                        
                    
                
            
        
    
        
        
            
            
            
            
            
            
            
            
            
            
            
            
    
            
        
    
        
            
            
            
                
                    
                        
                        
                        
                        
                    
    
                    
                    
                    
                
            
        
    
        
        
            
            
            
            
            
            
            
            
            
            
            
            
        
    
        
    
    
    

    What it basically does is define a base classpath without any SWT library. Then it creates platform specific classpaths using the base one and adding the appropriate platform SWT library.

    The jar task then creates a separate jar for each platform using these classpaths and the jar-in-jar-loader.

    And that's it, a fully automated way of generating jars for each (supported) platform.


    I've created an example project that people can download and test out. It's an easy starting point for a multi-platform application.

    https://www.dropbox.com/s/ianrbl4bn0fmsdi/SWTApplication.7z


    Update:

    I've managed to significantly shorten the ant script by making proper use of macrodef :)

    0 讨论(0)
提交回复
热议问题