buildr-iidea 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +12 -0
 - data/README.rdoc +43 -25
 - data/buildr-iidea.gemspec +3 -1
 - data/lib/buildr/intellij_idea/idea_module.rb +63 -30
 - data/lib/buildr/intellij_idea/project_extension.rb +9 -4
 - data/lib/buildr/intellij_idea/version.rb +11 -0
 - data/lib/buildr_iidea.rb +1 -0
 - data/spec/buildr/intellij_idea/dependency_spec.rb +35 -4
 - data/spec/buildr/intellij_idea/module_content_generation_spec.rb +76 -0
 - data/spec/buildr/intellij_idea/project_extension_spec.rb +65 -0
 - data/spec/spec_helper.rb +11 -2
 - metadata +6 -4
 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            0.0.5 (June 5, 2010)
         
     | 
| 
      
 2 
     | 
    
         
            +
            * Changed: The documentation indicated that the iml.local_repository_env_override value
         
     | 
| 
      
 3 
     | 
    
         
            +
              defaulted to nil while the code defaulted the value to M2_REPO. The code was changed to
         
     | 
| 
      
 4 
     | 
    
         
            +
              Use $MAVEN_REPOSITORY$ to match the behaviour of IDEA 9.x.
         
     | 
| 
      
 5 
     | 
    
         
            +
            * Added: Dependencies that are not in the maven repository or in projects where
         
     | 
| 
      
 6 
     | 
    
         
            +
              iml.local_repository_env_override is set nil will now have paths relative to the
         
     | 
| 
      
 7 
     | 
    
         
            +
              module directory.
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Added: Ability to disable generation of content section using iml.skip_content!
         
     | 
| 
      
 9 
     | 
    
         
            +
            * Fixed: A project which is tagged with no_iml may have a child with an IML.
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Changed: Directories that are outside content dir are no longer excluded in the content
         
     | 
| 
      
 11 
     | 
    
         
            +
              section.
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       1 
13 
     | 
    
         
             
            0.0.4 (May 29, 2010)
         
     | 
| 
       2 
14 
     | 
    
         
             
            * Added: Ability to disable ipr generation using project.no_ipr
         
     | 
| 
       3 
15 
     | 
    
         
             
            * Added: Documented the ability to disable the generation of iml files via project.no_iml 
         
     | 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -4,7 +4,7 @@ This extension provides tasks to generate Intellij IDEA project files by issuing 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              $ buildr iidea:generate
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
            This task will generate an .iml file for every project (or  
     | 
| 
      
 7 
     | 
    
         
            +
            This task will generate an .iml file for every project (or sub-project) and a .ipr
         
     | 
| 
       8 
8 
     | 
    
         
             
            that you can directly open for the root project.
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            The generated project files can be removed by issuing;
         
     | 
| 
         @@ -14,14 +14,16 @@ The generated project files can be removed by issuing; 
     | 
|
| 
       14 
14 
     | 
    
         
             
            The iidea task generates the project files based on the settings of each project and
         
     | 
| 
       15 
15 
     | 
    
         
             
            extension specific settings. The main and test source trees are added to the .iml
         
     | 
| 
       16 
16 
     | 
    
         
             
            file for each project as are the respective resource directories. The target and report
         
     | 
| 
       17 
     | 
    
         
            -
            directories are excluded from the project. If the project files exist on the  
     | 
| 
      
 17 
     | 
    
         
            +
            directories are excluded from the project. If the project files exist on the file system
         
     | 
| 
       18 
18 
     | 
    
         
             
            the extension will replace specific component sections in the xml with the generated
         
     | 
| 
       19 
19 
     | 
    
         
             
            component configurations.
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            Dependencies come in two forms. Dependencies on other projects and dependencies on
         
     | 
| 
       22 
22 
     | 
    
         
             
            external jars. Dependencies on other projects are added as module dependencies in the
         
     | 
| 
       23 
23 
     | 
    
         
             
            .iml while jars are added as regular file dependencies. Dependencies are exported from
         
     | 
| 
       24 
     | 
    
         
            -
            the .iml file if they are compile dependencies.
         
     | 
| 
      
 24 
     | 
    
         
            +
            the .iml file if they are compile dependencies. If a artifact that matches dependency but
         
     | 
| 
      
 25 
     | 
    
         
            +
            has a classifier of 'sources' is present then it is configured as the source for the
         
     | 
| 
      
 26 
     | 
    
         
            +
            dependency. Note: Use "buildr artifacts:sources" to download the source for dependencies.
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
28 
     | 
    
         
             
            == Installation
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
         @@ -43,12 +45,12 @@ The user then needs to add the following require into the build file: 
     | 
|
| 
       43 
45 
     | 
    
         
             
            === Warning
         
     | 
| 
       44 
46 
     | 
    
         | 
| 
       45 
47 
     | 
    
         
             
            The iidea task may generate project files that conflict with the files generated by the
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
            built-in 'idea' and 'idea7x' tasks. As a result the built-in tasks would fail if ran while
         
     | 
| 
       47 
49 
     | 
    
         
             
            the extension is present. To avoid this problem the extension removes these tasks.
         
     | 
| 
       48 
50 
     | 
    
         | 
| 
       49 
51 
     | 
    
         
             
            == Idea Specific Directives
         
     | 
| 
       50 
52 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            The extension specific settings of  
     | 
| 
      
 53 
     | 
    
         
            +
            The extension specific settings of sub-projects inherit the parent projects settings
         
     | 
| 
       52 
54 
     | 
    
         
             
            unless overwritten.
         
     | 
| 
       53 
55 
     | 
    
         | 
| 
       54 
56 
     | 
    
         
             
            === Project file naming
         
     | 
| 
         @@ -57,8 +59,8 @@ The extension will use the last element of the projects name when generating the 
     | 
|
| 
       57 
59 
     | 
    
         
             
            and .iml files. i.e. A project named "foo" will generate "foo.iml" and "foo.ipr" while
         
     | 
| 
       58 
60 
     | 
    
         
             
            a project named "foo:bar" will generate "bar/bar.iml" and no ipr. (The .ipr project
         
     | 
| 
       59 
61 
     | 
    
         
             
            files are only generated for base project). The name can be modified by setting the
         
     | 
| 
       60 
     | 
    
         
            -
            "ipr.suffix" or "iml.suffix"  
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
      
 62 
     | 
    
         
            +
            "ipr.suffix" or "iml.suffix" settings which specifies the suffix appended to the
         
     | 
| 
      
 63 
     | 
    
         
            +
            file names. The user can also override the name completely by setting "ipr.id" or "iml.id".
         
     | 
| 
       62 
64 
     | 
    
         | 
| 
       63 
65 
     | 
    
         
             
            ==== Example: Setting id
         
     | 
| 
       64 
66 
     | 
    
         | 
| 
         @@ -107,6 +109,19 @@ Will generate: 
     | 
|
| 
       107 
109 
     | 
    
         | 
| 
       108 
110 
     | 
    
         
             
              foo.iml
         
     | 
| 
       109 
111 
     | 
    
         | 
| 
      
 112 
     | 
    
         
            +
            === Disabling generation of content section in .iml file
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            The extension will not generate a content section in an iml file if the "iml.skip_content!" method
         
     | 
| 
      
 115 
     | 
    
         
            +
            is invoked. This can be useful if a project is just exporting dependencies and has no associated
         
     | 
| 
      
 116 
     | 
    
         
            +
            source code. This may also be of use in scenarios where the build is repackaging an existing jar with
         
     | 
| 
      
 117 
     | 
    
         
            +
            more meta-data or the project is just a container for other projects.
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            ==== Example
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
              define "foo" do
         
     | 
| 
      
 122 
     | 
    
         
            +
                iml.skip_content!
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
       110 
125 
     | 
    
         
             
            === VCS Integration
         
     | 
| 
       111 
126 
     | 
    
         | 
| 
       112 
127 
     | 
    
         
             
            The extension will attempt to guess the VCS type of the project by looking for a .svn
         
     | 
| 
         @@ -122,25 +137,36 @@ the project to one of either 'Git' or 'svn' using the ipr.vcs setting. 
     | 
|
| 
       122 
137 
     | 
    
         | 
| 
       123 
138 
     | 
    
         
             
            === Dependency generation
         
     | 
| 
       124 
139 
     | 
    
         | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
      
 140 
     | 
    
         
            +
            A file dependency that exists in the local maven 2 repository is stored in the IML file
         
     | 
| 
      
 141 
     | 
    
         
            +
            relative to the $MAVEN_REPOSITORY$ environment variable (that defaults to ~/.m2/repository).
         
     | 
| 
      
 142 
     | 
    
         
            +
            The user can override the environment variable by setting the "iml.local_repository_env_override"
         
     | 
| 
      
 143 
     | 
    
         
            +
            setting. If the dependency does not exist in to maven repository or the "iml.local_repository_env_override"
         
     | 
| 
      
 144 
     | 
    
         
            +
            setting is set to nil, then the path stored in the IML is relative to the IML file.
         
     | 
| 
       129 
145 
     | 
    
         | 
| 
       130 
146 
     | 
    
         
             
            ==== Example: Setting local_repository_env_override
         
     | 
| 
       131 
147 
     | 
    
         | 
| 
       132 
148 
     | 
    
         
             
              define "foo" do
         
     | 
| 
       133 
     | 
    
         
            -
                iml.local_repository_env_override =  
     | 
| 
      
 149 
     | 
    
         
            +
                iml.local_repository_env_override = nil
         
     | 
| 
       134 
150 
     | 
    
         
             
                compile.with 'group:id:jar:1.0'
         
     | 
| 
       135 
151 
     | 
    
         
             
              end
         
     | 
| 
       136 
152 
     | 
    
         | 
| 
       137 
153 
     | 
    
         
             
            Will generate a dependency with a path like:
         
     | 
| 
       138 
154 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
              jar 
     | 
| 
      
 155 
     | 
    
         
            +
              jar:///home/peter/.m2/repository/group/id/1.0/id-1.0.jar!/
         
     | 
| 
       140 
156 
     | 
    
         | 
| 
       141 
157 
     | 
    
         
             
            rather than the default
         
     | 
| 
       142 
158 
     | 
    
         | 
| 
       143 
     | 
    
         
            -
              jar 
     | 
| 
      
 159 
     | 
    
         
            +
              jar://$MAVEN_REPOSITORY$/group/id/1.0/id-1.0.jar!/
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
            ==== Example: A dependency outside the maven repository
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
              define "foo" do
         
     | 
| 
      
 164 
     | 
    
         
            +
                compile.with _("foos-dep.jar")
         
     | 
| 
      
 165 
     | 
    
         
            +
              end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
            Will generate a dependency with a path like:
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
              jar://$MODULE_DIR$/foo-dep.jar!/
         
     | 
| 
       144 
170 
     | 
    
         | 
| 
       145 
171 
     | 
    
         
             
            === Module Facets
         
     | 
| 
       146 
172 
     | 
    
         | 
| 
         @@ -149,7 +175,7 @@ core java. A facet can be added to a project so that it can be deployed as a web 
     | 
|
| 
       149 
175 
     | 
    
         
             
            or a hibernate application. A facet can also be used t provide support for other languages
         
     | 
| 
       150 
176 
     | 
    
         
             
            such as ruby and scala. The extension makes it possible to generate .iml with the appropriate
         
     | 
| 
       151 
177 
     | 
    
         
             
            facets via the "iml.add_facet" method. It should be noted that facets are NOT inherited by 
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
      
 178 
     | 
    
         
            +
            sub-projects.
         
     | 
| 
       153 
179 
     | 
    
         | 
| 
       154 
180 
     | 
    
         
             
            ==== Example
         
     | 
| 
       155 
181 
     | 
    
         | 
| 
         @@ -261,7 +287,7 @@ Will place the generated .imls in the following groups: 
     | 
|
| 
       261 
287 
     | 
    
         
             
            === Add Extra .iml files to .ipr
         
     | 
| 
       262 
288 
     | 
    
         | 
| 
       263 
289 
     | 
    
         
             
            The 'ipr.extra_modules' setting makes it possible to add extra modules to the generated iml file.
         
     | 
| 
       264 
     | 
    
         
            -
            The setting is an array of  
     | 
| 
      
 290 
     | 
    
         
            +
            The setting is an array of file names relative to the base project directory.
         
     | 
| 
       265 
291 
     | 
    
         | 
| 
       266 
292 
     | 
    
         
             
            ==== Example
         
     | 
| 
       267 
293 
     | 
    
         | 
| 
         @@ -283,7 +309,7 @@ jump in and supply a patch if you have gone ahead and implemented the feature. 
     | 
|
| 
       283 
309 
     | 
    
         | 
| 
       284 
310 
     | 
    
         
             
            === Auto-generate Web Facet
         
     | 
| 
       285 
311 
     | 
    
         | 
| 
       286 
     | 
    
         
            -
            Any project that defines a war package should have a web facet  
     | 
| 
      
 312 
     | 
    
         
            +
            Any project that defines a war package should have a web facet auto-generated for it.
         
     | 
| 
       287 
313 
     | 
    
         | 
| 
       288 
314 
     | 
    
         
             
            === Auto-generate Scala Facet
         
     | 
| 
       289 
315 
     | 
    
         | 
| 
         @@ -295,14 +321,6 @@ Add the ability for the module and project files to be generated off into a diff 
     | 
|
| 
       295 
321 
     | 
    
         
             
            directory hierarchy. i.e. Generate project modules into .idea_project in projects base
         
     | 
| 
       296 
322 
     | 
    
         
             
            directory.
         
     | 
| 
       297 
323 
     | 
    
         | 
| 
       298 
     | 
    
         
            -
            === Populate SOURCES and JAVADOC for dependencies
         
     | 
| 
       299 
     | 
    
         
            -
             
     | 
| 
       300 
     | 
    
         
            -
            Add tasks 'iidea:deps:sources:download' and 'iidea:deps:javadoc:download' that downloads
         
     | 
| 
       301 
     | 
    
         
            -
            missing :classifier => 'sources' and :classifier => 'javadoc' dependencies for all the
         
     | 
| 
       302 
     | 
    
         
            -
            :classifier => 'jar' dependencies in the project. When generating the project files the task
         
     | 
| 
       303 
     | 
    
         
            -
            should populate the SOURCES and JAVADOC if the relevant artifact is present in the local
         
     | 
| 
       304 
     | 
    
         
            -
            repository.
         
     | 
| 
       305 
     | 
    
         
            -
             
     | 
| 
       306 
324 
     | 
    
         
             
            === Fix tests to work when installed as a gem
         
     | 
| 
       307 
325 
     | 
    
         | 
| 
       308 
326 
     | 
    
         
             
            The library should determine whether it is installed as a gem and if so use the gem to
         
     | 
    
        data/buildr-iidea.gemspec
    CHANGED
    
    | 
         @@ -1,6 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/lib/buildr/intellij_idea/version')
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       2 
4 
     | 
    
         
             
              spec.name           = 'buildr-iidea'
         
     | 
| 
       3 
     | 
    
         
            -
              spec.version        =  
     | 
| 
      
 5 
     | 
    
         
            +
              spec.version        = Buildr::IntellijIdea::Version::STRING
         
     | 
| 
       4 
6 
     | 
    
         
             
              spec.authors        = ['Rhett Sutphin', 'Peter Donald']
         
     | 
| 
       5 
7 
     | 
    
         
             
              spec.email          = ["rhett@detailedbalance.net","peter@realityforge.org"]
         
     | 
| 
       6 
8 
     | 
    
         
             
              spec.homepage       = "http://github.com/realityforge/buildr-iidea"
         
     | 
| 
         @@ -2,10 +2,8 @@ module Buildr 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module IntellijIdea
         
     | 
| 
       3 
3 
     | 
    
         
             
                class IdeaModule < IdeaFile
         
     | 
| 
       4 
4 
     | 
    
         
             
                  DEFAULT_TYPE = "JAVA_MODULE"
         
     | 
| 
       5 
     | 
    
         
            -
                  DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE =  
     | 
| 
       6 
     | 
    
         
            -
                  MODULE_DIR_URL = "file://$MODULE_DIR$"
         
     | 
| 
      
 5 
     | 
    
         
            +
                  DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE = nil
         
     | 
| 
       7 
6 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  attr_writer :buildr_project
         
     | 
| 
       9 
7 
     | 
    
         
             
                  attr_accessor :type
         
     | 
| 
       10 
8 
     | 
    
         
             
                  attr_accessor :local_repository_env_override
         
     | 
| 
       11 
9 
     | 
    
         
             
                  attr_accessor :group
         
     | 
| 
         @@ -14,12 +12,12 @@ module Buildr 
     | 
|
| 
       14 
12 
     | 
    
         
             
                  def initialize
         
     | 
| 
       15 
13 
     | 
    
         
             
                    @type = DEFAULT_TYPE
         
     | 
| 
       16 
14 
     | 
    
         
             
                    @local_repository_env_override = DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE
         
     | 
| 
       17 
     | 
    
         
            -
                    @facets = []
         
     | 
| 
       18 
15 
     | 
    
         
             
                  end
         
     | 
| 
       19 
16 
     | 
    
         | 
| 
       20 
17 
     | 
    
         
             
                  def buildr_project=(buildr_project)
         
     | 
| 
       21 
18 
     | 
    
         
             
                    @id = nil
         
     | 
| 
       22 
19 
     | 
    
         
             
                    @facets = []
         
     | 
| 
      
 20 
     | 
    
         
            +
                    @skip_content = false
         
     | 
| 
       23 
21 
     | 
    
         
             
                    @buildr_project = buildr_project
         
     | 
| 
       24 
22 
     | 
    
         
             
                  end
         
     | 
| 
       25 
23 
     | 
    
         | 
| 
         @@ -63,12 +61,21 @@ module Buildr 
     | 
|
| 
       63 
61 
     | 
    
         
             
                    [buildr_project.test.resources.target, buildr_project.resources.target].compact
         
     | 
| 
       64 
62 
     | 
    
         
             
                  end
         
     | 
| 
       65 
63 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
                  def main_dependencies
         
     | 
| 
       67 
     | 
    
         
            -
                    buildr_project.compile.dependencies.map(&:to_s)
         
     | 
| 
       68 
     | 
    
         
            -
                  end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
64 
     | 
    
         
             
                  def test_dependencies
         
     | 
| 
       71 
     | 
    
         
            -
                    buildr_project. 
     | 
| 
      
 65 
     | 
    
         
            +
                    main_dependencies_paths = buildr_project.compile.dependencies.map(&:to_s)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    target_dir = buildr_project.compile.target.to_s
         
     | 
| 
      
 67 
     | 
    
         
            +
                    buildr_project.test.compile.dependencies.select{|d| d.to_s != target_dir}.collect do |d|
         
     | 
| 
      
 68 
     | 
    
         
            +
                      dependency_path = d.to_s
         
     | 
| 
      
 69 
     | 
    
         
            +
                      export = main_dependencies_paths.include?(dependency_path)
         
     | 
| 
      
 70 
     | 
    
         
            +
                      source_path = nil
         
     | 
| 
      
 71 
     | 
    
         
            +
                      if d.respond_to?(:to_spec_hash)
         
     | 
| 
      
 72 
     | 
    
         
            +
                        source_spec = d.to_spec_hash.merge(:classifier => 'sources')
         
     | 
| 
      
 73 
     | 
    
         
            +
                        source_path = Buildr.artifact(source_spec).to_s
         
     | 
| 
      
 74 
     | 
    
         
            +
                        source_path = nil unless File.exist?(source_path)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      end
         
     | 
| 
      
 76 
     | 
    
         
            +
                      [dependency_path, export, source_path]
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
       72 
79 
     | 
    
         
             
                  end
         
     | 
| 
       73 
80 
     | 
    
         | 
| 
       74 
81 
     | 
    
         
             
                  def base_directory
         
     | 
| 
         @@ -83,6 +90,14 @@ module Buildr 
     | 
|
| 
       83 
90 
     | 
    
         
             
                    self.facets << REXML::Document.new(target.string).root
         
     | 
| 
       84 
91 
     | 
    
         
             
                  end
         
     | 
| 
       85 
92 
     | 
    
         | 
| 
      
 93 
     | 
    
         
            +
                  def skip_content?
         
     | 
| 
      
 94 
     | 
    
         
            +
                    !!@skip_content
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  def skip_content!
         
     | 
| 
      
 98 
     | 
    
         
            +
                    @skip_content = true
         
     | 
| 
      
 99 
     | 
    
         
            +
                  end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       86 
101 
     | 
    
         
             
                  protected
         
     | 
| 
       87 
102 
     | 
    
         | 
| 
       88 
103 
     | 
    
         
             
                  def base_document
         
     | 
| 
         @@ -112,16 +127,13 @@ module Buildr 
     | 
|
| 
       112 
127 
     | 
    
         
             
                  end
         
     | 
| 
       113 
128 
     | 
    
         | 
| 
       114 
129 
     | 
    
         
             
                  def module_root_component
         
     | 
| 
       115 
     | 
    
         
            -
                    m2repo = Buildr::Repositories.instance.local
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
130 
     | 
    
         
             
                    create_component("NewModuleRootManager", "inherit-compiler-output" => "false") do |xml|
         
     | 
| 
       118 
131 
     | 
    
         
             
                      generate_compile_output(xml)
         
     | 
| 
       119 
     | 
    
         
            -
                      generate_content(xml)
         
     | 
| 
      
 132 
     | 
    
         
            +
                      generate_content(xml) unless skip_content?
         
     | 
| 
       120 
133 
     | 
    
         
             
                      generate_initial_order_entries(xml)
         
     | 
| 
       121 
134 
     | 
    
         | 
| 
       122 
135 
     | 
    
         
             
                      # Note: Use the test classpath since IDEA compiles both "main" and "test" classes using the same classpath
         
     | 
| 
       123 
     | 
    
         
            -
                      self.test_dependencies.each do |dependency_path|
         
     | 
| 
       124 
     | 
    
         
            -
                        export = self.main_dependencies.include?(dependency_path)
         
     | 
| 
      
 136 
     | 
    
         
            +
                      self.test_dependencies.each do |dependency_path, export, source_path|
         
     | 
| 
       125 
137 
     | 
    
         
             
                        project_for_dependency = Buildr.projects.detect do |project|
         
     | 
| 
       126 
138 
     | 
    
         
             
                          project.packages.detect { |pkg| pkg.to_s == dependency_path }
         
     | 
| 
       127 
139 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -130,52 +142,69 @@ module Buildr 
     | 
|
| 
       130 
142 
     | 
    
         
             
                            generate_project_dependency( xml, project_for_dependency.iml.name, export )
         
     | 
| 
       131 
143 
     | 
    
         
             
                          end
         
     | 
| 
       132 
144 
     | 
    
         
             
                          next
         
     | 
| 
       133 
     | 
    
         
            -
                         
     | 
| 
       134 
     | 
    
         
            -
                           
     | 
| 
       135 
     | 
    
         
            -
                          unless self.local_repository_env_override.nil?
         
     | 
| 
       136 
     | 
    
         
            -
                            entry_path = entry_path.sub(m2repo, "$#{self.local_repository_env_override}$")
         
     | 
| 
       137 
     | 
    
         
            -
                          end
         
     | 
| 
       138 
     | 
    
         
            -
                          generate_module_lib(xml, "jar://#{entry_path}!/", export )
         
     | 
| 
      
 145 
     | 
    
         
            +
                        else
         
     | 
| 
      
 146 
     | 
    
         
            +
                          generate_module_lib(xml, jar_path(dependency_path), export, (source_path ? jar_path(source_path) : nil))
         
     | 
| 
       139 
147 
     | 
    
         
             
                        end
         
     | 
| 
       140 
148 
     | 
    
         
             
                      end
         
     | 
| 
       141 
149 
     | 
    
         | 
| 
       142 
150 
     | 
    
         
             
                      self.resources.each do |resource|
         
     | 
| 
       143 
     | 
    
         
            -
                        generate_module_lib(xml,  
     | 
| 
      
 151 
     | 
    
         
            +
                        generate_module_lib(xml, file_path(resource.to_s), true, nil)
         
     | 
| 
       144 
152 
     | 
    
         
             
                      end
         
     | 
| 
       145 
153 
     | 
    
         | 
| 
       146 
154 
     | 
    
         
             
                      xml.orderEntryProperties
         
     | 
| 
       147 
155 
     | 
    
         
             
                    end
         
     | 
| 
       148 
156 
     | 
    
         
             
                  end
         
     | 
| 
       149 
157 
     | 
    
         | 
| 
      
 158 
     | 
    
         
            +
                  def jar_path(path)
         
     | 
| 
      
 159 
     | 
    
         
            +
                    "jar://#{resolve_path(path)}!/"
         
     | 
| 
      
 160 
     | 
    
         
            +
                  end
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                  def file_path(path)
         
     | 
| 
      
 163 
     | 
    
         
            +
                    "file://#{resolve_path(path)}"
         
     | 
| 
      
 164 
     | 
    
         
            +
                  end
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
                  def resolve_path(path)
         
     | 
| 
      
 167 
     | 
    
         
            +
                    m2repo = Buildr::Repositories.instance.local
         
     | 
| 
      
 168 
     | 
    
         
            +
                    if path.to_s.index(m2repo) == 0 && !self.local_repository_env_override.nil?
         
     | 
| 
      
 169 
     | 
    
         
            +
                      return path.sub(m2repo, "$#{self.local_repository_env_override}$")
         
     | 
| 
      
 170 
     | 
    
         
            +
                    else
         
     | 
| 
      
 171 
     | 
    
         
            +
                      return "$MODULE_DIR$/#{relative(path)}"
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
      
 173 
     | 
    
         
            +
                  end
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
       150 
175 
     | 
    
         
             
                  def relative(path)
         
     | 
| 
       151 
     | 
    
         
            -
                    Util.relative_path(File.expand_path(path.to_s), self.base_directory)
         
     | 
| 
      
 176 
     | 
    
         
            +
                    ::Buildr::Util.relative_path(File.expand_path(path.to_s), self.base_directory)
         
     | 
| 
       152 
177 
     | 
    
         
             
                  end
         
     | 
| 
       153 
178 
     | 
    
         | 
| 
       154 
179 
     | 
    
         
             
                  def generate_compile_output(xml)
         
     | 
| 
       155 
     | 
    
         
            -
                    xml.output(:url =>  
     | 
| 
       156 
     | 
    
         
            -
                    xml.tag!("output-test", :url =>  
     | 
| 
      
 180 
     | 
    
         
            +
                    xml.output(:url => file_path(self.main_output_dir.to_s))
         
     | 
| 
      
 181 
     | 
    
         
            +
                    xml.tag!("output-test", :url => file_path(self.test_output_dir.to_s))
         
     | 
| 
       157 
182 
     | 
    
         
             
                    xml.tag!("exclude-output")
         
     | 
| 
       158 
183 
     | 
    
         
             
                  end
         
     | 
| 
       159 
184 
     | 
    
         | 
| 
       160 
185 
     | 
    
         
             
                  def generate_content(xml)
         
     | 
| 
       161 
     | 
    
         
            -
                    xml.content(:url =>  
     | 
| 
      
 186 
     | 
    
         
            +
                    xml.content(:url => "file://$MODULE_DIR$") do
         
     | 
| 
       162 
187 
     | 
    
         
             
                      # Source folders
         
     | 
| 
       163 
188 
     | 
    
         
             
                      {
         
     | 
| 
       164 
189 
     | 
    
         
             
                          :main => self.main_source_directories,
         
     | 
| 
       165 
190 
     | 
    
         
             
                          :test => self.test_source_directories
         
     | 
| 
       166 
191 
     | 
    
         
             
                      }.each do |kind, directories|
         
     | 
| 
       167 
192 
     | 
    
         
             
                        directories.map { |dir| relative(dir) }.compact.sort.uniq.each do |dir|
         
     | 
| 
       168 
     | 
    
         
            -
                          xml.sourceFolder :url =>  
     | 
| 
      
 193 
     | 
    
         
            +
                          xml.sourceFolder :url => file_path(dir), :isTestSource => (kind == :test ? 'true' : 'false')
         
     | 
| 
       169 
194 
     | 
    
         
             
                        end
         
     | 
| 
       170 
195 
     | 
    
         
             
                      end
         
     | 
| 
       171 
196 
     | 
    
         | 
| 
       172 
197 
     | 
    
         
             
                      # Exclude target directories
         
     | 
| 
       173 
     | 
    
         
            -
                      self.net_excluded_directories.sort.each do |dir|
         
     | 
| 
       174 
     | 
    
         
            -
                        xml.excludeFolder :url =>  
     | 
| 
      
 198 
     | 
    
         
            +
                      self.net_excluded_directories.select{|dir| relative_dir_inside_dir?(dir)}.sort.each do |dir|
         
     | 
| 
      
 199 
     | 
    
         
            +
                        xml.excludeFolder :url => file_path(dir)
         
     | 
| 
       175 
200 
     | 
    
         
             
                      end
         
     | 
| 
       176 
201 
     | 
    
         
             
                    end
         
     | 
| 
       177 
202 
     | 
    
         
             
                  end
         
     | 
| 
       178 
203 
     | 
    
         | 
| 
      
 204 
     | 
    
         
            +
                  def relative_dir_inside_dir?(dir)
         
     | 
| 
      
 205 
     | 
    
         
            +
                    !dir.include?("../")
         
     | 
| 
      
 206 
     | 
    
         
            +
                  end
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
       179 
208 
     | 
    
         
             
                  def generate_initial_order_entries(xml)
         
     | 
| 
       180 
209 
     | 
    
         
             
                    xml.orderEntry :type => "sourceFolder", :forTests => "false"
         
     | 
| 
       181 
210 
     | 
    
         
             
                    xml.orderEntry :type => "inheritedJdk"
         
     | 
| 
         @@ -187,7 +216,7 @@ module Buildr 
     | 
|
| 
       187 
216 
     | 
    
         
             
                    xml.orderEntry attribs
         
     | 
| 
       188 
217 
     | 
    
         
             
                  end
         
     | 
| 
       189 
218 
     | 
    
         | 
| 
       190 
     | 
    
         
            -
                  def generate_module_lib(xml, path, export)
         
     | 
| 
      
 219 
     | 
    
         
            +
                  def generate_module_lib(xml, path, export, source_path)
         
     | 
| 
       191 
220 
     | 
    
         
             
                    attribs = {:type => 'module-library'}
         
     | 
| 
       192 
221 
     | 
    
         
             
                    attribs[:exported] = '' if export
         
     | 
| 
       193 
222 
     | 
    
         
             
                    xml.orderEntry attribs do
         
     | 
| 
         @@ -196,7 +225,11 @@ module Buildr 
     | 
|
| 
       196 
225 
     | 
    
         
             
                          xml.root :url => path
         
     | 
| 
       197 
226 
     | 
    
         
             
                        end
         
     | 
| 
       198 
227 
     | 
    
         
             
                        xml.JAVADOC
         
     | 
| 
       199 
     | 
    
         
            -
                        xml.SOURCES
         
     | 
| 
      
 228 
     | 
    
         
            +
                        xml.SOURCES do
         
     | 
| 
      
 229 
     | 
    
         
            +
                          if source_path
         
     | 
| 
      
 230 
     | 
    
         
            +
                            xml.root :url => source_path
         
     | 
| 
      
 231 
     | 
    
         
            +
                          end
         
     | 
| 
      
 232 
     | 
    
         
            +
                        end
         
     | 
| 
       200 
233 
     | 
    
         
             
                      end
         
     | 
| 
       201 
234 
     | 
    
         
             
                    end
         
     | 
| 
       202 
235 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -42,9 +42,10 @@ module Buildr 
     | 
|
| 
       42 
42 
     | 
    
         
             
                      iidea.enhance [ file(ideafile.filename) ]
         
     | 
| 
       43 
43 
     | 
    
         
             
                      file(ideafile.filename => [Buildr.application.buildfile, module_dir]) do |task|
         
     | 
| 
       44 
44 
     | 
    
         
             
                        info "Writing #{task.name}"
         
     | 
| 
       45 
     | 
    
         
            -
                         
     | 
| 
       46 
     | 
    
         
            -
                         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
                        t = Tempfile.open("buildr-iidea")
         
     | 
| 
      
 46 
     | 
    
         
            +
                        temp_filename = t.path
         
     | 
| 
      
 47 
     | 
    
         
            +
                        t.close!
         
     | 
| 
      
 48 
     | 
    
         
            +
                        File.open(temp_filename, "w") do |f|
         
     | 
| 
       48 
49 
     | 
    
         
             
                          ideafile.write f
         
     | 
| 
       49 
50 
     | 
    
         
             
                        end
         
     | 
| 
       50 
51 
     | 
    
         
             
                        mv temp_filename, ideafile.filename
         
     | 
| 
         @@ -74,7 +75,11 @@ module Buildr 
     | 
|
| 
       74 
75 
     | 
    
         
             
                  def iml
         
     | 
| 
       75 
76 
     | 
    
         
             
                    if iml?
         
     | 
| 
       76 
77 
     | 
    
         
             
                      unless @iml
         
     | 
| 
       77 
     | 
    
         
            -
                         
     | 
| 
      
 78 
     | 
    
         
            +
                        inheritable_iml_source = self.parent
         
     | 
| 
      
 79 
     | 
    
         
            +
                        while inheritable_iml_source && !inheritable_iml_source.iml?
         
     | 
| 
      
 80 
     | 
    
         
            +
                          inheritable_iml_source = inheritable_iml_source.parent;
         
     | 
| 
      
 81 
     | 
    
         
            +
                        end
         
     | 
| 
      
 82 
     | 
    
         
            +
                        @iml = inheritable_iml_source ? inheritable_iml_source.iml.clone : IdeaModule.new
         
     | 
| 
       78 
83 
     | 
    
         
             
                        @iml.buildr_project = self
         
     | 
| 
       79 
84 
     | 
    
         
             
                      end
         
     | 
| 
       80 
85 
     | 
    
         
             
                      return @iml
         
     | 
    
        data/lib/buildr_iidea.rb
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'buildr'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require File.expand_path(File.dirname(__FILE__) + '/buildr/intellij_idea/version')
         
     | 
| 
       2 
3 
     | 
    
         
             
            require File.expand_path(File.dirname(__FILE__) + '/buildr/intellij_idea/idea_file')
         
     | 
| 
       3 
4 
     | 
    
         
             
            require File.expand_path(File.dirname(__FILE__) + '/buildr/intellij_idea/idea_module')
         
     | 
| 
       4 
5 
     | 
    
         
             
            require File.expand_path(File.dirname(__FILE__) + '/buildr/intellij_idea/idea_project')
         
     | 
| 
         @@ -2,6 +2,7 @@ require File.expand_path('../../../spec_helper', __FILE__) 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            ORDER_ENTRY_XPATH = "/module/component[@name='NewModuleRootManager']/orderEntry"
         
     | 
| 
       4 
4 
     | 
    
         
             
            DEPENDENCY_NAME = 'group:id:jar:1.0'
         
     | 
| 
      
 5 
     | 
    
         
            +
            DEPENDENCY_SOURCES_NAME = 'group:id:jar:sources:1.0'
         
     | 
| 
       5 
6 
     | 
    
         
             
            DEPENDENCY2_NAME = 'group:id2:jar:1.0'
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            describe "iidea:generate" do
         
     | 
| 
         @@ -20,7 +21,7 @@ describe "iidea:generate" do 
     | 
|
| 
       20 
21 
     | 
    
         
             
                  end
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
                  it "generates one exported 'module-library' orderEntry in IML" do
         
     | 
| 
       23 
     | 
    
         
            -
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library', @exported='']", 1)
         
     | 
| 
      
 24 
     | 
    
         
            +
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library', @exported='']/library/CLASSES/root", 1)
         
     | 
| 
       24 
25 
     | 
    
         
             
                  end
         
     | 
| 
       25 
26 
     | 
    
         
             
                end
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
         @@ -33,8 +34,22 @@ describe "iidea:generate" do 
     | 
|
| 
       33 
34 
     | 
    
         
             
                  end
         
     | 
| 
       34 
35 
     | 
    
         | 
| 
       35 
36 
     | 
    
         
             
                  it "generates one non-exported 'module-library' orderEntry in IML" do
         
     | 
| 
       36 
     | 
    
         
            -
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library' and @exported]", 0)
         
     | 
| 
       37 
     | 
    
         
            -
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library']", 1)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library' and @exported]/library/CLASSES/root", 0)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library']/library/CLASSES/root", 1)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                describe "with sources artifact present" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 44 
     | 
    
         
            +
                    artifact(DEPENDENCY_SOURCES_NAME) { |t| write t.to_s }
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @foo = define "foo" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                      compile.with DEPENDENCY_NAME
         
     | 
| 
      
 47 
     | 
    
         
            +
                    end
         
     | 
| 
      
 48 
     | 
    
         
            +
                    invoke_generate_task
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  it "generates 'module-library' orderEntry in IML with SOURCES specified" do
         
     | 
| 
      
 52 
     | 
    
         
            +
                    root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library', @exported='']/library/SOURCES/root", 1)
         
     | 
| 
       38 
53 
     | 
    
         
             
                  end
         
     | 
| 
       39 
54 
     | 
    
         
             
                end
         
     | 
| 
       40 
55 
     | 
    
         | 
| 
         @@ -49,7 +64,7 @@ describe "iidea:generate" do 
     | 
|
| 
       49 
64 
     | 
    
         | 
| 
       50 
65 
     | 
    
         
             
                  it "generates orderEntry with absolute path for classes jar" do
         
     | 
| 
       51 
66 
     | 
    
         
             
                    root_module_xml(@foo).should match_xpath("#{ORDER_ENTRY_XPATH}/library/CLASSES/root/@url",
         
     | 
| 
       52 
     | 
    
         
            -
                                                             "jar 
     | 
| 
      
 67 
     | 
    
         
            +
                                                             "jar://$MODULE_DIR$/home/.m2/repository/group/id/1.0/id-1.0.jar!/")
         
     | 
| 
       53 
68 
     | 
    
         
             
                  end
         
     | 
| 
       54 
69 
     | 
    
         
             
                end
         
     | 
| 
       55 
70 
     | 
    
         
             
                describe "with local_repository_env_override set to MAVEN_REPOSITORY" do
         
     | 
| 
         @@ -82,4 +97,20 @@ describe "iidea:generate" do 
     | 
|
| 
       82 
97 
     | 
    
         
             
                  root_module_xml(@foo).should have_nodes("#{ORDER_ENTRY_XPATH}[@type='module-library']", 2)
         
     | 
| 
       83 
98 
     | 
    
         
             
                end
         
     | 
| 
       84 
99 
     | 
    
         
             
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              describe "with a single non artifact dependency" do
         
     | 
| 
      
 102 
     | 
    
         
            +
                before do
         
     | 
| 
      
 103 
     | 
    
         
            +
                  @foo = define "foo" do
         
     | 
| 
      
 104 
     | 
    
         
            +
                    filename = _("foo-dep.jar")
         
     | 
| 
      
 105 
     | 
    
         
            +
                    File.open(filename,"w") { |t| write t.to_s }
         
     | 
| 
      
 106 
     | 
    
         
            +
                    compile.with filename
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
      
 108 
     | 
    
         
            +
                  invoke_generate_task
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                it "generates one exported 'module-library' orderEntry in IML" do
         
     | 
| 
      
 112 
     | 
    
         
            +
                  root_module_xml(@foo).should match_xpath("#{ORDER_ENTRY_XPATH}/library/CLASSES/root/@url",
         
     | 
| 
      
 113 
     | 
    
         
            +
                                                           "jar://$MODULE_DIR$/foo-dep.jar!/")
         
     | 
| 
      
 114 
     | 
    
         
            +
                end
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
       85 
116 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require File.expand_path('../../../spec_helper', __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "iidea:generate" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "with iml.skip_content! specified" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                before do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @foo = define "foo" do
         
     | 
| 
      
 7 
     | 
    
         
            +
                    iml.skip_content!
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  invoke_generate_task
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                it "generate an IML with no content section" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  doc = xml_document(@foo._(root_module_filename(@foo)))
         
     | 
| 
      
 14 
     | 
    
         
            +
                  doc.should_not have_xpath("/module/component[@name='NewModuleRootManager']/content")
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              describe "with iml.skip_content! not specified and standard layout" do
         
     | 
| 
      
 19 
     | 
    
         
            +
                before do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  @foo = define "foo" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  invoke_generate_task
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                it "generate an IML with content section" do
         
     | 
| 
      
 26 
     | 
    
         
            +
                  root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content")
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                it "generate an exclude in content section for reports" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                  root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                it "generate an exclude in content section for target" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              describe "with report dir outside content" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                before do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  layout = Layout::Default.new
         
     | 
| 
      
 41 
     | 
    
         
            +
                  layout[:reports] = "../reports"
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  @foo = define "foo", :layout => layout do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                  invoke_generate_task
         
     | 
| 
      
 46 
     | 
    
         
            +
                end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                it "generate an exclude in content section for target" do
         
     | 
| 
      
 49 
     | 
    
         
            +
                  root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/target']")
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                it "generates an content section without an exclude for report dir" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              describe "with target dir outside content" do
         
     | 
| 
      
 58 
     | 
    
         
            +
                before do
         
     | 
| 
      
 59 
     | 
    
         
            +
                  layout = Layout::Default.new
         
     | 
| 
      
 60 
     | 
    
         
            +
                  layout[:target] = "../target"
         
     | 
| 
      
 61 
     | 
    
         
            +
                  layout[:target, :main] = "../target"
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                  @foo = define "foo", :layout => layout do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  end
         
     | 
| 
      
 65 
     | 
    
         
            +
                  invoke_generate_task
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                it "generate an exclude in content section for reports" do
         
     | 
| 
      
 69 
     | 
    
         
            +
                  root_module_xml(@foo).should have_xpath("/module/component[@name='NewModuleRootManager']/content/excludeFolder[@url='file://$MODULE_DIR$/reports']")
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                it "generates an content section without an exclude for target dir" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                  root_module_xml(@foo).should have_nodes("/module/component[@name='NewModuleRootManager']/content/excludeFolder", 1)
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -28,4 +28,69 @@ describe "project extension" do 
     | 
|
| 
       28 
28 
     | 
    
         
             
              it "removes the 'idea7x:clean' task" do
         
     | 
| 
       29 
29 
     | 
    
         
             
                Rake::Task.tasks.detect{|task| task.to_s == "idea7x:clean"}.should be_nil
         
     | 
| 
       30 
30 
     | 
    
         
             
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              describe "#no_iml" do
         
     | 
| 
      
 33 
     | 
    
         
            +
                it "makes #iml? false" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  @foo = define "foo" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                    project.no_iml
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @foo.iml?.should be_false
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              describe "#iml" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                before do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  define "foo" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                    iml.suffix = "-top"
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    define "bar" do
         
     | 
| 
      
 47 
     | 
    
         
            +
                      iml.suffix = "-mid"
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                      define "baz" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                      end
         
     | 
| 
      
 51 
     | 
    
         
            +
                    end
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                it "inherits the direct parent's IML settings" do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  project('foo:bar:baz').iml.suffix.should == "-mid"
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                it "does not modify the parent's IML settings" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  project('foo').iml.suffix.should == "-top"
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                it "works even when the parent has no IML" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  lambda {
         
     | 
| 
      
 65 
     | 
    
         
            +
                    define "a" do
         
     | 
| 
      
 66 
     | 
    
         
            +
                      project.no_iml
         
     | 
| 
      
 67 
     | 
    
         
            +
                      define "b" do
         
     | 
| 
      
 68 
     | 
    
         
            +
                        iml.suffix = "-alone"
         
     | 
| 
      
 69 
     | 
    
         
            +
                      end
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
                  }.should_not raise_error
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                it "inherits from the first ancestor which has an IML" do
         
     | 
| 
      
 75 
     | 
    
         
            +
                  define "a" do
         
     | 
| 
      
 76 
     | 
    
         
            +
                    iml.suffix = "-a"
         
     | 
| 
      
 77 
     | 
    
         
            +
                    define "b" do
         
     | 
| 
      
 78 
     | 
    
         
            +
                      iml.suffix = "-b"
         
     | 
| 
      
 79 
     | 
    
         
            +
                      define "c" do
         
     | 
| 
      
 80 
     | 
    
         
            +
                        project.no_iml
         
     | 
| 
      
 81 
     | 
    
         
            +
                        define "d" do
         
     | 
| 
      
 82 
     | 
    
         
            +
                          project.no_iml
         
     | 
| 
      
 83 
     | 
    
         
            +
                          define "e" do
         
     | 
| 
      
 84 
     | 
    
         
            +
                            project.no_iml
         
     | 
| 
      
 85 
     | 
    
         
            +
                            define "f" do
         
     | 
| 
      
 86 
     | 
    
         
            +
                            end
         
     | 
| 
      
 87 
     | 
    
         
            +
                          end
         
     | 
| 
      
 88 
     | 
    
         
            +
                        end
         
     | 
| 
      
 89 
     | 
    
         
            +
                      end
         
     | 
| 
      
 90 
     | 
    
         
            +
                    end
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                  project("a:b:c:d:e:f").iml.suffix.should == "-b"
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
              end
         
     | 
| 
       31 
96 
     | 
    
         
             
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -2,10 +2,19 @@ require 'spec' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require File.expand_path(File.dirname(__FILE__) + '/xpath_matchers.rb')
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
            DEFAULT_BUILDR_DIR=File.expand_path(File.dirname(__FILE__) + '/../../buildr')
         
     | 
| 
       5 
     | 
    
         
            -
            BUILDR_DIR= 
     | 
| 
      
 5 
     | 
    
         
            +
            BUILDR_DIR =
         
     | 
| 
      
 6 
     | 
    
         
            +
              begin
         
     | 
| 
      
 7 
     | 
    
         
            +
                if ENV['BUILDR_DIR']
         
     | 
| 
      
 8 
     | 
    
         
            +
                  ENV['BUILDR_DIR']
         
     | 
| 
      
 9 
     | 
    
         
            +
                elsif File.exist?(File.expand_path('../buildr_dir', __FILE__))
         
     | 
| 
      
 10 
     | 
    
         
            +
                  File.read(File.expand_path('../buildr_dir', __FILE__)).strip
         
     | 
| 
      
 11 
     | 
    
         
            +
                else
         
     | 
| 
      
 12 
     | 
    
         
            +
                  DEFAULT_BUILDR_DIR
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
       6 
15 
     | 
    
         | 
| 
       7 
16 
     | 
    
         
             
            unless File.exist?("#{BUILDR_DIR}/buildr.gemspec")
         
     | 
| 
       8 
     | 
    
         
            -
              raise "Unable to find buildr.gemspec in #{BUILDR_DIR == DEFAULT_BUILDR_DIR ? 'guessed' : 'specified'} $ 
     | 
| 
      
 17 
     | 
    
         
            +
              raise "Unable to find buildr.gemspec in #{BUILDR_DIR == DEFAULT_BUILDR_DIR ? 'guessed' : 'specified'} $BUILDR_DIR (#{BUILDR_DIR})"
         
     | 
| 
       9 
18 
     | 
    
         
             
            end
         
     | 
| 
       10 
19 
     | 
    
         | 
| 
       11 
20 
     | 
    
         
             
            require 'rubygems'
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
                - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
                - 0
         
     | 
| 
       8 
     | 
    
         
            -
                -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 8 
     | 
    
         
            +
                - 5
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.0.5
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
              - Rhett Sutphin
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2010-05 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2010-07-05 00:00:00 +10:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
         @@ -38,6 +38,7 @@ extra_rdoc_files: 
     | 
|
| 
       38 
38 
     | 
    
         
             
              - CHANGELOG
         
     | 
| 
       39 
39 
     | 
    
         
             
            files: 
         
     | 
| 
       40 
40 
     | 
    
         
             
              - lib/buildr_iidea.rb
         
     | 
| 
      
 41 
     | 
    
         
            +
              - lib/buildr/intellij_idea/version.rb
         
     | 
| 
       41 
42 
     | 
    
         
             
              - lib/buildr/intellij_idea/idea_project.rb
         
     | 
| 
       42 
43 
     | 
    
         
             
              - lib/buildr/intellij_idea/project_extension.rb
         
     | 
| 
       43 
44 
     | 
    
         
             
              - lib/buildr/intellij_idea/idea_module.rb
         
     | 
| 
         @@ -55,6 +56,7 @@ files: 
     | 
|
| 
       55 
56 
     | 
    
         
             
              - spec/buildr/intellij_idea/initial_components_spec.rb
         
     | 
| 
       56 
57 
     | 
    
         
             
              - spec/buildr/intellij_idea/clean_spec.rb
         
     | 
| 
       57 
58 
     | 
    
         
             
              - spec/buildr/intellij_idea/dependency_spec.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
              - spec/buildr/intellij_idea/module_content_generation_spec.rb
         
     | 
| 
       58 
60 
     | 
    
         
             
              - spec/buildr/intellij_idea/template_spec.rb
         
     | 
| 
       59 
61 
     | 
    
         
             
              - buildr-iidea.gemspec
         
     | 
| 
       60 
62 
     | 
    
         
             
              - LICENSE
         
     | 
| 
         @@ -69,7 +71,7 @@ licenses: [] 
     | 
|
| 
       69 
71 
     | 
    
         
             
            post_install_message: Thanks for installing the Intellij IDEA extension for Buildr
         
     | 
| 
       70 
72 
     | 
    
         
             
            rdoc_options: 
         
     | 
| 
       71 
73 
     | 
    
         
             
              - --title
         
     | 
| 
       72 
     | 
    
         
            -
              - buildr-iidea 0.0. 
     | 
| 
      
 74 
     | 
    
         
            +
              - buildr-iidea 0.0.5
         
     | 
| 
       73 
75 
     | 
    
         
             
              - --main
         
     | 
| 
       74 
76 
     | 
    
         
             
              - README.rdoc
         
     | 
| 
       75 
77 
     | 
    
         
             
            require_paths: 
         
     |